Recent

Author Topic: Division by zero using TRawImage Init_BPP24_R8G8B8_BIO_TTB on linux 64  (Read 337 times)

jcbritobr

  • New Member
  • *
  • Posts: 13
Hello, good afternoon. Im reading about TLazIntfImage and Im working with this object on linux 64. I perceived that using Init_BPP24_R8G8B8_BIO_TTB in code below leads to division by zero error. Cant understand why 32 bit images are working, and 24 bit the issue happens. May someone help?

Code: Pascal  [Select][+][-]
  1. var
  2.   AImage: TLazIntfImage;
  3.   lRawImage: TRawImage;
  4. begin
  5.   lRawImage.Init;
  6.   lRawImage.Description.Init_BPP32_A8R8G8B8_BIO_TTB(100, 100);
  7.   lRawImage.CreateData(False);
  8.   AImage := TLazIntfImage.Create(0, 0);
  9.   try
  10.     //AImage.DataDescription := GetDescriptionFromDevice(0);
  11.     //AImage.SetSize(0, 0);
  12.     AImage.SetRawImage(lRawImage);
  13.     try
  14.       ImgMain.Picture.Bitmap.LoadFromIntfImage(AImage); // ---division by zero here when using 24bpp image---
  15.     except
  16.       on E: Exception do
  17.         ShowMessage('An exception was raised: ' + E.Message);
  18.     end;
  19.   finally
  20.     AImage.Free;
  21.   end;  

dje

  • Full Member
  • ***
  • Posts: 111
Re: Division by zero using TRawImage Init_BPP24_R8G8B8_BIO_TTB on linux 64
« Reply #1 on: August 17, 2022, 04:04:20 pm »
You may need to do some tracing at your end.

TBitmap is derived from TRasterImage.
TRasterImage.LoadFromIntfImage(IntfImage: TLazIntfImage) calls IntfImage.CreateBitmaps()
IntfImage.CreateBitmaps calls RawImage_CreateBitmaps for the platform widget set.

I'm using Gtk, so when I searched the LCL source for RawImage_CreateBitmaps, I can find the implementations for GTk.
I can see a number of comments like:
Code: Pascal  [Select][+][-]
  1. // check if the depth is supported  
  2. // try some alternative (I'm not sure if we should fail here instead)
  3. // if we don't have a visual we cannot draw anyway      
  4. // this is only a rough implementation, there is no check against bitsperpixel  
  5. // The gdk_pixmap_create_from_data creates only a two-color pixmap so we can not use it
  6. // this is only a rough implementation, there is no check against bitsperpixel

The point being, my system throws a 'Failed to create handles'. Which means, the pixel format was identified as "not supported", and failed correctly. I checked a couple of the 24bit pixel formats, and they all failed. This is the ideal result.

I didn't get a divide by zero, so I'm guessing, whatever setup you have, is passing though a safety check and hitting a div/divmod command.

Either way, it looks like 24bit rawimages have little to no bitmap handle support. (Most likely because its not possible)
« Last Edit: August 17, 2022, 04:08:23 pm by derek.john.evans »

jcbritobr

  • New Member
  • *
  • Posts: 13
Re: Division by zero using TRawImage Init_BPP24_R8G8B8_BIO_TTB on linux 64
« Reply #2 on: August 22, 2022, 09:55:25 pm »
Hello. Thank you. I really apreciate your answer.
In my environment, that is linux 64, and also using gtk I got division by zero from a unit. I had read the comments but none about no support for 24pp. I think its a bad error handling. Maybe an exception with "Not supported" text gets better.

 

TinyPortal © 2005-2018