10

TImageList画像 (32 ビット深度、透明) を からにロードしたいTImage。標準的なアプローチはImageList.GetBitmap(Index, Image.Picture.Bitmap);. ただし、このGetBitmap方法は透明度では機能しないため、常に不透明なビットマップを取得します。

4

2 に答える 2

34

回避策はかなり単純です。ImageList は別のメソッドを提供しますGetIcon。透明な画像をロードするコードは次のようになります。

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

そして、適切な ImageList プロパティを設定することを忘れないでください:

ImageList.ColorDepth:=cd32bit;
ImageList.DrawingStyle:=dsTransparent;
于 2012-07-22T11:50:05.093 に答える
3

私も、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)
于 2014-01-08T20:56:40.967 に答える