使用Delphi XE在运行时添加png图像到图像列表 [英] Add a png image to a imagelist in runtime using Delphi XE

查看:1343
本文介绍了使用Delphi XE在运行时添加png图像到图像列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在运行时添加一个png图像到一个 TImageList 。我查看了 TCustomImageList 实现的功能,但只允许添加

I need add in runtime a png image to a TImageList. I've looked at the functions implemented by the TCustomImageList but they only allow adding


  • bitmaps,
  • icons or
  • images from another imagelist

例如:

function Add(Image, Mask: TBitmap): Integer;
function AddIcon(Image: TIcon): Integer;
function AddImage(Value: TCustomImageList; Index: Integer): Integer;
procedure AddImages(Value: TCustomImageList);
function AddMasked(Image: TBitmap; MaskColor: TColor): Integer;

如何将PNG图像添加到ImageList组件而不将此图像转换为BMP?

How I can add a PNG image to a ImageList component without converting this image to BMP?

IDE已经可以在设计时添加一个PNG到ImageList:

The IDE already can add a PNG to an ImageList at design time:

现在我们需要在运行时执行。

Now we need to do it at runtime.

推荐答案

p>根据MSDN,imagelist只能包含位图和图标。要将png图像添加到图像列表中,必须先将其转换为图标。要执行此操作的代码可以在 PngComponents 软件包中找到。如果您的图像列表中只有PNG图像,您可以简单地使用该包附带的TPngImageList。

According to MSDN an imagelist can only contain bitmaps and icons. To add a png image to an imagelist you have to convert it to an icon first. The code to do that can be found in the PngComponents package. If you have only PNG images in your imagelist you can for simplicity just use TPngImageList that comes with that package.

这篇关于使用Delphi XE在运行时添加png图像到图像列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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