summaryrefslogtreecommitdiff
path: root/spec/fltk-images-bitmaps.ads
blob: d60334fcbc549c5f4658ddd8ea0b4b03a86897b6 (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


--  Programmed by Jedidiah Barber
--  Released into the public domain


package FLTK.Images.Bitmaps is


    type Bitmap is new Image with private;

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




    function To_Next_Byte
           (Bits : in Natural)
        return Natural;




    package Forge is

        --  Please note that input data should be some declared item
        --  that lives at least as long as the resulting Bitmap.

        function Create
               (Data          : in Color_Component_Array;
                Width, Height : in Natural)
            return Bitmap
        with Pre => Data'Length = To_Next_Byte (Width) * Height;

    end Forge;




    --  Copying  --

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

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




    --  Activity  --

    procedure Uncache
           (This : in out Bitmap);




    --  Pixel Data  --

    function Data_Size
           (This : in Bitmap)
        return Natural;

    function Get_Datum
           (This  : in Bitmap;
            Place : in Positive)
        return Color_Component
    with Pre => Place <= This.Data_Size;

    procedure Set_Datum
           (This  : in out Bitmap;
            Place : in     Positive;
            Value : in     Color_Component)
    with Pre => Place <= This.Data_Size;

    function Slice
           (This : in Bitmap;
            Low  : in Positive;
            High : in Natural)
        return Color_Component_Array
    with Pre => High <= This.Data_Size,
        Post => Slice'Result'Length = Integer'Max (0, High - Low + 1);

    procedure Overwrite
           (This   : in out Bitmap;
            Place  : in     Positive;
            Values : in     Color_Component_Array)
    with Pre => Place + Values'Length - 1 <= This.Data_Size;

    function All_Data
           (This : in Bitmap)
        return Color_Component_Array
    with Post => All_Data'Result'Length = This.Data_Size;




    --  Drawing  --

    procedure Draw
           (This : in Bitmap;
            X, Y : in Integer);

    procedure Draw
           (This           : in Bitmap;
            X, Y, W, H     : in Integer;
            Clip_X, Clip_Y : in Integer := 0);


private


    type Bitmap is new Image with null record;

    overriding procedure Finalize
           (This : in out Bitmap);


    pragma Inline (To_Next_Byte);

    pragma Inline (Copy);

    pragma Inline (Uncache);

    pragma Inline (Data_Size);
    pragma Inline (Get_Datum);
    pragma Inline (Set_Datum);
    pragma Inline (Slice);
    pragma Inline (Overwrite);
    pragma Inline (All_Data);

    pragma Inline (Draw);


end FLTK.Images.Bitmaps;