- Bitmap:= TBitmap.Create();
- Bitmap.TransparentMode := tmFixed; //必须在getBitmap前设置
- Bitmap.Transparent := True;
- if (ImageList.GetBitmap(SubMenu.Tag, Bitmap)) then
- begin
- Bitmap.TransparentColor := Bitmap.Canvas.Pixels[0, 0]; //必须在getBitmap后设置
- end;
如上代码,必须先设置Bitmap.TransparentMode := tmFixed; ,再GetBitmap获取图片后再设置Bitmap.TransparentColor才可以透明。GetBitmap之后再设置TransparentMode不管用。
没时间管它了,有时间和兴趣时可以看看GetBitmap调用的DoDraw函数是不是作了什么手脚。
本文介绍了在VCL(Visual Component Library)环境下如何为图标设置透明背景的方法。关键步骤包括:初始化Bitmap对象,并设置其透明模式为tmFixed;通过ImageList获取图标;最后设置透明颜色为图标左上角像素的颜色。
867

被折叠的 条评论
为什么被折叠?



