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

📄 jpg.h

📁 实时监控
💻 H
字号:
/*
 *	本文件需要ijl.h, yuv2rgb.h, autobuf.h
 */
#ifndef _JPG_H
#define _JPG_H

#include "ijl.h"
#pragma comment(lib,"ijl11.lib")
#include "yuv2rgb.h"
#include "autobuf.h"

//#include "bmp_file.h"
// return JPG size
static DWORD compress_yuy2_jpg(void* buf, DWORD size, int w, int h, void* jpgbuf, byte q)
{
	JPEG_CORE_PROPERTIES jcp;
	int res = ijlInit(&jcp);

	bytebuf rgb(w*h*3);
	yuy2_rgb24((byte*)buf, w, h, rgb);

	jcp.DIBBytes = (byte*)rgb;
	jcp.DIBChannels = 3;
	jcp.DIBColor = IJL_BGR;
	jcp.DIBWidth = w;
	jcp.DIBHeight = -h;

	jcp.jquality = q;
	jcp.JPGBytes = (byte*)jpgbuf;
	jcp.JPGWidth = w;
	jcp.JPGHeight = h;

	res = ijlWrite(&jcp, IJL_JBUFF_WRITEWHOLEIMAGE );
	DWORD jpgsize = jcp.JPGSizeBytes;
	res = ijlFree(&jcp);

	return jpgsize;
}

static DWORD compress_yuy2_jpgf(void* buf, DWORD size, int w, int h, LPCTSTR jpgfile, byte q)
{
	JPEG_CORE_PROPERTIES jcp;
	int res = ijlInit(&jcp);
	
	bytebuf rgb(w*h*3);
	yuy2_rgb24((byte*)buf, w, h, rgb);

	jcp.DIBBytes = (byte*)rgb;
	jcp.DIBChannels = 3;
	jcp.DIBColor = IJL_RGB;
	jcp.DIBWidth = w;
	jcp.DIBHeight = h;
	
	jcp.JPGFile = const_cast<LPTSTR>(jpgfile);
	jcp.JPGWidth = w;
	jcp.JPGHeight = h;
	jcp.jquality = q;

	res = ijlWrite(&jcp, IJL_JFILE_WRITEWHOLEIMAGE );
	rgb.free();

	DWORD jpgsize = jcp.JPGSizeBytes;
	res = ijlFree(&jcp);
	
	return jpgsize;
}

#endif	// _JPG_H

⌨️ 快捷键说明

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