动态将摄像头bmp数据转换成jpg格式(不完善)

由于需要经常存储摄像头捕捉到的bmp数据,bmp数据没有经过压缩,每一张都很大,存储到一定空间的时候就需要删除一部分,非常麻烦.如果存储的bmp图像数据不需要做特殊处理,可以将其存为jpg格式.会节省很多空间.

使用GDI+:

</pre><pre name="code" class="html">#include "gdiplus.h" 
using namespace Gdiplus;
//全局变量
GdiplusStartupInput  m_Gdistart; 
ULONG_PTR  m_GdiplusToken; 
//初始化
GdiplusStartup(&m_GdiplusToken,& m_Gdistart,NULL); 
//程序结束
GdiplusShutdown(m_GdiplusToken); 

上面是基本配置

void CXXX::SaveBmp2Jpg(char* filename)
{
	BITMAPFILEHEADER bfh;
	bfh.bfType = 19778;
	bfh.bfSize = imwidth * imheight * nCount;
	bfh.bfReserved1 = 0;
	bfh.bfReserved2 = 0;
	bfh.bfOffBits = 54;
	BITMAPINFOHEADER bih;
	bih.biSize = 40;
	bih.biWidth = imwidth;
	bih.biHeight = imheight;
	bih.biPlanes = 1;	//must be set to 1
	bih.biBitCount = 24;
	bih.biCompression = 0;
	bih.biSizeImage = (imwidth*nCount*8+31)/32*nCount*imheight;
	bih.biXPelsPerMeter = 0;
	bih.biYPelsPerMeter = 0;
	b
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值