如何从ImageList加载透明图像? [英] How to load a transparent Image from ImageList?

查看:184
本文介绍了如何从ImageList加载透明图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从TImageListTImage加载图片(32位深度,透明).标准方法是ImageList.GetBitmap(Index, Image.Picture.Bitmap);.但是GetBitmap方法不适用于透明度,因此我总是得到一个不透明的位图.

I want to load a picture (32 bit-depth, transparent) from a TImageList to an TImage. The standard approach would be ImageList.GetBitmap(Index, Image.Picture.Bitmap);. However the GetBitmap method doesn't work with transparency, so I always get a non-transparent bitmap.

推荐答案

解决方法非常简单-ImageList提供了另一种方法GetIcon,该方法可以透明地工作.加载透明图像的代码为:

The workaround is rather simple - ImageList offers another method, GetIcon, which works OK with transparency. Code to load a transparent Image would be:

ImageList.GetIcon(Index, Image.Picture.Icon);

不要忘记设置适当的ImageList属性:

And don't forget to set proper ImageList properties:

ImageList.ColorDepth:=cd32bit;
ImageList.DrawingStyle:=dsTransparent;

这篇关于如何从ImageList加载透明图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆