diff options
-rw-r--r-- | src/c_fl_bitmap.cpp | 20 | ||||
-rw-r--r-- | src/c_fl_bitmap.h | 16 | ||||
-rw-r--r-- | src/fltk-images-bitmaps.adb | 71 | ||||
-rw-r--r-- | src/fltk-images-bitmaps.ads | 31 |
4 files changed, 138 insertions, 0 deletions
diff --git a/src/c_fl_bitmap.cpp b/src/c_fl_bitmap.cpp new file mode 100644 index 0000000..2481062 --- /dev/null +++ b/src/c_fl_bitmap.cpp @@ -0,0 +1,20 @@ + + +#include <FL/Fl_Bitmap.H> +#include "c_fl_bitmap.h" + + +void free_fl_bitmap(BITMAP b) { + delete reinterpret_cast<Fl_Bitmap*>(b); +} + + +BITMAP fl_bitmap_copy(BITMAP b, int w, int h) { + return reinterpret_cast<Fl_Bitmap*>(b)->copy(w, h); +} + + +BITMAP fl_bitmap_copy2(BITMAP b) { + return reinterpret_cast<Fl_Bitmap*>(b)->copy(); +} + diff --git a/src/c_fl_bitmap.h b/src/c_fl_bitmap.h new file mode 100644 index 0000000..e132347 --- /dev/null +++ b/src/c_fl_bitmap.h @@ -0,0 +1,16 @@ + + +#ifndef FL_BITMAP_GUARD +#define FL_BITMAP_GUARD + + +typedef void* BITMAP; + + +extern "C" void free_fl_bitmap(BITMAP b); +extern "C" BITMAP fl_bitmap_copy(BITMAP b, int w, int h); +extern "C" BITMAP fl_bitmap_copy2(BITMAP b); + + +#endif + diff --git a/src/fltk-images-bitmaps.adb b/src/fltk-images-bitmaps.adb new file mode 100644 index 0000000..280d327 --- /dev/null +++ b/src/fltk-images-bitmaps.adb @@ -0,0 +1,71 @@ + + +with Interfaces.C; +with System; +use type System.Address; + + +package body FLTK.Images.Bitmaps is + + + procedure free_fl_bitmap + (I : in System.Address); + pragma Import (C, free_fl_bitmap, "free_fl_bitmap"); + + function fl_bitmap_copy + (I : in System.Address; + W, H : in Interfaces.C.int) + return System.Address; + pragma Import (C, fl_bitmap_copy, "fl_bitmap_copy"); + + function fl_bitmap_copy2 + (I : in System.Address) + return System.Address; + pragma Import (C, fl_bitmap_copy2, "fl_bitmap_copy2"); + + + + + overriding procedure Finalize + (This : in out Bitmap) is + begin + if This.Void_Ptr /= System.Null_Address and then + This in Bitmap'Class + then + free_fl_bitmap (This.Void_Ptr); + This.Void_Ptr := System.Null_Address; + end if; + Finalize (Image (This)); + end Finalize; + + + + + function Copy + (This : in Bitmap; + Width, Height : in Natural) + return Bitmap is + begin + return Copied : Bitmap do + Copied.Void_Ptr := fl_bitmap_copy + (This.Void_Ptr, + Interfaces.C.int (Width), + Interfaces.C.int (Height)); + end return; + end Copy; + + + + + function Copy + (This : in Bitmap) + return Bitmap is + begin + return Copied : Bitmap do + Copied.Void_Ptr := fl_bitmap_copy2 (This.Void_Ptr); + end return; + end Copy; + + +end FLTK.Images.Bitmaps; + diff --git a/src/fltk-images-bitmaps.ads b/src/fltk-images-bitmaps.ads new file mode 100644 index 0000000..d209b4a --- /dev/null +++ b/src/fltk-images-bitmaps.ads @@ -0,0 +1,31 @@ + + +package FLTK.Images.Bitmaps is + + + type Bitmap is new Image with private; + + + function Copy + (This : in Bitmap; + Width, Height : in Natural) + return Bitmap; + + + function Copy + (This : in Bitmap) + return Bitmap; + + +private + + + type Bitmap is new Image with null record; + + + overriding procedure Finalize + (This : in out Bitmap); + + +end FLTK.Images.Bitmaps; + |