Registriert seit: 18. Mär 2005
1.682 Beiträge
Delphi 2006 Enterprise
|
Re: GDI+ & LoadFromResource Marke Eigenbau machts nicht
11. Nov 2007, 10:08
Hallo,
ich verwende da immer den Umweg über einen TMemoryStream:
Delphi-Quellcode:
function LoadFromResource(const AResName: WideString;
AInstance: LongWord): TMemoryStream;
var
HR,
HRI,
ResSize: Cardinal;
Stream: TMemoryStream;
begin
Stream := nil;
HRI := FindResourceW(AInstance, PWideChar(AResName), PWideChar(RT_RCDATA));
if HRI <> 0 then
begin
HR := LoadResource(AInstance, HRI);
if HR <> 0 then
begin
ResSize := SizeOfResource(AInstance, HRI);
Stream := TMemoryStream.Create;
Stream.Write(LockResource(HR)^, ResSize);
Stream.Position := 0;
end;
end;
Result := Stream;
end;
function LoadImageFromResource(const AResName: WideString;
AInstance: LongWord): TGPImage;
var
Image: TGPimage;
Stream: TMemoryStream;
SA: TStreamAdapter;
begin
Image := nil;
Stream := LoadFromResource(AResName, AInstance);
if Assigned(Stream) then
begin
SA := TStreamAdapter.Create(Stream, soOwned);
Image := TGPImage.Create(SA);
end;
Result := Image;
end;
Gruß
xaromz
I am a leaf on the wind - watch how I soar
|
|
Zitat
|