Recent

Author Topic: Issues with BGRAControls/BGRABitmap and TImage  (Read 782 times)

wp

  • Hero Member
  • *****
  • Posts: 12523
Issues with BGRAControls/BGRABitmap and TImage
« on: January 06, 2024, 03:53:11 pm »
I don't use BGRAControls, but I had once installed them to test something, and after completing this test, I did not uninstall the package and forgot about it. This is not good - it took me several hours to fix my system again.

Yesterday I created a little test project with a TImage component, and I loaded one of the Lazarus general-purpose images (a png) into the component at designtime. Everything looked fine in the object inspector, but when I ran the project the image was empty.

I took me quite a while until I found out that this is caused by BGRABitmap/BGRAControls. The root-cause is at the beginning of the hex-encoded image data block in the lfm file - see red rectangle in attached screenshot. During streaming TPicture first writes the name of the graphic class which can read/write the following data, in case of a 'png' image, normally 'TPortableNetworkGraphic' (the name is preceded by the string length). The characters of this string (as well as the image data) are base-16 hex-encoded, i.e. each byte is shown by two hex characters: 'A', for example, has hex value $41, and thus its string representation is '41'.

Decoding the first line of the screenshot surprisingly yields the class name 'TBGRAAnimatedGif'. This explains why there is no image a runtime - without mentioning in the uses clause the unit which is able to read this format the LCL has no way to display the image. At designtime, however, the image can be displayed because the BGRAControls/TBGRABitmap seem to register their readers/writers in the IDE.

Searching the sources for "TBGRAAnimatedGif" I found out that this format is implemented and registered in unit BGRAAnimatedGif, and adding this unit to the uses clause of my test project finally made the image appear at runtime. I would never have thought that I must add a unit of an unused package to my project to fix this...

Don't know whether BGRABitmap or BGRAControls are the main pulprit for this issue. At least, when I uninstall BGRAControls the issue does no longer happen...

I had submitted a similar issue with TImage and non-LCL image format reader/writers to bugtracker yesterday (https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40685), but the BGRAControls issue is different. I have no idea how it could be fixed...

paweld

  • Hero Member
  • *****
  • Posts: 1278
Re: Issues with BGRAControls/BGRABitmap and TImage
« Reply #1 on: January 06, 2024, 04:49:45 pm »
@wp: update BGRABitmap to the latest version, as version 11.5.7 had a bug that caused, among other things, the case you describe, more info: https://github.com/bgrabitmap/bgrabitmap/issues/224
Best regards / Pozdrawiam
paweld

wp

  • Hero Member
  • *****
  • Posts: 12523
Re: Issues with BGRAControls/BGRABitmap and TImage
« Reply #2 on: January 06, 2024, 05:21:18 pm »
You are right. After updating the issue is gone. Thanks for the hint.

 

TinyPortal © 2005-2018