简体   繁体   English

如何从CImageList中提取图像并将其另存为透明GIF文件

[英]How to extract images from a CImageList and save them as transparent GIF files

I want to extract images from a CImageList and save them as transparent GIF files. 我想从CImageList中提取图像并将其另存为透明GIF文件。 I'm using the following GDI+ code and the transparent area comes out black. 我正在使用以下GDI +代码,透明区域显示为黑色。

const HICON hIcon = myImageList.ExtractIcon( nImage );    
Bitmap* gdiBMP = Bitmap::FromHICON( hIcon );    
CLSID   encoderClsid;    
GetEncoderClsid( T2W( "image/gif" ), &encoderClsid );    
Status stat = gdiBMP->Save( L"myfilename.gif", &encoderClsid, NULL );    
delete gdiBMP;

I'm assuming I need to explicitly set the transparent image in the gif file. 我假设我需要在gif文件中显式设置透明图像。 Or muck with the Bitmap. 或与位图混为一谈。 I have found some .Net articles related to this, but for this specific project I'm using VC6. 我发现了一些与此有关的.Net文章,但是对于这个特定项目,我正在使用VC6。

Have Google'd to no avail. 谷歌无济于事。 Any/all suggestions most welcome. 任何/所有建议最欢迎。

Neville Franks, www.surfulater.com 内维尔·弗兰克斯(Neville Franks), www.surfulater.com

It seems this is not as easy as picking a transparent color. 似乎这不像选择透明颜色那么容易。 I found a tutorial for this here (EDIT: original link dead, link from wayback machine ). 我在 这里 找到了一个教程(编辑:原始链接已死, 回程机器的链接 )。 It's for C#, but I guess it can be ported easily. 它用于C#,但我想它可以轻松移植。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM