windows gdi截屏使用libjpeg保存jpg文件

2021-05-06 15:27

阅读:614

标签:set   point   har   stdio.h   screen   nts   window   cpp   compress   

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

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


评论


亲,登录后才可以留言!