gpt4 book ai didi

Delphi 组件中的 PNG 图像集合

转载 作者:行者123 更新时间:2023-12-03 15:57:47 25 4
gpt4 key购买 nike

今天我的问题是关于在组件中创建 PNG 图像的集合。我找到了一个接受 PNG 图像作为字形的按钮,但它使用由图像的四种状态组成的 PNG 图像,如下所示:

enter image description here

我已经修改了该组件以使用四个不同的图像,每个图像用于一个状态。所以,我的组件如下所示:

  ...
public
FPngImgEnabled: TPngImage;
FPngImgDisabled: TPngImage;
FPngImgDown: TPngImage;
FPngImgOver: TPngImage;
FDown: Boolean;
Constructor Create(AOwner: TComponent); override;
Destructor Destroy; override;
procedure Paint; override;
published
property PngImgEnabled: TPngImage read FPngImgEnabled write SetPngImgEnabled;
property PngImgDisabled: TPngImage read FPngImgDisabled write SetPngImgDisabled;
property PngImgDown: TPngImage read FPngImgDown write SetPngImgDown;
property PngImgOver: TPngImage read FPngImgOver write SetPngImgOver;
...

这样我就有了一个包含四个 PNG 图像的组件,然后用于 SetPng... 程序。我想知道是否有办法使用四个PNG图像的集合;像“TPNGImagesList”这样的东西可以将图像集中在一个地方。

最佳答案

我认为你需要这样的东西:

  type
TImgType = (itEnabled, itDisabled, itDown, itOver);


...
protected
procedure SetImg(Index: TImgType; Value: TPngImage);
function GetImg(Index: TImgType): TPngImage;
public
FImages: TList<TPngImage>;
FDown: Boolean;
Constructor Create(AOwner: TComponent); override;
Destructor Destroy; override;
procedure Paint; override;
published
property Image[Index:TImgType]: TPngImage read GetImg write SetImg;
property PngImgEnabled: TPngImage index itEnabled read GetImg write SetImg;
property PngImgDisabled: TPngImage index itDisabled read GetImg write SetImg;
property PngImgDown: TPngImage index itDown read GetImg write SetImg;
property PngImgOver: TPngImage index itOver read GetImg write SetImg;

...

关于Delphi 组件中的 PNG 图像集合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36007645/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com