亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? jpegfile.cpp

?? About JPEG, executable on Visual C++
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
////////////////////////////////////////////////////////////
//	JpegFile - A C++ class to allow reading and writing of
//	RGB and Grayscale JPEG images.
//	It is based on the IJG V.6 code.
//
//	This class Copyright 1997, Chris Losinger
//	This is free to use and modify provided my name is 
//	included.
//
//	See jpegfile.h for usage.
//
////////////////////////////////////////////////////////////
#include "stdafx.h"

#undef FAR        // gets rid of a warning
#define XMD_H     // fixes a type redefiniton issue
#include "JpegFile.h"

#include <stdio.h>

#ifdef __cplusplus
	extern "C" {
#endif // __cplusplus

#include "jpeglib.h"

#ifdef __cplusplus
	}
#endif // __cplusplus

//
//
//

/*
 * <setjmp.h> is used for the optional error recovery mechanism shown in
 * the second part of the example.
 */

#include <setjmp.h>

// error handler, to avoid those pesky exit(0)'s

struct my_error_mgr {
  struct jpeg_error_mgr pub;	/* "public" fields */

  jmp_buf setjmp_buffer;	/* for return to caller */
};

typedef struct my_error_mgr * my_error_ptr;

//
//
//

METHODDEF(void) my_error_exit (j_common_ptr cinfo);

//
//	to handle fatal errors.
//	the original JPEG code will just exit(0). can't really
//	do that in Windows....
//

METHODDEF(void) my_error_exit (j_common_ptr cinfo)
{
	/* cinfo->err really points to a my_error_mgr struct, so coerce pointer */
	my_error_ptr myerr = (my_error_ptr) cinfo->err;

	char buffer[JMSG_LENGTH_MAX];

	/* Create the message */
	(*cinfo->err->format_message) (cinfo, buffer);

	/* Always display the message. */
	MessageBox(NULL,buffer,"JPEG Fatal Error",MB_ICONSTOP);


	/* Return control to the setjmp point */
	longjmp(myerr->setjmp_buffer, 1);
}

// store a scanline to our data buffer
void j_putRGBScanline(BYTE *jpegline, 
						 int widthPix,
						 BYTE *outBuf,
						 int row);

void j_putGrayScanlineToRGB(BYTE *jpegline, 
						 int widthPix,
						 BYTE *outBuf,
						 int row);


//
//	constructor doesn't do much - there's no real class here...
//

JpegFile::JpegFile()
{
}

//
//	
//

JpegFile::~JpegFile()
{
}

//
//	read a JPEG file
//


BYTE * JpegFile::JpegFileToRGB(CString fileName,
							   UINT *width,
							   UINT *height)

{

	// basic code from IJG Jpeg Code v6 example.c

	*width=0;
	*height=0;

	/* This struct contains the JPEG decompression parameters and pointers to
	* working space (which is allocated as needed by the JPEG library).
	*/
	struct jpeg_decompress_struct cinfo;
	/* We use our private extension JPEG error handler.
	* Note that this struct must live as long as the main JPEG parameter
	* struct, to avoid dangling-pointer problems.
	*/
	struct my_error_mgr jerr;
	/* More stuff */
	FILE * infile=NULL;		/* source file */

	JSAMPARRAY buffer;		/* Output row buffer */
	int row_stride;		/* physical row width in output buffer */
	char buf[250];

	/* In this example we want to open the input file before doing anything else,
	* so that the setjmp() error recovery below can assume the file is open.
	* VERY IMPORTANT: use "b" option to fopen() if you are on a machine that
	* requires it in order to read binary files.
	*/

	if ((infile = fopen(fileName, "rb")) == NULL) {
		sprintf(buf, "JPEG :\nCan't open %s\n", fileName);
		AfxMessageBox(buf);
		return NULL;
	}

	/* Step 1: allocate and initialize JPEG decompression object */

	/* We set up the normal JPEG error routines, then override error_exit. */
	cinfo.err = jpeg_std_error(&jerr.pub);
	jerr.pub.error_exit = my_error_exit;


	/* Establish the setjmp return context for my_error_exit to use. */
	if (setjmp(jerr.setjmp_buffer)) {
		/* If we get here, the JPEG code has signaled an error.
		 * We need to clean up the JPEG object, close the input file, and return.
		 */

		jpeg_destroy_decompress(&cinfo);

		if (infile!=NULL)
			fclose(infile);
		return NULL;
	}

	/* Now we can initialize the JPEG decompression object. */
	jpeg_create_decompress(&cinfo);

	/* Step 2: specify data source (eg, a file) */

	jpeg_stdio_src(&cinfo, infile);

	/* Step 3: read file parameters with jpeg_read_header() */

	(void) jpeg_read_header(&cinfo, TRUE);
	/* We can ignore the return value from jpeg_read_header since
	*   (a) suspension is not possible with the stdio data source, and
	*   (b) we passed TRUE to reject a tables-only JPEG file as an error.
	* See libjpeg.doc for more info.
	*/

	/* Step 4: set parameters for decompression */

	/* In this example, we don't need to change any of the defaults set by
	* jpeg_read_header(), so we do nothing here.
	*/

	/* Step 5: Start decompressor */

	(void) jpeg_start_decompress(&cinfo);
	/* We can ignore the return value since suspension is not possible
	* with the stdio data source.
	*/

	/* We may need to do some setup of our own at this point before reading
	* the data.  After jpeg_start_decompress() we have the correct scaled
	* output image dimensions available, as well as the output colormap
	* if we asked for color quantization.
	* In this example, we need to make an output work buffer of the right size.
	*/ 

	// get our buffer set to hold data
	BYTE *dataBuf;

	////////////////////////////////////////////////////////////
	// alloc and open our new buffer
	dataBuf=(BYTE *)new BYTE[cinfo.output_width * 3 * cinfo.output_height];
	if (dataBuf==NULL) {

		AfxMessageBox("JpegFile :\nOut of memory",MB_ICONSTOP);

		jpeg_destroy_decompress(&cinfo);
		
		fclose(infile);

		return NULL;
	}

	// how big is this thing gonna be?
	*width = cinfo.output_width;
	*height = cinfo.output_height;
	
	/* JSAMPLEs per row in output buffer */
	row_stride = cinfo.output_width * cinfo.output_components;

	/* Make a one-row-high sample array that will go away when done with image */
	buffer = (*cinfo.mem->alloc_sarray)
		((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);

	/* Step 6: while (scan lines remain to be read) */
	/*           jpeg_read_scanlines(...); */

	/* Here we use the library's state variable cinfo.output_scanline as the
	* loop counter, so that we don't have to keep track ourselves.
	*/
	while (cinfo.output_scanline < cinfo.output_height) {
		/* jpeg_read_scanlines expects an array of pointers to scanlines.
		 * Here the array is only one element long, but you could ask for
		 * more than one scanline at a time if that's more convenient.
		 */
		(void) jpeg_read_scanlines(&cinfo, buffer, 1);
		/* Assume put_scanline_someplace wants a pointer and sample count. */

		// asuumer all 3-components are RGBs
		if (cinfo.out_color_components==3) {
			
			j_putRGBScanline(buffer[0], 
								*width,
								dataBuf,
								cinfo.output_scanline-1);

		} else if (cinfo.out_color_components==1) {

			// assume all single component images are grayscale
			j_putGrayScanlineToRGB(buffer[0], 
								*width,
								dataBuf,
								cinfo.output_scanline-1);

		}

	}

	/* Step 7: Finish decompression */

	(void) jpeg_finish_decompress(&cinfo);
	/* We can ignore the return value since suspension is not possible
	* with the stdio data source.
	*/

	/* Step 8: Release JPEG decompression object */

	/* This is an important step since it will release a good deal of memory. */
	jpeg_destroy_decompress(&cinfo);

	/* After finish_decompress, we can close the input file.
	* Here we postpone it until after no more JPEG errors are possible,
	* so as to simplify the setjmp error logic above.  (Actually, I don't
	* think that jpeg_destroy can do an error exit, but why assume anything...)
	*/
	fclose(infile);

	/* At this point you may want to check to see whether any corrupt-data
	* warnings occurred (test whether jerr.pub.num_warnings is nonzero).
	*/

	return dataBuf;
}

BOOL JpegFile::GetJPGDimensions(CString fileName,
								UINT *width,
								UINT *height)

{
	// basic code from IJG Jpeg Code v6 example.c

	/* This struct contains the JPEG decompression parameters and pointers to
	* working space (which is allocated as needed by the JPEG library).
	*/
	struct jpeg_decompress_struct cinfo;
	/* We use our private extension JPEG error handler.
	* Note that this struct must live as long as the main JPEG parameter
	* struct, to avoid dangling-pointer problems.
	*/
	struct my_error_mgr jerr;
	/* More stuff */
	FILE * infile=NULL;		/* source file */
	char buf[250];

	/* In this example we want to open the input file before doing anything else,
	* so that the setjmp() error recovery below can assume the file is open.
	* VERY IMPORTANT: use "b" option to fopen() if you are on a machine that
	* requires it in order to read binary files.
	*/

	if ((infile = fopen(fileName, "rb")) == NULL) {
		sprintf(buf, "JPEG :\nCan't open %s\n", fileName);
		AfxMessageBox(buf);
		return FALSE;
	}

	/* Step 1: allocate and initialize JPEG decompression object */

	/* We set up the normal JPEG error routines, then override error_exit. */
	cinfo.err = jpeg_std_error(&jerr.pub);
	jerr.pub.error_exit = my_error_exit;


	/* Establish the setjmp return context for my_error_exit to use. */
	if (setjmp(jerr.setjmp_buffer)) {
		/* If we get here, the JPEG code has signaled an error.
		 * We need to clean up the JPEG object, close the input file, and return.
		 */

		jpeg_destroy_decompress(&cinfo);

		if (infile!=NULL)
			fclose(infile);
		return FALSE;
	}

	/* Now we can initialize the JPEG decompression object. */
	jpeg_create_decompress(&cinfo);

	/* Step 2: specify data source (eg, a file) */

	jpeg_stdio_src(&cinfo, infile);

	/* Step 3: read file parameters with jpeg_read_header() */

	(void) jpeg_read_header(&cinfo, TRUE);
	/* We can ignore the return value from jpeg_read_header since
	*   (a) suspension is not possible with the stdio data source, and
	*   (b) we passed TRUE to reject a tables-only JPEG file as an error.
	* See libjpeg.doc for more info.
	*/


	// how big is this thing ?
	*width = cinfo.image_width;
	*height = cinfo.image_height;

	/* Step 8: Release JPEG decompression object */

	/* This is an important step since it will release a good deal of memory. */
	jpeg_destroy_decompress(&cinfo);

	/* After finish_decompress, we can close the input file.
	* Here we postpone it until after no more JPEG errors are possible,
	* so as to simplify the setjmp error logic above.  (Actually, I don't
	* think that jpeg_destroy can do an error exit, but why assume anything...)
	*/
	fclose(infile);

	/* At this point you may want to check to see whether any corrupt-data
	* warnings occurred (test whether jerr.pub.num_warnings is nonzero).
	*/

	return TRUE;
}

//
//
//

BYTE *JpegFile::RGBFromDWORDAligned(BYTE *inBuf,
									UINT widthPix, 
									UINT widthBytes,
									UINT height)

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一本久道中文字幕精品亚洲嫩| 蜜桃av噜噜一区二区三区小说| 欧美成人video| 精品婷婷伊人一区三区三| 一本色道久久综合狠狠躁的推荐| 国产精品18久久久久| 精品制服美女丁香| 美腿丝袜亚洲三区| 免费观看在线综合色| 麻豆久久久久久| 国产一区在线观看视频| 国产伦精品一区二区三区免费| 国产老女人精品毛片久久| 韩国女主播成人在线观看| 国产精品一区二区在线观看不卡| 国产福利一区二区三区在线视频| 国产大陆精品国产| 97久久精品人人澡人人爽| 91麻豆精品秘密| 欧美日本乱大交xxxxx| 欧美一区日韩一区| 久久精品一区二区三区av| 国产精品乱人伦中文| 亚洲品质自拍视频| 男人的j进女人的j一区| 99精品视频中文字幕| 欧美日韩一区高清| 久久久一区二区| 亚洲美女一区二区三区| 久久av中文字幕片| 99久久99久久精品国产片果冻| 欧美在线观看禁18| 久久色.com| 一区二区免费看| 国产综合色在线| 色综合色狠狠天天综合色| 欧美一区二区福利视频| 中文字幕不卡的av| 蜜桃视频免费观看一区| 91在线无精精品入口| 欧美一区二区三区免费大片 | 亚洲欧美日韩系列| 婷婷综合在线观看| 97精品视频在线观看自产线路二| 91精品国产综合久久精品app| 久久久久久久久久久久久女国产乱| 综合久久久久久| 精品亚洲porn| 欧美三区在线观看| 国产日韩欧美激情| 日韩av不卡一区二区| 成人福利电影精品一区二区在线观看 | 亚洲精品国产a| 国产又黄又大久久| 日韩一区二区精品| 亚洲综合色婷婷| 国产91富婆露脸刺激对白| 日韩欧美另类在线| 亚洲成人午夜影院| 91性感美女视频| 欧美国产精品中文字幕| 久久国产麻豆精品| 制服丝袜一区二区三区| 亚洲r级在线视频| 94-欧美-setu| 国产精品三级在线观看| 国产成人在线视频网站| 欧美精品一区二区三区一线天视频 | 亚洲成在线观看| 日韩一级完整毛片| 日韩手机在线导航| 欧美视频精品在线| 不卡的看片网站| 久久精品国产亚洲a| 樱桃视频在线观看一区| 国产区在线观看成人精品| 欧美日韩美女一区二区| 99re这里只有精品首页| 国内精品伊人久久久久av一坑 | 欧美在线你懂得| 综合欧美亚洲日本| 99国产精品国产精品久久| 欧美激情一区二区在线| 成人一级视频在线观看| 国产精品卡一卡二| 欧美性色aⅴ视频一区日韩精品| 一区二区三区免费网站| 欧美日韩视频在线一区二区| 亚洲成人免费电影| 欧美一区二区三区免费视频| 精品亚洲成a人在线观看| 久久嫩草精品久久久精品| 国产91露脸合集magnet| 国产精品第一页第二页第三页| 91免费在线播放| 亚洲香肠在线观看| 欧美变态口味重另类| 国产福利精品一区二区| 一区二区在线观看免费视频播放| 欧美日韩国产综合一区二区| 裸体健美xxxx欧美裸体表演| 久久蜜桃香蕉精品一区二区三区| 国产69精品久久久久毛片| 亚洲男人的天堂在线观看| 欧美欧美午夜aⅴ在线观看| 激情综合色播激情啊| 国产精品精品国产色婷婷| 欧美日韩成人激情| 国产精品影视网| 精品一区二区三区在线观看| 一色屋精品亚洲香蕉网站| 欧美群妇大交群中文字幕| 国产福利不卡视频| 亚洲成a人在线观看| 国产欧美中文在线| 欧美精品一二三四| 成人91在线观看| 日韩激情一二三区| 亚洲天堂中文字幕| 日韩欧美三级在线| 在线亚洲精品福利网址导航| 韩国女主播一区| 亚洲资源在线观看| 亚洲国产电影在线观看| 日韩一区二区三区三四区视频在线观看| 国产激情精品久久久第一区二区 | 免费精品99久久国产综合精品| 欧美国产视频在线| 日韩免费在线观看| 欧美日韩一级二级三级| 丁香啪啪综合成人亚洲小说 | 国模一区二区三区白浆| 亚洲va欧美va天堂v国产综合| 国产精品网站一区| 日韩精品专区在线影院重磅| 在线视频综合导航| 成人爱爱电影网址| 国产ts人妖一区二区| 麻豆久久久久久| 色婷婷国产精品久久包臀| 精油按摩中文字幕久久| 日本午夜一本久久久综合| 亚洲成人动漫在线免费观看| 最新中文字幕一区二区三区| 国产日产欧美精品一区二区三区| 日韩一区二区高清| 日韩视频123| 欧美一区二区日韩| 日韩一区二区三区av| 制服丝袜日韩国产| 欧美日韩一二三| 欧美三级蜜桃2在线观看| 欧美亚男人的天堂| 欧美美女激情18p| 欧美午夜精品一区二区蜜桃| 色婷婷av一区二区三区大白胸| 99久久精品国产麻豆演员表| 成人午夜看片网址| 91在线精品秘密一区二区| 91丝袜高跟美女视频| 在线视频观看一区| 欧美精品一级二级三级| 欧美一区中文字幕| 久久婷婷国产综合国色天香| 国产三级欧美三级日产三级99 | 一区二区成人在线| 亚洲影院在线观看| 日韩精品亚洲专区| 激情五月激情综合网| 国产精品一卡二卡| 99久久婷婷国产综合精品电影 | 波多野结衣在线一区| 不卡免费追剧大全电视剧网站| 99精品国产99久久久久久白柏| 色又黄又爽网站www久久| 91久久奴性调教| 欧美一区二区私人影院日本| 精品999久久久| 国产精品高潮久久久久无| 一区二区三区蜜桃| 精品一区二区三区免费播放| 东方aⅴ免费观看久久av| 91久久国产最好的精华液| 欧美一区二区女人| 国产精品美女久久福利网站| 夜夜嗨av一区二区三区| 美日韩一区二区三区| 成人av电影在线| 欧美老年两性高潮| 中文字幕精品—区二区四季| 性欧美大战久久久久久久久| 成人一区二区三区在线观看| 欧美精品成人一区二区三区四区| 久久久一区二区三区捆绑**| 亚洲第一电影网| 国产一区二区三区精品欧美日韩一区二区三区 | 亚洲一区在线播放| 国产在线看一区| 欧美视频三区在线播放| 久久色成人在线|