summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/c_fl_bitmap.cpp7
-rw-r--r--src/c_fl_bitmap.h3
-rw-r--r--src/c_fl_image.cpp36
-rw-r--r--src/c_fl_image.h6
-rw-r--r--src/c_fl_rgb_image.cpp7
-rw-r--r--src/c_fl_rgb_image.h3
-rw-r--r--src/fltk-images-bitmaps.adb26
-rw-r--r--src/fltk-images-bitmaps.ads8
-rw-r--r--src/fltk-images-rgb.adb26
-rw-r--r--src/fltk-images-rgb.ads8
-rw-r--r--src/fltk-images.adb82
-rw-r--r--src/fltk-images.ads22
12 files changed, 234 insertions, 0 deletions
diff --git a/src/c_fl_bitmap.cpp b/src/c_fl_bitmap.cpp
index fe5fd99..ce1c221 100644
--- a/src/c_fl_bitmap.cpp
+++ b/src/c_fl_bitmap.cpp
@@ -16,3 +16,10 @@ BITMAP fl_bitmap_copy2(BITMAP b) {
return reinterpret_cast<Fl_Bitmap*>(b)->copy();
}
+
+
+
+void fl_bitmap_draw(BITMAP b, int x, int y, int w, int h, int cx, int cy) {
+ reinterpret_cast<Fl_Bitmap*>(b)->draw(x, y, w, h, cx, cy);
+}
+
diff --git a/src/c_fl_bitmap.h b/src/c_fl_bitmap.h
index 3a0aa64..3caab69 100644
--- a/src/c_fl_bitmap.h
+++ b/src/c_fl_bitmap.h
@@ -16,5 +16,8 @@ extern "C" BITMAP fl_bitmap_copy(BITMAP b, int w, int h);
extern "C" BITMAP fl_bitmap_copy2(BITMAP b);
+extern "C" void fl_bitmap_draw(BITMAP b, int x, int y, int w, int h, int cx, int cy);
+
+
#endif
diff --git a/src/c_fl_image.cpp b/src/c_fl_image.cpp
index 3323c25..f3daf7f 100644
--- a/src/c_fl_image.cpp
+++ b/src/c_fl_image.cpp
@@ -6,6 +6,14 @@
+class My_Image : public Fl_Image {
+ public:
+ friend void fl_image_draw_empty(IMAGE i, int x, int y);
+};
+
+
+
+
IMAGE new_fl_image(int w, int h, int d) {
Fl_Image *i = new Fl_Image(w, h, d);
return i;
@@ -41,6 +49,19 @@ void fl_image_inactive(IMAGE i) {
reinterpret_cast<Fl_Image*>(i)->inactive();
}
+int fl_image_fail(IMAGE i) {
+ switch (reinterpret_cast<Fl_Image*>(i)->fail()) {
+ case Fl_Image::ERR_NO_IMAGE:
+ return 1;
+ case Fl_Image::ERR_FILE_ACCESS:
+ return 2;
+ case Fl_Image::ERR_FORMAT:
+ return 3;
+ default:
+ return 0;
+ }
+}
+
@@ -56,3 +77,18 @@ int fl_image_d(IMAGE i) {
return reinterpret_cast<Fl_Image*>(i)->d();
}
+
+
+
+void fl_image_draw(IMAGE i, int x, int y) {
+ reinterpret_cast<Fl_Image*>(i)->draw(x, y);
+}
+
+void fl_image_draw2(IMAGE i, int x, int y, int w, int h, int cx, int cy) {
+ reinterpret_cast<Fl_Image*>(i)->draw(x, y, w, h, cx, cy);
+}
+
+void fl_image_draw_empty(IMAGE i, int x, int y) {
+ reinterpret_cast<My_Image*>(i)->draw_empty(x, y);
+}
+
diff --git a/src/c_fl_image.h b/src/c_fl_image.h
index bdd71a3..b3fac75 100644
--- a/src/c_fl_image.h
+++ b/src/c_fl_image.h
@@ -24,6 +24,7 @@ extern "C" void fl_image_desaturate(IMAGE i);
extern "C" void fl_image_inactive(IMAGE i);
+extern "C" int fl_image_fail(IMAGE i);
extern "C" int fl_image_w(IMAGE i);
@@ -31,5 +32,10 @@ extern "C" int fl_image_h(IMAGE i);
extern "C" int fl_image_d(IMAGE i);
+extern "C" void fl_image_draw(IMAGE i, int x, int y);
+extern "C" void fl_image_draw2(IMAGE i, int x, int y, int w, int h, int cx, int cy);
+extern "C" void fl_image_draw_empty(IMAGE i, int x, int y);
+
+
#endif
diff --git a/src/c_fl_rgb_image.cpp b/src/c_fl_rgb_image.cpp
index 96b5266..e91eec2 100644
--- a/src/c_fl_rgb_image.cpp
+++ b/src/c_fl_rgb_image.cpp
@@ -30,3 +30,10 @@ void fl_rgb_image_desaturate(RGB_IMAGE i) {
}
+
+
+void fl_rgb_image_draw(RGB_IMAGE i, int x, int y, int w, int h, int cx, int cy) {
+ reinterpret_cast<Fl_RGB_Image*>(i)->draw(x, y, w, h, cx, cy);
+}
+
+
diff --git a/src/c_fl_rgb_image.h b/src/c_fl_rgb_image.h
index 2879be1..d64f0a2 100644
--- a/src/c_fl_rgb_image.h
+++ b/src/c_fl_rgb_image.h
@@ -22,5 +22,8 @@ extern "C" void fl_rgb_image_color_average(RGB_IMAGE i, int c, float b);
extern "C" void fl_rgb_image_desaturate(RGB_IMAGE i);
+extern "C" void fl_rgb_image_draw(RGB_IMAGE i, int x, int y, int w, int h, int cx, int cy);
+
+
#endif
diff --git a/src/fltk-images-bitmaps.adb b/src/fltk-images-bitmaps.adb
index f8c954c..6d80954 100644
--- a/src/fltk-images-bitmaps.adb
+++ b/src/fltk-images-bitmaps.adb
@@ -31,6 +31,14 @@ package body FLTK.Images.Bitmaps is
+ procedure fl_bitmap_draw
+ (I : in System.Address;
+ X, Y, W, H, CX, CY : in Interfaces.C.int);
+ pragma Import (C, fl_bitmap_draw, "fl_bitmap_draw");
+
+
+
+
overriding procedure Finalize
(This : in out Bitmap) is
begin
@@ -70,5 +78,23 @@ package body FLTK.Images.Bitmaps is
end Copy;
+
+
+ procedure Draw
+ (This : in Bitmap;
+ X, Y, W, H : in Integer;
+ CX, CY : in Integer := 0) is
+ begin
+ fl_bitmap_draw
+ (This.Void_Ptr,
+ Interfaces.C.int (X),
+ Interfaces.C.int (Y),
+ Interfaces.C.int (W),
+ Interfaces.C.int (H),
+ Interfaces.C.int (CX),
+ Interfaces.C.int (CY));
+ end Draw;
+
+
end FLTK.Images.Bitmaps;
diff --git a/src/fltk-images-bitmaps.ads b/src/fltk-images-bitmaps.ads
index ce688f1..8f2e4bf 100644
--- a/src/fltk-images-bitmaps.ads
+++ b/src/fltk-images-bitmaps.ads
@@ -18,6 +18,14 @@ package FLTK.Images.Bitmaps is
return Bitmap;
+
+
+ procedure Draw
+ (This : in Bitmap;
+ X, Y, W, H : in Integer;
+ CX, CY : in Integer := 0);
+
+
private
diff --git a/src/fltk-images-rgb.adb b/src/fltk-images-rgb.adb
index fbbf23e..881b8cb 100644
--- a/src/fltk-images-rgb.adb
+++ b/src/fltk-images-rgb.adb
@@ -44,6 +44,14 @@ package body FLTK.Images.RGB is
+ procedure fl_rgb_image_draw
+ (I : in System.Address;
+ X, Y, W, H, CX, CY : in Interfaces.C.int);
+ pragma Import (C, fl_rgb_image_draw, "fl_rgb_image_draw");
+
+
+
+
overriding procedure Finalize
(This : in out RGB_Image) is
begin
@@ -104,5 +112,23 @@ package body FLTK.Images.RGB is
end Desaturate;
+
+
+ procedure Draw
+ (This : in RGB_Image;
+ X, Y, W, H : in Integer;
+ CX, CY : in Integer := 0) is
+ begin
+ fl_rgb_image_draw
+ (This.Void_Ptr,
+ Interfaces.C.int (X),
+ Interfaces.C.int (Y),
+ Interfaces.C.int (W),
+ Interfaces.C.int (H),
+ Interfaces.C.int (CX),
+ Interfaces.C.int (CY));
+ end Draw;
+
+
end FLTK.Images.RGB;
diff --git a/src/fltk-images-rgb.ads b/src/fltk-images-rgb.ads
index 6d0a1fc..f34c34a 100644
--- a/src/fltk-images-rgb.ads
+++ b/src/fltk-images-rgb.ads
@@ -29,6 +29,14 @@ package FLTK.Images.RGB is
(This : in out RGB_Image);
+
+
+ procedure Draw
+ (This : in RGB_Image;
+ X, Y, W, H : in Integer;
+ CX, CY : in Integer := 0);
+
+
private
diff --git a/src/fltk-images.adb b/src/fltk-images.adb
index f99c760..cadf47b 100644
--- a/src/fltk-images.adb
+++ b/src/fltk-images.adb
@@ -7,6 +7,7 @@ with
use type
+ Interfaces.C.int,
System.Address;
@@ -53,6 +54,11 @@ package body FLTK.Images is
(I : in System.Address);
pragma Import (C, fl_image_inactive, "fl_image_inactive");
+ function fl_image_fail
+ (I : in System.Address)
+ return Interfaces.C.int;
+ pragma Import (C, fl_image_fail, "fl_image_fail");
+
@@ -74,6 +80,24 @@ package body FLTK.Images is
+ procedure fl_image_draw
+ (I : in System.Address;
+ X, Y : in Interfaces.C.int);
+ pragma Import (C, fl_image_draw, "fl_image_draw");
+
+ procedure fl_image_draw2
+ (I : in System.Address;
+ X, Y, W, H, CX, CY : in Interfaces.C.int);
+ pragma Import (C, fl_image_draw2, "fl_image_draw2");
+
+ procedure fl_image_draw_empty
+ (I : in System.Address;
+ X, Y : in Interfaces.C.int);
+ pragma Import (C, fl_image_draw_empty, "fl_image_draw_empty");
+
+
+
+
overriding procedure Finalize
(This : in out Image) is
begin
@@ -97,6 +121,16 @@ package body FLTK.Images is
(Interfaces.C.int (Width),
Interfaces.C.int (Height),
Interfaces.C.int (Depth));
+ 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;
@@ -155,6 +189,14 @@ package body FLTK.Images is
end Inactive;
+ function Is_Empty
+ (This : in Image)
+ return Boolean is
+ begin
+ return fl_image_fail (This.Void_Ptr) /= 0;
+ end Is_Empty;
+
+
function Get_W
@@ -181,5 +223,45 @@ package body FLTK.Images is
end Get_D;
+
+
+ procedure Draw
+ (This : in Image;
+ X, Y : in Integer) is
+ begin
+ fl_image_draw
+ (This.Void_Ptr,
+ Interfaces.C.int (X),
+ Interfaces.C.int (Y));
+ end Draw;
+
+
+ procedure Draw
+ (This : in Image;
+ X, Y, W, H : in Integer;
+ CX, CY : in Integer := 0) is
+ begin
+ fl_image_draw2
+ (This.Void_Ptr,
+ Interfaces.C.int (X),
+ Interfaces.C.int (Y),
+ Interfaces.C.int (W),
+ Interfaces.C.int (H),
+ Interfaces.C.int (CX),
+ Interfaces.C.int (CY));
+ end Draw;
+
+
+ procedure Draw_Empty
+ (This : in Image;
+ X, Y : in Integer) is
+ begin
+ fl_image_draw_empty
+ (This.Void_Ptr,
+ Interfaces.C.int (X),
+ Interfaces.C.int (Y));
+ end Draw_Empty;
+
+
end FLTK.Images;
diff --git a/src/fltk-images.ads b/src/fltk-images.ads
index 51f8443..3e47ee6 100644
--- a/src/fltk-images.ads
+++ b/src/fltk-images.ads
@@ -7,6 +7,8 @@ package FLTK.Images is
type Blend is new Float range 0.0 .. 1.0;
+ No_Image_Error, File_Access_Error, Format_Error : exception;
+
@@ -40,6 +42,10 @@ package FLTK.Images is
procedure Inactive
(This : in out Image);
+ function Is_Empty
+ (This : in Image)
+ return Boolean;
+
@@ -56,6 +62,22 @@ package FLTK.Images is
return Natural;
+
+
+ procedure Draw
+ (This : in Image;
+ X, Y : in Integer);
+
+ procedure Draw
+ (This : in Image;
+ X, Y, W, H : in Integer;
+ CX, CY : in Integer := 0);
+
+ procedure Draw_Empty
+ (This : in Image;
+ X, Y : in Integer);
+
+
private