[lazarus] PNG and resource
Mattias Gaertner
nc-gaertnma at netcologne.de
Mon Nov 10 14:49:47 EST 2003
On Mon, 10 Nov 2003 00:52:36 +0100
"Darek Mazur" <darekm at emadar.com> wrote:
> Hi
>
> I've try use resources like in delphi
> I've notice that no function to load bitmap from resource (only truecolor)
> Than try PNG to store button image but in graphics.pp is bug or I can't
> understand it.
>
> class tBitmap has
> procedure ReadStream(Stream: TStream; Size: Longint); virtual;
>
> and class tPortableNetworkBitmap has
> procedure ReadStream(Stream: TStream; Size: Longint); override;
>
> but there are not conected ,
because a TPortableNetworkBitmap can load .png files, but not bmp/xpm files.
> I need load resource from different formats
Use TPicture.
Mattias
>
> I think it will be better work when we write some like this in each stage
> of inheritation
>
> procedure TBitmap.LoadFromLazarusResource(const ResName: String);
> var
> ms:TMemoryStream;
> res:TLResource;
> begin
> res:=LazarusResources.Find(ResName);
> if (res=nil) or (res.Value='') or not
> LazarusResourceTypeValid(res.ValueType)
> then begin
>
> inherited;
> ^^^^^^^^
>
>
> exit;
> end;
> ms:=TMemoryStream.Create;
> try
> ms.Write(res.Value[1],length(res.Value));
> ms.Position:=0;
> LoadFromStream(ms);
> finally
> ms.Free;
> end;
> end;
>
>
> I can work on this, but I don't know if it is the better solution
>
> darek
>
> _________________________________________________________________
> To unsubscribe: mail lazarus-request at miraclec.com with
> "unsubscribe" as the Subject
> archives at http://www.lazarus.freepascal.org/mailarchives
--
More information about the Lazarus
mailing list