summaryrefslogtreecommitdiff
path: root/src/fltk-images.ads
blob: 0ee31d5696a837814f8b0913a259bef21cabe328 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233


package FLTK.Images is


    -------------
    --  Types  --
    -------------

    type Image is new Wrapper with private;

    type Image_Reference (Data : not null access Image'Class) is limited null record
        with Implicit_Dereference => Data;

    type Scaling_Kind is (Nearest, Bilinear);

    type Blend is new Float range 0.0 .. 1.0;

    No_Image_Error, File_Access_Error, Format_Error : exception;




    --------------------
    --  Construction  --
    --------------------

    package Forge is

        function Create
               (Width, Height, Depth : in Natural)
            return Image;

    end Forge;

    function Get_Copy_Algorithm
        return Scaling_Kind;

    procedure Set_Copy_Algorithm
           (To : in Scaling_Kind);

    function Copy
           (This          : in Image;
            Width, Height : in Natural)
        return Image'Class;

    function Copy
           (This : in Image)
        return Image'Class;




    --------------
    --  Colors  --
    --------------

    procedure Color_Average
           (This   : in out Image;
            Col    : in     Color;
            Amount : in     Blend);

    procedure Desaturate
           (This : in out Image);




    ----------------
    --  Activity  --
    ----------------

    procedure Inactive
           (This : in out Image);

    function Is_Empty
           (This : in Image)
        return Boolean;

    procedure Uncache
           (This : in out Image);




    ------------------
    --  Dimensions  --
    ------------------

    function Get_W
           (This : in Image)
        return Natural;

    function Get_H
           (This : in Image)
        return Natural;

    function Get_D
           (This : in Image)
        return Natural;

    function Get_Line_Data
           (This : in Image)
        return Natural;

    function Get_Data_Count
           (This : in Image)
        return Natural;

    function Get_Data_Size
           (This : in Image)
        return Natural;




    ------------------
    --  Pixel Data  --
    ------------------

    function Get_Datum
           (This     : in Image;
            Data     : in Positive;
            Position : in Positive)
        return Color_Component
    with Pre =>
            Data <= Get_Data_Count (This) and
            Position <= Get_Data_Size (This);

    procedure Set_Datum
           (This     : in out Image;
            Data     : in     Positive;
            Position : in     Positive;
            Value    : in     Color_Component)
    with Pre =>
            Data <= Get_Data_Count (This) and
            Position <= Get_Data_Size (This);

    function Get_Data
           (This     : in Image;
            Data     : in Positive;
            Position : in Positive;
            Count    : in Natural)
        return Color_Component_Array
    with Pre =>
            Data <= Get_Data_Count (This) and
            Position <= Get_Data_Size (This) and
            Count <= Get_Data_Size (This) - Position + 1;

    function All_Data
           (This : in Image;
            Data : in Positive)
        return Color_Component_Array
    with Pre =>
            Data <= Get_Data_Count (This);

    procedure Update_Data
           (This     : in out Image;
            Data     : in     Positive;
            Position : in     Positive;
            Values   : in     Color_Component_Array)
    with Pre =>
            Data <= Get_Data_Count (This) and
            Position <= Get_Data_Size (This) and
            Values'Length <= Get_Data_Size (This) - Position + 1;




    ---------------
    --  Drawing  --
    ---------------

    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


    type Image is new Wrapper with null record;

    overriding procedure Finalize
           (This : in out Image);




    pragma Inline (Get_Copy_Algorithm);
    pragma Inline (Set_Copy_Algorithm);
    pragma Inline (Copy);


    pragma Inline (Color_Average);
    pragma Inline (Desaturate);


    pragma Inline (Inactive);
    pragma Inline (Is_Empty);
    pragma Inline (Uncache);


    pragma Inline (Get_W);
    pragma Inline (Get_H);
    pragma Inline (Get_D);
    pragma Inline (Get_Line_Data);
    pragma Inline (Get_Data_Count);


    pragma Inline (Draw);
    pragma Inline (Draw_Empty);




    function fl_image_fail
           (I : in System.Address)
        return Interfaces.C.int;
    pragma Import (C, fl_image_fail, "fl_image_fail");


end FLTK.Images;