Wenn Du am Umstellen bist wirst Du früher oder später bei einem Problem aufschlagen, welches mich seinerzeit Nerven gekostet hat. TGPImage aus TGraphic's zu bekommen.
Delphi-Quellcode:
//2010 by Thomas Wassermann
// Halten von Grafiken in Stream zur Verwendung als TGPImage
TGPImageWrapper=Class(TObject)
private
FImage: TGPImage;
FStream: TMemoryStream;
public
Constructor Create(FileName:
String);
overload;
Constructor Create(AGraphic:TGraphic);
overload;
Destructor Destroy;
override;
Public
Property Image:TGPImage
read FImage;
end;
constructor TGPImageWrapper.Create(AGraphic: TGraphic);
begin
inherited Create;
FStream := TMemoryStream.Create;
AGraphic.SaveToStream(FStream);
Fimage:= TGPImage.Create(TStreamAdapter.Create(FStream));
end;
constructor TGPImageWrapper.Create(FileName:
String);
begin
inherited Create;
Fimage:= TGPImage.Create(FileName);
end;
destructor TGPImageWrapper.Destroy;
begin
FImage.Free;
FStream.Free;
inherited;
end;
// Verwendung on TGPImages aus einer Imagelist (z.B. 32-Bit, PNG's transparent)
procedure CreateGPList(
il:TDragImageList;
var ol:TObjectList<TGPImageWrapper>);
var
i:Integer;
ico:TIcon;
begin
ol := TObjectList<TGPImageWrapper>.Create;
ol.OwnsObjects := true;
for I := 0
to il.Count - 1
do
begin
ico:=TIcon.Create;
try
IL.GetIcon(i,ico);
ol.Add(TGPImageWrapper.Create(ico));
finally
ico.Free;
end;
end;
end