Recent

Author Topic: fcl-image and TImage  (Read 718 times)

adderthorn

  • New Member
  • *
  • Posts: 19
fcl-image and TImage
« on: February 25, 2023, 05:42:29 pm »
I am working with a library that creates bitmaps using the fcl-image classes, I am trying to integrate this into a GUI application and display these bitmaps, I can't seem to find a way to do this. I've tried doing this with a stream, but it fails on me. Any thoughts?

Code: Pascal  [Select][+][-]
  1. ABitmap:=LIBRARYCLASS.ToBitmapImage(1, 1);
  2. Writer:=TFPWriterBMP.Create;
  3. AStream:=TMemoryStream.Create;
  4. ABitmap.SaveToStream(AStream, Writer);
  5. Image1.Picture.Bitmap.LoadFromStream(AStream, 1);

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: fcl-image and TImage
« Reply #1 on: February 25, 2023, 05:50:11 pm »
Assuming that line 1 in your example is correct, then you simply can assign ABitmap to Image1.Picture:
Code: Pascal  [Select][+][-]
  1. Image1.Picture.Assign(ABitmap);

Your code with the stream should work, too. But you must be aware that the stream.Position is at the end after ABitmap.SaveToStream; therefore, there's nothing to read for Image1.Picture.Bitmap.LoadFromStream. Rewinding the stream should help:
Code: Pascal  [Select][+][-]
  1. ...
  2. ABitmap.SaveToStream(AStream, Writer);
  3. AStream.Position := 0;
  4. Image1.Picture.Bitmap.LoadFromStream(AStream, 1);

adderthorn

  • New Member
  • *
  • Posts: 19
Re: fcl-image and TImage
« Reply #2 on: February 25, 2023, 06:21:04 pm »
Thank-you! This was what I needed. Still having an issue (now getting Invalid palette index 0), but I think this is the library I'm using, so I'm doing some more debugging.

 

TinyPortal © 2005-2018