summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/c_fl_rgb_image.cpp33
-rw-r--r--src/c_fl_rgb_image.h20
-rw-r--r--src/fltk-images-rgb.adb91
-rw-r--r--src/fltk-images-rgb.ads21
4 files changed, 165 insertions, 0 deletions
diff --git a/src/c_fl_rgb_image.cpp b/src/c_fl_rgb_image.cpp
new file mode 100644
index 0000000..83a89ac
--- /dev/null
+++ b/src/c_fl_rgb_image.cpp
@@ -0,0 +1,33 @@
+
+
+#include <FL/Fl_RGB_Image.H>
+#include "c_fl_rgb_image.h"
+
+
+void free_fl_rgb_image(RGB_IMAGE i) {
+ delete reinterpret_cast<Fl_RGB_Image*>(i);
+}
+
+
+RGB_IMAGE fl_rgb_image_copy(RGB_IMAGE i, int w, int h) {
+ return reinterpret_cast<Fl_RGB_Image*>(i)->copy(w, h);
+}
+
+
+RGB_IMAGE fl_rgb_image_copy2(RGB_IMAGE i) {
+ return reinterpret_cast<Fl_RGB_Image*>(i)->copy();
+}
+
+
+
+
+void fl_rgb_image_color_average(RGB_IMAGE i, int c, float b) {
+ reinterpret_cast<Fl_RGB_Image*>(i)->color_average(c, b);
+}
+
+
+void fl_rgb_image_desaturate(RGB_IMAGE i) {
+ reinterpret_cast<Fl_RGB_Image*>(i)->desaturate();
+}
+
+
diff --git a/src/c_fl_rgb_image.h b/src/c_fl_rgb_image.h
new file mode 100644
index 0000000..3209909
--- /dev/null
+++ b/src/c_fl_rgb_image.h
@@ -0,0 +1,20 @@
+
+
+#ifndef FL_RGB_IMAGE_GUARD
+#define FL_RGB_IMAGE_GUARD
+
+
+typedef void* RGB_IMAGE;
+
+
+extern "C" void free_fl_rgb_image(RGB_IMAGE i);
+extern "C" RGB_IMAGE fl_rgb_image_copy(RGB_IMAGE i, int w, int h);
+extern "C" RGB_IMAGE fl_rgb_image_copy2(RGB_IMAGE i);
+
+
+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);
+
+
+#endif
+
diff --git a/src/fltk-images-rgb.adb b/src/fltk-images-rgb.adb
index 3556f74..0287914 100644
--- a/src/fltk-images-rgb.adb
+++ b/src/fltk-images-rgb.adb
@@ -1,14 +1,105 @@
+with Interfaces.C;
+with System;
+use type System.Address;
+
+
package body FLTK.Images.RGB is
+ procedure free_fl_rgb_image
+ (I : in System.Address);
+ pragma Import (C, free_fl_rgb_image, "free_fl_rgb_image");
+
+ function fl_rgb_image_copy
+ (I : in System.Address;
+ W, H : in Interfaces.C.int)
+ return System.Address;
+ pragma Import (C, fl_rgb_image_copy, "fl_rgb_image_copy");
+
+ function fl_rgb_image_copy2
+ (I : in System.Address)
+ return System.Address;
+ pragma Import (C, fl_rgb_image_copy2, "fl_rgb_image_copy2");
+
+
+ procedure fl_rgb_image_color_average
+ (I : in System.Address;
+ C : in Interfaces.C.int;
+ B : in Interfaces.C.C_float);
+ pragma Import (C, fl_rgb_image_color_average, "fl_rgb_image_color_average");
+
+ procedure fl_rgb_image_desaturate
+ (I : in System.Address);
+ pragma Import (C, fl_rgb_image_desaturate, "fl_rgb_image_desaturate");
+
+
+
+
overriding procedure Finalize
(This : in out RGB_Image) is
begin
+ if This.Void_Ptr /= System.Null_Address and then
+ This in RGB_Image'Class
+ then
+ free_fl_rgb_image (This.Void_Ptr);
+ This.Void_Ptr := System.Null_Address;
+ end if;
Finalize (Image (This));
end Finalize;
+
+
+ function Copy
+ (This : in RGB_Image;
+ Width, Height : in Natural)
+ return RGB_Image is
+ begin
+ return Copied : RGB_Image do
+ Copied.Void_Ptr := fl_rgb_image_copy
+ (This.Void_Ptr,
+ Interfaces.C.int (Width),
+ Interfaces.C.int (Height));
+ end return;
+ end Copy;
+
+
+
+
+ function Copy
+ (This : in RGB_Image)
+ return RGB_Image is
+ begin
+ return Copied : RGB_Image do
+ Copied.Void_Ptr := fl_rgb_image_copy2 (This.Void_Ptr);
+ end return;
+ end Copy;
+
+
+
+
+ procedure Color_Average
+ (This : in out RGB_Image;
+ Col : in Color;
+ Amount : in Blend) is
+ begin
+ fl_rgb_image_color_average
+ (This.Void_Ptr,
+ Interfaces.C.int (Col),
+ Interfaces.C.C_float (Amount));
+ end Color_Average;
+
+
+
+
+ procedure Desaturate
+ (This : in out RGB_Image) is
+ begin
+ fl_rgb_image_desaturate (This.Void_Ptr);
+ end Desaturate;
+
+
end FLTK.Images.RGB;
diff --git a/src/fltk-images-rgb.ads b/src/fltk-images-rgb.ads
index ba47793..ea47c2b 100644
--- a/src/fltk-images-rgb.ads
+++ b/src/fltk-images-rgb.ads
@@ -6,6 +6,27 @@ package FLTK.Images.RGB is
type RGB_Image is new Image with private;
+ function Copy
+ (This : in RGB_Image;
+ Width, Height : in Natural)
+ return RGB_Image;
+
+
+ function Copy
+ (This : in RGB_Image)
+ return RGB_Image;
+
+
+ procedure Color_Average
+ (This : in out RGB_Image;
+ Col : in Color;
+ Amount : in Blend);
+
+
+ procedure Desaturate
+ (This : in out RGB_Image);
+
+
private