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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? jpegfile.cpp

?? CAM-TOOL 是高效率高質量的模具制造的最好CAM解決方案。在當今的 Windows 操作環境里
?? 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"
#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)

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

	// 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);

      if (dataBuf!=NULL)
      {
         delete [] dataBuf;
      }

		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.
	*/ 

	////////////////////////////////////////////////////////////
	// 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,

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
天天操天天综合网| 在线播放视频一区| 午夜私人影院久久久久| 欧美精品一区二区三区高清aⅴ | 国产精品视频在线看| 欧美日韩一区二区三区在线看| 精品一区二区三区在线播放视频| 亚洲同性同志一二三专区| 日韩精品一区国产麻豆| 色综合欧美在线| 国产一区二区伦理| 午夜在线电影亚洲一区| 欧美国产日韩在线观看| 日韩精品影音先锋| 欧美久久免费观看| 色综合色狠狠综合色| 岛国精品在线观看| 久久精品国产第一区二区三区| 亚洲欧美激情一区二区| 国产日产欧美精品一区二区三区| 欧美日韩aaaaaa| 91成人免费网站| av电影在线观看不卡| 国产69精品久久777的优势| 蜜臀av性久久久久蜜臀av麻豆| 香蕉成人啪国产精品视频综合网 | 色欧美片视频在线观看| 成人午夜视频福利| 国产九色精品成人porny| 日本不卡在线视频| 国产乱码字幕精品高清av | 一区二区三区美女视频| 中文字幕日韩av资源站| 中文字幕乱码一区二区免费| 国产日韩欧美综合一区| 久久久久久电影| 亚洲精品在线三区| 2020国产精品自拍| 久久久天堂av| 国产亚洲综合在线| 国产日韩精品一区二区浪潮av| 欧美成人高清电影在线| 精品成人在线观看| 久久嫩草精品久久久久| 久久久久亚洲综合| 久久久亚洲精品一区二区三区 | 捆绑调教美女网站视频一区| 青青草国产精品亚洲专区无| 日韩高清不卡一区| 日本人妖一区二区| 毛片不卡一区二区| 国内外成人在线视频| 国产一区二区视频在线播放| 国产精品18久久久| 99精品视频中文字幕| 91亚洲国产成人精品一区二区三| 色综合久久久久| 欧美日韩在线一区二区| 欧美一级理论性理论a| 精品国产麻豆免费人成网站| 久久久久高清精品| 亚洲少妇中出一区| 亚洲国产日日夜夜| 国产原创一区二区| 99久久免费精品| 欧美色综合网站| 精品99一区二区三区| 国产精品网曝门| 亚洲国产你懂的| 精品一区二区三区在线观看| av一区二区不卡| 777奇米四色成人影色区| 精品欧美一区二区三区精品久久| 中文在线资源观看网站视频免费不卡 | 欧美在线小视频| 精品美女一区二区| 亚洲欧美日韩中文播放| 日韩福利电影在线| 欧美亚洲精品一区| 久久亚洲精品小早川怜子| 综合电影一区二区三区 | 久久综合九色综合久久久精品综合| 亚洲国产成人在线| 亚洲国产成人91porn| 国产乱码字幕精品高清av| 色婷婷国产精品综合在线观看| 日韩免费福利电影在线观看| 中文字幕在线不卡| 久久激情五月激情| 日本精品一区二区三区高清| 2021中文字幕一区亚洲| 有码一区二区三区| 国产精品亚洲人在线观看| 欧洲精品一区二区| 久久久精品免费免费| 午夜一区二区三区在线观看| 国产盗摄一区二区三区| 在线不卡中文字幕| ...av二区三区久久精品| 老色鬼精品视频在线观看播放| 99re这里都是精品| 国产午夜精品一区二区三区视频| 亚洲午夜精品17c| 成人免费视频播放| 欧美成人a∨高清免费观看| 亚洲午夜免费福利视频| 丁香激情综合五月| 久久综合狠狠综合久久激情| 亚洲午夜在线观看视频在线| 成人av在线资源网| 亚洲精品在线一区二区| 日韩成人精品视频| 欧美三级韩国三级日本三斤| 国产精品成人一区二区三区夜夜夜| 蜜桃在线一区二区三区| 欧美日韩日日摸| 亚洲美女精品一区| 成人av免费在线| 国产亚洲精品免费| 精品一区二区日韩| 日韩欧美一区二区在线视频| 亚洲mv在线观看| 91豆麻精品91久久久久久| 国产精品不卡在线观看| 成人高清视频免费观看| 国产亚洲精品bt天堂精选| 国产一区二区三区免费观看| 欧美一级二级在线观看| 亚洲成人动漫精品| 欧美日韩在线观看一区二区 | 免费观看91视频大全| 欧美日韩精品专区| 亚洲午夜精品一区二区三区他趣| 色嗨嗨av一区二区三区| 亚洲欧美日韩一区二区| 97久久精品人人做人人爽| 国产精品麻豆视频| 99国产精品久久久久| 亚洲色图欧美偷拍| 91香蕉视频mp4| 亚洲女同一区二区| 欧洲人成人精品| 艳妇臀荡乳欲伦亚洲一区| 欧美怡红院视频| 亚洲6080在线| 欧美一区二区三区免费在线看 | 97精品久久久午夜一区二区三区| 国产亚洲一区二区在线观看| 国产成人精品亚洲777人妖| 国产精品女主播在线观看| 99久久婷婷国产综合精品电影| 亚洲欧美日韩久久| 欧美性受极品xxxx喷水| 琪琪久久久久日韩精品| 欧美精品一区二区三区高清aⅴ| 国产真实乱子伦精品视频| 国产日韩在线不卡| 91麻豆swag| 无吗不卡中文字幕| 欧美成人免费网站| 国产成人精品亚洲日本在线桃色| 综合欧美一区二区三区| 欧美日韩视频第一区| 亚洲不卡在线观看| 精品系列免费在线观看| 亚洲成av人综合在线观看| 亚洲欧美另类久久久精品 | 国产精品一区免费在线观看| 亚洲成人av资源| 亚洲欧美乱综合| 亚洲欧美色综合| 亚洲777理论| 亚洲国产精品一区二区久久| 亚洲妇熟xx妇色黄| 亚洲无人区一区| 亚洲国产中文字幕在线视频综合 | 99久久婷婷国产精品综合| 激情五月婷婷综合网| 舔着乳尖日韩一区| 亚洲国产欧美在线人成| 亚洲欧美综合色| 国产精品区一区二区三| 欧美国产一区在线| 欧美—级在线免费片| 久久久精品欧美丰满| 亚洲日本在线a| 亚洲美女一区二区三区| 亚洲四区在线观看| 久久久久国产精品麻豆ai换脸| 91 com成人网| 日韩一级免费观看| 日韩欧美一级在线播放| 日韩激情视频在线观看| 一级日本不卡的影视| 国产成人精品网址| 国产精品第一页第二页第三页| 国产精品理论片在线观看| 一区二区三区**美女毛片| 国产欧美一区二区精品性色超碰 | 成人理论电影网|