?? encode.c
字號:
#include <assert.h>#include <err.h>#include <errno.h>#include <fcntl.h>#include <stdio.h>#include <stdint.h>#include <stdlib.h>#include <stdbool.h>#include <string.h>#include <sysexits.h>#include <unistd.h>#include <stdint.h>#include <signal.h>#include <alloca.h>#include <limits.h>#include <ctype.h>#include <poll.h>#include <sys/mman.h>#include <sys/ioctl.h>#include <sys/time.h>#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */#include "zeviojpegapi.h"//#include "zsp_jpeglib.h"//#define TRACE fprintf(stdout, "( %s : %s : %d )\n", __FILE__, __func__, __LINE__);#define TRACEstatic struct jpeg_compress_struct cinfo;static struct jpeg_error_mgr jerr;static FILE *output_file;void encodeStart( zJpegDecompressPtr decompressCinfo, char *filename, unsigned int oWidth, unsigned int oHeight, unsigned int quality ){ char outfilename[128]; sprintf(outfilename, "%s.jpg", filename); output_file = fopen(outfilename, "wb"); assert(output_file); cinfo.err = jpeg_std_error(&jerr); jpeg_create_compress(&cinfo); cinfo.in_color_space = JCS_RGB; jpeg_set_defaults(&cinfo); cinfo.data_precision = 8; cinfo.image_width = oWidth; cinfo.image_height = oHeight; cinfo.input_components = 3; jpeg_default_colorspace(&cinfo); cinfo.arith_code = FALSE; cinfo.optimize_coding = FALSE; cinfo.dct_method = JDCT_IFAST; zJpegSetCompressCinfo(decompressCinfo, &cinfo); jpeg_set_quality( &cinfo, quality, FALSE); jpeg_stdio_dest(&cinfo, output_file); /* Start compressor */ jpeg_start_compress(&cinfo, TRUE);}void encodeEnd( void ){ jpeg_finish_compress(&cinfo); jpeg_destroy_compress(&cinfo); fclose(output_file);}void encodeWriteAPP1( unsigned char *pHeader, unsigned int length){ jpeg_write_marker ( &cinfo, JPEG_APP0+1, pHeader, length );}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -