diff options
author | Jedidiah Barber <contact@jedbarber.id.au> | 2025-01-21 21:04:54 +1300 |
---|---|---|
committer | Jedidiah Barber <contact@jedbarber.id.au> | 2025-01-21 21:04:54 +1300 |
commit | b4438b2fbe895694be98e6e8426103deefc51448 (patch) | |
tree | 760d86cd7c06420a91dad102cc9546aee73146fc /body/fltk-images-rgb-bmp.adb | |
parent | a4703a65b015140cd4a7a985db66264875ade734 (diff) |
Split public API and private implementation files into different directories
Diffstat (limited to 'body/fltk-images-rgb-bmp.adb')
-rw-r--r-- | body/fltk-images-rgb-bmp.adb | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/body/fltk-images-rgb-bmp.adb b/body/fltk-images-rgb-bmp.adb new file mode 100644 index 0000000..01669eb --- /dev/null +++ b/body/fltk-images-rgb-bmp.adb @@ -0,0 +1,67 @@ + + +-- Programmed by Jedidiah Barber +-- Released into the public domain + + +with + + Interfaces.C; + + +package body FLTK.Images.RGB.BMP is + + + function new_fl_bmp_image + (F : in Interfaces.C.char_array) + return Storage.Integer_Address; + pragma Import (C, new_fl_bmp_image, "new_fl_bmp_image"); + pragma Inline (new_fl_bmp_image); + + procedure free_fl_bmp_image + (P : in Storage.Integer_Address); + pragma Import (C, free_fl_bmp_image, "free_fl_bmp_image"); + pragma Inline (free_fl_bmp_image); + + + + + overriding procedure Finalize + (This : in out BMP_Image) is + begin + if This.Void_Ptr /= Null_Pointer and This.Needs_Dealloc then + free_fl_bmp_image (This.Void_Ptr); + This.Void_Ptr := Null_Pointer; + end if; + end Finalize; + + + + + -------------------- + -- Construction -- + -------------------- + + package body Forge is + + function Create + (Filename : in String) + return BMP_Image is + begin + return This : BMP_Image do + This.Void_Ptr := new_fl_bmp_image + (Interfaces.C.To_C (Filename)); + case fl_image_fail (This.Void_Ptr) is + when 1 => raise No_Image_Error; + when 2 => raise File_Access_Error; + when 3 => raise Format_Error; + when others => null; + end case; + end return; + end Create; + + end Forge; + + +end FLTK.Images.RGB.BMP; + |