[Lazarus] Read image from resources with TLazIntfImage

Valdas Jankūnas skroblas at erdves.lt
Mon Apr 28 14:58:37 CEST 2008

Marc Weustink rašė:
> Valdas Jankūnas wrote:
>> Hello,
>>   how i can read PNG image from Lazarus resources using TLazIntfImage?
>> I tried TPortableNetworkGraphic to read transparent PNG from resource
>> or file, but in transparent areas of saved PNG image i get random
>> garbage.Code:
>>     img:=TPortableNetworkGraphic.Create;
>  >     img.LoadFromFile(FAILAS_OUT);
>  >     img.SaveToFile(FAILAS_IN);
>  >     img.Free;
>> This code is correct? If so i report bug to bugtracker.
> When you only loading, the stream loaded from is internally stored, so 
> when you only save this stream is saved. It should result in an exact 
> copy of your source.
> However if you modify something, then it depends on the widgetset (since 
> it gets converted to a bitmaphandle first). On Gtk1 or Gtk2 this will 
> replace your 8bit alpha channel with a 1 bit channel.
>> If i doing same test (with file) using TLazIntfImage with
>> TFPCustomImageReader and TFPCustomImageWriter, then i get correct
>> results, but i not know how using TLazIntfImage load image from
>> resource.
> See TCustomBitmap loadfromlazarusresource code.
> I think somehow after the image is loaded, TPortableNetworkGraphic 
> thinks something is changed and the original stream isn't saved.

  Thanks for info.

   Valdas Jankūnas

More information about the Lazarus mailing list