Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi TImageList.AddMasked (https://www.delphipraxis.net/170293-timagelist-addmasked.html)

Andreas Leix 10. Sep 2012 09:30

TImageList.AddMasked
 
Hallo !

Bin gerade dabei ein Projekt von Delphi 2009 auf DelphiXE2 zu bringen.
Bin nun auf ein Problem mit TImageList gestoßen.
Ich übertrage einzelne Bitmaps zur Laufzeit von einer Image-list auf eine andere.
Das funktioniert unter Delphi 2009 einwandfrei:

Code:
function Uebertrage ( Source,Target: TImageList; SourceIndex: integer ): integer;
{ Image3: TImage ist auch noch deklariert und initialisiert}
begin
  Source.GetBitmap(sourceIndex, Image3.Picture.Bitmap );
  Image3.Picture.Bitmap.TransparentMode := tmAuto;
  Image3.Picture.Bitmap.TransparentColor:= clFuchsia;
  // zur kontrolle eingebaut: Image3.Picture.SaveToFile('D:\temp\bild'+inttoStr(sourceindex)+'.bmp');
  Result:= Target.AddMasked(Image3.Picture.Bitmap,clFuchsia );  
end;
Unter DelphiXE2 schauen die übertragenen Bitmaps in Target-ImageList aus, alsob nur die Maske übertragen worden wäre.

Kennt jemand Probleme mit TImageList.AddMasked unter XE2,
oder hat jemand Hinweise zu Änderungern bei TImageList in XE2 ?

Vielen Dank für jeden Hinweis !

Bummi 10. Sep 2012 09:51

AW: TImageList.AddMasked
 
ist im Quellbild clFuchsia noch auf [0,Height-1] vorhanden?
Gegf. kommt die Methode für Dich in Frage?
Delphi-Quellcode:
function Uebertrage ( Source,Target: TImageList; SourceIndex: integer ): integer;
var
 ico:TIcon;
begin
  ico :=TIcon.Create;
  try
  Source.GetIcon(sourceIndex, Ico );
  Result:= Target.AddIcon(Ico);
  Showmessage(IntToStr(Result));
  finally
    ico.Free;
  end;
end;
Zugriff auf das Bitmap besteht trotzdem
Delphi-Quellcode:
procedure TForm6.Button1Click(Sender: TObject);
var
 bmp:TBitmap;
begin
    Uebertrage(Imagelist1,Imagelist2,0);
    bmp:=TBitmap.Create;
    try
      Imagelist2.GetBitmap(0,bmp);
      Canvas.Draw(0,0,bmp);
    finally
      bmp.Free;
    end;
    action1.ImageIndex :=0;
end;

Andreas Leix 10. Sep 2012 10:29

AW: TImageList.AddMasked
 
Hi Bummi !

Die Vorhgehensweise mit GetIcon / AddIcon funktioniert !!!!
Vielen vielen Dank für Deine Antwort !!
Grüße Andreas


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:23 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz