⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jpegutil.cpp

📁 这是个人脸识别程序
💻 CPP
字号:
// $image\jpegutil.cpp 1.5 milbo$ jpeg library hooks// Warning: this is raw research code -- expect it to be quite messy.// milbo mar 2005 petalum#include <windows.h>#include <io.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <signal.h>#include <float.h>#include <math.h>#include <new.h>#include <direct.h>#include <sys/stat.h>#include <fstream.h>#include <iostream.h>extern FILE *Fopen(const char *sPath, const char *sMode);extern "C" {#define XMD_H	/* get cdjpeg.h to not issue compiler warnings */#include "cdjpeg.h"}//-----------------------------------------------------------------------------// Create the add-on message string table#define JMESSAGE(code,string)	string ,static const char * const cdjpeg_message_table[] = {#include "cderror.h"  NULL};//-----------------------------------------------------------------------------void ConvertJpgFileToBmpFile (const char sJpegFile[], FILE *pOutFile, unsigned Width){static struct jpeg_decompress_struct cinfo;static struct jpeg_error_mgr jerr;djpeg_dest_ptr dest_mgr = NULL;FILE *pInFile = NULL;JDIMENSION num_scanlines;/* Initialize the CONVERT_JPEG_TO_BMP decompression object with default error handling. */cinfo.err = jpeg_std_error(&jerr);jpeg_create_decompress(&cinfo);/* Add some application-specific error messages (from cderror.h) */jerr.addon_message_table = cdjpeg_message_table;jerr.first_addon_message = JMSG_FIRSTADDONCODE;jerr.last_addon_message = JMSG_LASTADDONCODE;pInFile = Fopen(sJpegFile, READ_BINARY);	// Fopen will exit with a msg if can't open/* Specify data source for decompression */jpeg_stdio_src(&cinfo, pInFile);/* Read file header, set default decompression parameters */(void)jpeg_read_header(&cinfo, true);cinfo.err->trace_level = 0;cinfo.dct_method = JDCT_ISLOW;	// milbo: this is the default in their vc libsdest_mgr = jinit_write_bmp(&cinfo, false);// lprintf("Decompressing %s => %s\n", sJpegFile, sBmpFile);dest_mgr->output_file = pOutFile;if (Width && cinfo.image_width != Width)	{	cinfo.scale_num = Width;	cinfo.scale_denom = cinfo.output_width;	}(void)jpeg_start_decompress(&cinfo);  			/* start decompressor */(*dest_mgr->start_output)(&cinfo, dest_mgr);	/* write output file header */while (cinfo.output_scanline < cinfo.output_height)   	/* process data */	{	num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer,										dest_mgr->buffer_height);	(*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);  	}/* Finish decompression and release memory. * I must do it in this order because output module has allocated memory * of lifespan JPOOL_IMAGE; it needs to finish before releasing memory. */(*dest_mgr->finish_output) (&cinfo, dest_mgr);(void)jpeg_finish_decompress(&cinfo);jpeg_destroy_decompress(&cinfo);fclose(pInFile);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -