From ffc566b41d9dd64b2d571f68458a272f503958c6 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Mon, 15 May 2017 11:08:34 +1000 Subject: Most relevant methods for Image now implemented, except for Draw --- src/c_fl_image.cpp | 25 +++++++++++++++ src/c_fl_image.h | 5 +++ src/fltk-enums.ads | 3 ++ src/fltk-images.adb | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/fltk-images.ads | 31 +++++++++++++++++++ src/fltk-widgets.ads | 2 +- 6 files changed, 151 insertions(+), 1 deletion(-) diff --git a/src/c_fl_image.cpp b/src/c_fl_image.cpp index 8222392..a02c683 100644 --- a/src/c_fl_image.cpp +++ b/src/c_fl_image.cpp @@ -15,6 +15,31 @@ void free_fl_image(IMAGE i) { } +IMAGE fl_image_copy(IMAGE i, int w, int h) { + return reinterpret_cast(i)->copy(w, h); +} + + +IMAGE fl_image_copy2(IMAGE i) { + return reinterpret_cast(i)->copy(); +} + + + + +void fl_image_color_average(IMAGE i, int c, float b) { + reinterpret_cast(i)->color_average(c, b); +} + + +void fl_image_desaturate(IMAGE i) { + reinterpret_cast(i)->desaturate(); +} + + +void fl_image_inactive(IMAGE i) { + reinterpret_cast(i)->inactive(); +} int fl_image_w(IMAGE i) { diff --git a/src/c_fl_image.h b/src/c_fl_image.h index a4be6df..ce4a8ba 100644 --- a/src/c_fl_image.h +++ b/src/c_fl_image.h @@ -9,8 +9,13 @@ typedef void* IMAGE; extern "C" IMAGE new_fl_image(int w, int h, int d); extern "C" void free_fl_image(IMAGE i); +extern "C" IMAGE fl_image_copy(IMAGE i, int w, int h); +extern "C" IMAGE fl_image_copy2(IMAGE i); +extern "C" void fl_image_color_average(IMAGE i, int c, float b); +extern "C" void fl_image_desaturate(IMAGE i); +extern "C" void fl_image_inactive(IMAGE i); extern "C" int fl_image_w(IMAGE i); extern "C" int fl_image_h(IMAGE i); extern "C" int fl_image_d(IMAGE i); diff --git a/src/fltk-enums.ads b/src/fltk-enums.ads index 0057cec..ff8e69a 100644 --- a/src/fltk-enums.ads +++ b/src/fltk-enums.ads @@ -128,6 +128,9 @@ package FLTK.Enums is Fullscreen); + type Color is new Natural; + + -- type Modifier_Key is private; type Modifier_Key is new Interfaces.Unsigned_8; diff --git a/src/fltk-images.adb b/src/fltk-images.adb index d719e9c..5d3a1ed 100644 --- a/src/fltk-images.adb +++ b/src/fltk-images.adb @@ -17,6 +17,32 @@ package body FLTK.Images is (I : in System.Address); pragma Import (C, free_fl_image, "free_fl_image"); + function fl_image_copy + (I : in System.Address; + W, H : in Interfaces.C.int) + return System.Address; + pragma Import (C, fl_image_copy, "fl_image_copy"); + + function fl_image_copy2 + (I : in System.Address) + return System.Address; + pragma Import (C, fl_image_copy2, "fl_image_copy2"); + + + procedure fl_image_color_average + (I : in System.Address; + C : in Interfaces.C.int; + B : in Interfaces.C.C_float); + pragma Import (C, fl_image_color_average, "fl_image_color_average"); + + procedure fl_image_desaturate + (I : in System.Address); + pragma Import (C, fl_image_desaturate, "fl_image_desaturate"); + + procedure fl_image_inactive + (I : in System.Address); + pragma Import (C, fl_image_inactive, "fl_image_inactive"); + function fl_image_w (I : in System.Address) return Interfaces.C.int; @@ -65,6 +91,66 @@ package body FLTK.Images is + function Copy + (This : in Image; + Width, Height : in Natural) + return Image is + begin + return Copied : Image do + Copied.Void_Ptr := fl_image_copy + (This.Void_Ptr, + Interfaces.C.int (Width), + Interfaces.C.int (Height)); + end return; + end Copy; + + + + + function Copy + (This : in Image) + return Image is + begin + return Copied : Image do + Copied.Void_Ptr := fl_image_copy2 (This.Void_Ptr); + end return; + end Copy; + + + + + procedure Color_Average + (This : in out Image; + Col : in Color; + Amount : in Blend) is + begin + fl_image_color_average + (This.Void_Ptr, + Interfaces.C.int (Col), + Interfaces.C.C_float (Amount)); + end Color_Average; + + + + + procedure Desaturate + (This : in out Image) is + begin + fl_image_desaturate (This.Void_Ptr); + end Desaturate; + + + + + procedure Inactive + (This : in out Image) is + begin + fl_image_inactive (This.Void_Ptr); + end Inactive; + + + + function Get_W (This : in Image) return Natural is diff --git a/src/fltk-images.ads b/src/fltk-images.ads index f005443..980eb23 100644 --- a/src/fltk-images.ads +++ b/src/fltk-images.ads @@ -1,16 +1,47 @@ +with FLTK.Enums; use FLTK.Enums; + + package FLTK.Images is type Image is new Wrapper with private; + type Blend is new Float range 0.0 .. 1.0; + + function Create (Width, Height, Depth : in Natural) return Image; + function Copy + (This : in Image; + Width, Height : in Natural) + return Image; + + + function Copy + (This : in Image) + return Image; + + + procedure Color_Average + (This : in out Image; + Col : in Color; + Amount : in Blend); + + + procedure Desaturate + (This : in out Image); + + + procedure Inactive + (This : in out Image); + + function Get_W (This : in Image) return Natural; diff --git a/src/fltk-widgets.ads b/src/fltk-widgets.ads index 439b72d..dce79b5 100644 --- a/src/fltk-widgets.ads +++ b/src/fltk-widgets.ads @@ -21,7 +21,7 @@ package FLTK.Widgets is type Font_Size is new Natural; Normal_Size : constant Font_Size := 14; - type Color is new Natural; + type Event_Outcome is (Not_Handled, Handled); -- cgit