Recent

Author Topic: FCL Image SIGSEGV Raised on run  (Read 7702 times)

BeanzMaster

  • Sr. Member
  • ****
  • Posts: 268
Re: FCL Image SIGSEGV Raised on run
« Reply #15 on: June 30, 2018, 03:02:44 pm »
I have the feeling that something is missing here. You are working with a simple TFPMemoryImage.
Loading bitmap is independant of the device display, it must be work. I must can load data information in a  TFPMemoryImage for working with it. Bitmaps are only a series of bytes that are grouped by 1, 3, 4 bytes or more depending on the color mode (1, 2, 4, 8, 16, 24, 32, 64, 128 bits) and sorted following the type (WB, BGR, GRBA, ABGR, ARGB, ect....)

Does it do all the required adaptions to the device format? Lazarus introduced TLazIntfImage for this purpose. There is an example in the wiki:
http://wiki.freepascal.org/Developing_with_Graphics#Working_with_TLazIntfImage.2C_TRawImage_and_TLazCanvas. This is similar to what the LCL is doing when reading an image. And the LCL can read all your test bmp images without any problems (I reported above that the bmp*.bmp images cannot be read - this is not true, I just did not see them due to their small size; with the gifs there are some issues, though).

If i just want use FCL in an application console (suppose i don't use Lazarus and LCL), how i can do  ? LCL is not FCL. they are two differents things.

For information LCL override the BMP loading so this why you can load and see Lena-2.bmp
The LCL graphic solution also have many "bugs" . Many thing are not manage correctly thrue TRawImage/ TRawImageDescription (many times is not fill correctly, like the pixelformat or the color masks) I take a look many times in code before began my project and this is the why.

You can take a look in this topic (it's in french, but just see screenshot is enougth for make a comparation)  see here : https://www.developpez.net/forums/d1699554/autres-langages/pascal/lazarus/fichier-bmp-encodage-bitfield/
This discussion was when i began to decode Bmp and i've made some comparating tests with TBitmap (all bmp are in the imagetestsuite if you want make some test to with TRawImageDescription)

TLazIntfImage is a good  for manipulating bitmap instead of use TRawImage/TBitmap, ( see bug in TGIFViewer and transparency with Linux) but not an easy way sometimes and it was not very optimized for speed. I see TLazIntfImage as a bridge with the LCL and that's it.

Indeed the best way to load a bitmap with TLazIntfImage (so also for TBitmap) (only BMP, XPM, PNG and TIFF)
This sample come from the IntfGraphics unit
Code: Pascal  [Select][+][-]
  1.       var
  2.         BmpHnd,MaskHnd: HBitmap;
  3.         Bitmap1: TBitmap;
  4.         IntfImg1: TLazIntfImage;
  5.         Reader: TLazReaderBMP;
  6.       begin
  7.         // create a bitmap (or use an existing one)
  8.         Bitmap1:=TBitmap.Create;
  9.         // create the raw image for the screenformat you want
  10.         IntfImg1:=TLazIntfImage.Create(0,0,[riqfRGB, riqfAlpha, riqfMask]);
  11.         // create the XPM reader
  12.         Reader:=TLazReaderXPM.Create;
  13.         // load the image
  14.         IntfImg1.LoadFromFile('filename.xpm',Reader);
  15.         // create the bitmap handles
  16.  
  17.         // do something with the IntfImg1
  18.  
  19.         IntfImg1.CreateBitmap(BmpHnd,MaskHnd);
  20.         // apply handles to the Bitmap1
  21.         Bitmap1.Handle:=BmpHnd;
  22.         Bitmap1.MaskHandle:=MaskHnd;
  23.         // clean up
  24.         Reader.Free;
  25.         IntfImg1.Free;
  26.  
  27.         // do something with the Bitmap1
  28.       end;

Like you can see FPReadBMP is overrided by TLazReaderBMP but is not complete and also have some things wrong with the support of BMP formats.

Cheers


 

 

TinyPortal © 2005-2018