Converting a BMP Image to a PNG Image

本文介绍如何使用GDI+的Image类Save方法将BMP图像转换为PNG格式并保存到磁盘。通过获取PNG编码器的CLSID,实现图像格式的转换。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本文来自msdn,方便以后查询!当然闲来无事,看看是有益处的......

 

To save an image to a disk file, call the Save method of the Image class. The following console application loads a BMP image from a disk file, converts the image to the PNG format, and saves the converted image to a new disk file. The main function relies on the helper function GetEncoderClsid, which is shown in Retrieving the Class Identifier for an Encoder.

 

另外,检索编码器clsid的函数GetEncoderClsid在msdn的链接 Retrieving the Class Identifier for an Encoder为:

http://msdn.microsoft.com/en-us/library/ms533843(VS.85).aspx

 

分析以上代码可知,GetEncoderClsid(L"image/png", &encoderClsid)根据MIME类型“image/png”得到png格式编码器的clsid,这样在调用save方法保存image时,就会按照clsid指定的png编码格式将image编码为Bird.png文件保存在硬盘。因此编码器的clsid(encodeClsid)在这里起着很重要的作用,sava为何种格式完全依靠它!!!

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值