From a41dedec645a0894d9173e5de0b502f727572f62 Mon Sep 17 00:00:00 2001 From: Jedidiah Barber <contact@jedbarber.id.au> Date: Wed, 9 Apr 2025 23:54:13 +1200 Subject: Fixed RGB_Image size_t issue, RGB_Image/Bitmap preconditions --- body/fltk-images-bitmaps.adb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'body/fltk-images-bitmaps.adb') diff --git a/body/fltk-images-bitmaps.adb b/body/fltk-images-bitmaps.adb index cfb63d7..4597151 100644 --- a/body/fltk-images-bitmaps.adb +++ b/body/fltk-images-bitmaps.adb @@ -118,7 +118,9 @@ package body FLTK.Images.Bitmaps is begin return This : Bitmap do This.Void_Ptr := new_fl_bitmap - (Storage.To_Integer (Data (Data'First)'Address), + ((if Data'Length > 0 + then Storage.To_Integer (Data (Data'First)'Address) + else Null_Pointer), Interfaces.C.int (Width), Interfaces.C.int (Height)); end return; @@ -135,13 +137,13 @@ package body FLTK.Images.Bitmaps is -- Contracts -- - function To_Next_Byte + function Bytes_Needed (Bits : in Natural) return Natural is begin - return Integer (Float'Ceiling (Float (Bits) / Float (Color_Component_Array'Component_Size))) - * Color_Component_Array'Component_Size; - end To_Next_Byte; + return Integer (Float'Ceiling + (Float (Bits) / Float (Color_Component_Array'Component_Size))); + end Bytes_Needed; @@ -191,7 +193,7 @@ package body FLTK.Images.Bitmaps is (This : in Bitmap) return Natural is begin - return To_Next_Byte (This.Get_W) * This.Get_H; + return Bytes_Needed (This.Get_W) * This.Get_H; end Data_Size; -- cgit