我想從TImageList
加載一張圖片(32位深度,透明)到TImage
。標準方法是ImageList.GetBitmap(Index, Image.Picture.Bitmap);
。但是GetBitmap
方法不適用於透明度,所以我總是得到一個不透明的位圖。如何從ImageList加載透明圖像?
6
A
回答
23
解決方法非常簡單 - ImageList提供了另一種方法,GetIcon
,該方法在透明度下工作正常。代碼加載一個透明的形象將是:
ImageList.GetIcon(Index, Image.Picture.Icon);
而且不要忘記設置正確的ImageList屬性:
ImageList.ColorDepth:=cd32bit;
ImageList.DrawingStyle:=dsTransparent;
2
我也有各種問題,在圖像通過從一個的TImageList。所以我有一個簡單的包裝例程,通常可以完成這項工作,並且它會強制執行透明度。下面的代碼是Delphi 2005,imlActiveView是帶有我的按鈕字形圖像集的tImageList組件。
procedure TfrmForm.LoadBitmap (Number : integer; bmp : tBitMap);
var
ActiveBitmap : TBitMap;
begin
ActiveBitmap := TBitMap.Create;
try
imlActiveView.GetBitmap (Number, ActiveBitmap);
bmp.Transparent := true;
bmp.Height := ActiveBitmap.Height;
bmp.Width := ActiveBitmap.Width;
bmp.Canvas.Draw (0, 0, ActiveBitmap);
finally
ActiveBitmap.Free;
end
end;
這裏是第5個imlActiveView圖像傳遞到btnNavigate.Glyph的使用示例。
LoadBitmap (5, btnNavigate.Glyph)
相關問題
- 1. 如何在ImageList中使用半透明圖像
- 2. jquery BlockUI - 透明加載圖像
- 3. 如何在運行時加載48x48 .ico進入imagelist和保存透明度
- 4. 透明圖像搞亂透明圖像
- 5. Monogame和XNA - 如何加載/使用半透明圖像?
- 6. 透明圖像
- 7. 試圖添加背景圖像透明度不透明
- 8. 如何從較小的組件圖像構建C#ImageList圖像?
- 9. 如何從現有圖像創建透明背景圖像?
- 10. 如何從透明圖像創建圖像損壞顏色?
- 11. 從圖像中讀取透明像素
- 12. 爲位圖圖像添加透明度
- 13. 將透明圖層添加到圖像
- 14. Hotmail(PHP)下載的透明圖像
- 15. 在FreeImage下載透明圖像
- 16. 透明dijit.Dialog爲裝載機圖像
- 17. 透明背景透明圖像問題
- 18. 透明圖像在IE中不透明
- 19. 非透明圖像
- 20. android圖像透明
- 21. 非透明圖像
- 22. 僞透明圖像
- 23. CSS圖像透明
- 24. 如何使用透明圖像作爲透明winform的背景?
- 25. 將圖像從不透明變爲半透明(並保持半透明狀態)
- 26. 如何讓我的圖像透明?
- 27. 如何使UIBarButtonItem圖像透明?
- 28. 如何透明刪除圖像陰影
- 29. 如何使圖像透明android
- 30. 如何在透明圖像上滾動?
像['RRUZ suggested'(http://stackoverflow.com/questions/10972986/png-image-from-imagelist#comment14330479_10973026)前一段時間... – TLama 2012-07-22 12:03:33