- 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函数是不是作了什么手脚。