Forum > Graphics

Division by zero using TRawImage Init_BPP24_R8G8B8_BIO_TTB on linux 64

(1/1)

jcbritobr:
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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var  AImage: TLazIntfImage;  lRawImage: TRawImage;begin  lRawImage.Init;  lRawImage.Description.Init_BPP32_A8R8G8B8_BIO_TTB(100, 100);  lRawImage.CreateData(False);  AImage := TLazIntfImage.Create(0, 0);  try    //AImage.DataDescription := GetDescriptionFromDevice(0);    //AImage.SetSize(0, 0);    AImage.SetRawImage(lRawImage);    try      ImgMain.Picture.Bitmap.LoadFromIntfImage(AImage); // ---division by zero here when using 24bpp image---    except      on E: Exception do        ShowMessage('An exception was raised: ' + E.Message);    end;  finally    AImage.Free;  end;  

dje:
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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---// check if the depth is supported  // try some alternative (I'm not sure if we should fail here instead)// if we don't have a visual we cannot draw anyway      // this is only a rough implementation, there is no check against bitsperpixel   // The gdk_pixmap_create_from_data creates only a two-color pixmap so we can not use it// 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)

jcbritobr:
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.

Navigation

[0] Message Index

Go to full version