windows gdi截屏使用libjpeg保存jpg文件
2021-05-06 15:27
标签:set point har stdio.h screen nts window cpp compress gdi_jpg.cpp windows gdi截屏使用libjpeg保存jpg文件 标签:set point har stdio.h screen nts window cpp compress 原文地址:http://www.cnblogs.com/hatsusakana/p/7660314.html/*
* windows gdi截屏使用libjpeg保存jpg文件
*/
#include "stdio.h"
#include "windows.h"
#include "libjpeg/jpeglib.h"
#pragma comment(lib,"libjpeg/libjpeg.lib")
void bgr_to_jpgfile(BYTE *rgb,int size,int w,int h,char *jpgfile)
{
struct jpeg_error_mgr jerr;
jpeg_std_error(&jerr);
struct jpeg_compress_struct cinfo;
cinfo.err = &jerr;
jpeg_create_compress(&cinfo);
FILE *fp = fopen(jpgfile,"wb+");
jpeg_stdio_dest(&cinfo,fp);
cinfo.image_width = w;
cinfo.image_height = h;
cinfo.input_components = 3;
cinfo.in_color_space = JCS_RGB;
jpeg_set_defaults(&cinfo);
jpeg_set_quality(&cinfo, 100, TRUE);
jpeg_start_compress(&cinfo,TRUE);
int row_stride = cinfo.image_width*cinfo.input_components;
JSAMPROW row_pointer[1];
while(cinfo.next_scanline
文章标题:windows gdi截屏使用libjpeg保存jpg文件
文章链接:http://soscw.com/index.php/essay/83269.html