summaryrefslogtreecommitdiff
path: root/src/Image/Image_GImage.cdl
blob: fa57ec1e9bd513fdb134f8269bff892e33a1c923 (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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
-- File:	Image_GImage.cdl
-- Created:	Tue Jul 27 18:47:06 1993
-- Author:	Jean Louis FRENKEL
--		<jlf@sparc3>
---Copyright:	 Matra Datavision 1993


deferred generic class GImage from Image (anyPixel as Pixel from Aspect) 
						inherits Image from Image

	---Purpose: Provide genmeric Image method independent from Pixel type.

uses

    Pixel       	from Aspect,
    PixelInterpolation	from Image,
    PixelAddress 	from Image,
    FlipType    	from Image,
    TypeOfImage 	from Image,
    PlaneAngle  	from Quantity,
    Trsf		from gp,
    GTrsf2d		from gp

    class PixelRow   instantiates Array1 from TCollection (anyPixel);
	---Level: Public
	---Purpose: Manipulates PixelRow.

    class PixelField instantiates GPixelField from Image (anyPixel);
	---Level: Public
	---Purpose: Resizable Image PixelField.

is

    Initialize( x,y,dx,dy : in Integer from Standard ;
		BackPixel : in anyPixel ) ;
	---Level: Public
	---Purpose: GImage constructor ,initialise Image origin, create Image
	--		PixelField .

    Destroy (me : mutable )
	---Level: Public
    	---Purpose: Frees   the allocated   area corresponding to  the
    	--          PixelField.
        --          
        ---C++: alias ~
    is redefined;

    SetBackgroundPixel( me : mutable ; aPixel: in anyPixel ) ;
	---Level: Public
	---Purpose: Sets the  Image BackgroundPixel.

    BackgroundPixel   ( me : immutable ) returns anyPixel ;
    	---C++: return const &
	---Level: Public
 	---Purpose: Return the Image BackgroundPixel.
 
    Pixel ( me : immutable ; X,Y : in Integer from Standard ) 
	returns anyPixel ;
    	---C++: return const &
    	---C++: alias operator()
	---Level: Public
	---Purpose: Return the Image Pixel Value at X,Y coordinate.
	--		The returned Pixel is ReadOnly .

    SetPixel( me : mutable   ; X,Y   : in Integer from Standard ; 
	                              aPixel: in anyPixel ) ;
	---Level: Public
	---Purpose: Sets the Image Pixel at X,Y coordinate with aPixel.
 	    
    MutPixel   ( me : mutable  ; X,Y : in Integer from Standard ) 
	returns anyPixel ;
    	---C++: return &
    	---C++: alias operator()
	---Level: Public
	---Purpose: Return the Image Pixel Value at X,Y coordinate.
	--		The returned Pixel is ReadWrite .

    SetRow  ( me : mutable   ; X,Y : in Integer from Standard ;
                                      aRow: in PixelRow from Image);
	---Level: Public
	---Purpose: Sets an Image PixelRow starting at X,Y coordinate with aRow.

    Row     ( me : immutable ; X,Y : in Integer from Standard ;
             		              aRow: in out PixelRow from Image);
	---Level: Public
	---Purpose: Get an Image PixelRow starting at X,Y coordinate in aRow.

    SwapRow ( me : mutable ; I,J : Integer from Standard);
	---Level: Public
	---Purpose: Swap row.

    SwapCol ( me : mutable ; I,J : Integer from Standard);
	---Level: Public
	---Purpose: Swap columns.

    Zoom     ( me : mutable ; 
				anInterpolation : PixelInterpolation from Image;
				aCoefX,aCoefY  : in Real from Standard ) ;
	---Level: Public
	---Purpose: Zoom an Image with a specific PixelInterpolation method.
	--		Warning: image size change after a Zoom.

    Rotate   ( me : mutable ;
				anInterpolation : PixelInterpolation from Image;
				aAngle         : in PlaneAngle from Quantity ) ;
	---Level: Public
	---Purpose: Rotate an Image with a specific PixelInterpolation method.

    Translate( me : mutable ;
				anInterpolation : PixelInterpolation from Image;
				DX, DY         : in Real from Standard ) ;
	---Level: Public
	---Purpose: Translate an Image with a specific PixelInterpolation method.

    Affine( me : mutable ;
				anInterpolation : PixelInterpolation from Image;
	       			Trsf           : in GTrsf2d from gp ) ;
	---Level: Public
	---Purpose : General transformation of an Image with the default 
	--		PixelInterpolation method.
	--	Warning:         
	--  		Raised an exception if the matrix of the transformation 
        --  		is not inversible.

    Affine( me : mutable ;
				anInterpolation : PixelInterpolation from Image;
	       			Trsf           : in Trsf from gp ) ;
	---Level: Public
	---Purpose : General transformation of an Image with the default 
	--		PixelInterpolation method.
	--	Warning:         
	--  		Raised an exception if the matrix of the transformation 
        --  		is not inversible.

    InternalDup( me : mutable ; anImage : immutable like me )
		is redefined ;
	---Level: Public
	---Purpose : Duplicate an Image.

    -- ******************* Deferred method from Image ******************* 

    SetOrigin ( me : mutable ; x,y : in Integer from Standard ) ;
	---Level: Public
	---Purpose: Sets Image origin, for Rotation, copy between image ...
	--		Image origin is on the TOP LEFT . Y axis goes TOP to
	--		DOWN , X axis goes LEFT to RIGHT.


    LowerX  ( me : immutable )  returns Integer from Standard ;
	---Level: Public
	---Purpose: Return the lower X Image coordinate ( X Origin ).
    UpperX  ( me : immutable )  returns Integer from Standard ;
	---Level: Public
 	---Purpose: Return the upper X Image coordinate 
	--		( X Origin + Image width - 1 ).

    Width   ( me : immutable )  returns Integer from Standard ;
	---Level: Public
	---Purpose: Return the Image width.

    LowerY  ( me : immutable )  returns Integer from Standard ;
	---Level: Public
	---Purpose: Return the lower Y Image coordinate ( Y Origin ).

    UpperY  ( me : immutable )  returns Integer from Standard ;
	---Level: Public
	---Purpose: Return the upper Y Image coordinate 
	--		( Y Origin + Image height - 1 ).

    Height  ( me : immutable )  returns Integer from Standard ;
	---Level: Public
	---Purpose: Return the Image height.

    Resize( me : mutable ; 
	XOffset,XScale, YOffset,YScale : Real from Standard ) ;
	---Level: Public
	---Purpose: Resize an Image. Image Pixel are left unchanged at there
	--	      absolute positon. Resulting Image can be clipped.
	--	newLowerX = LowerX()*XScale + XOffset
	--	newLowerY = LowerY()*YScale + YOffset
	--	newUpperX = UpperX()*XScale + XOffset
	--	newUpperY = UpperY()*YScale + YOffset
	--	newWidth  = Width() *XScale
	--	newHeight = Height()*YScale

    Type    ( me : immutable )  returns TypeOfImage from Image is deferred ;
	---Level: Public
	---Purpose: Return the ImageType TOI_ColorImage or TOI_PseudoColorImage

    isSamePixel( me : immutable ; 
	X,Y    	     		: in Integer from Standard ;
	anotherImage 		: immutable like me ;
	anotherX,anotherY	: in Integer from Standard ) 
	returns Boolean from Standard ;
	---Level: Public
	---Purpose: Returns True if me->Pixel(X,Y) is equal to 
	--	    anotherImage->Pixel(anotherX,anotherY)

    Pixel   ( me : immutable ; 	X,Y    : in Integer from Standard ;
				aPixel : in out Pixel from Aspect ) ;
	---Level: Public
	---Purpose: Store the Image Pixel Value at X,Y coordinate in aPixel.
	--	    Warning: aPixel must have the same type than Image Pixel.

    SetPixel( me : mutable ; 	X,Y    : in Integer from Standard ;
				aPixel : in Pixel   from Aspect ) ;
	---Level: Public
	---Purpose: Store aPixel in the Image  at X,Y coordinate .
	-- Warning: aPixel must have the same type than Image Pixel.

    Pixel   ( me : immutable ; 	X,Y    : in Integer from Standard ;
				aPixel : in out PixelAddress from Image ) ;
	---Level: Public
	---Purpose: Store the Image Pixel Value at X,Y coordinate in aPixel.
	--	    Warning: aPixel must have the same type than Image Pixel.

    SetPixel( me : mutable ; 	X,Y    : in Integer from Standard ;
				aPixel : in PixelAddress from Image ) ;
	---Level: Public
	---Purpose: Store aPixel in the Image  at X,Y coordinate .
	-- Warning: aPixel must have the same type than Image Pixel.

    Transpose( me : mutable ; aType         : in FlipType from Image ) ;
	---Level: Public
	---Purpose: Transpose an Image( flipping across horizontal axis or 
	--		vertical axis, or acroos diagonal... )
	--	    This geometric transformation preserve all Image Pixels.
	--	    We don't need to interpolate pixel .
	--	    Warning : Image size change durring Transpose.

    Clip     ( me : mutable ; X,Y,Width,Height:in Integer from Standard);
	---Level: Public
	---Purpose: Extract a SubImage starting at coordinate X,Y 
	--		to (X+Width-1),(Y+Height-1).
	--	    Warning : the Image size and origin change, new origine
	--	    is X,Y ; new size is Width,Height.


    Shift    ( me : mutable ; XShifth,YShift  :in Integer from Standard);
	---Level: Public
	---Purpose: Translate an Image XShifth pixel Right, YShift Down .
	--	    Shift parameter are Integer value.

    Fill     ( me : mutable ; SrcImage : immutable like me ) ;
	---Level: Public
	---Purpose: Fill me with SrcImage. SrcImage pixel are copied starting
	--	     at SrcImage->LowerX(),SrcImage->LowerY() in MyPixelField.
	--	     SrcImage Pixel are clipped outside <me>.

    Fill     ( me : mutable ; SrcImage : immutable like me ;
		SrcX, SrcY, SrcWidth, SrcHeight,
		X, Y : in Integer from Standard ) ;
	---Level: Public
	---Purpose: Fill me with a SubImage of SrcImage starting from 
	--	    SrcX, SrcY to (SrcX+SrcWidth-1),(SrcY+SrcHeight-1) in 
	--	    Src Image coordinate. SrcImage SubImage pixels are copied 
	--	    starting at X,Y in MyPixelField.
	--	    SrcImage Pixel are clipped outside <me>.


    FillRect  ( me : mutable ; aPixel : anyPixel ;
		X, Y, Width, Height : in Integer from Standard) ;
	---Level: Public
	---Purpose: Fill a Rectangle in me with a Pixel 
	--	    starting at X,Y to (X+Width-1,Y+Height-1) .

    DrawRect  ( me : mutable ; aPixel : anyPixel ;
		X, Y, Width, Height : in Integer from Standard) ;
	---Level: Public
	---Purpose: draw a Rectangle in me with a Pixel  
	--	    starting at X,Y to (X+Width-1,Y+Height-1) .

    DrawLine  ( me : mutable ; aPixel : anyPixel ;
		X1, Y1, X2, Y2 : in Integer from Standard) ;
	---Level: Public
	---Purpose: draw a line in me with a Pixel  
	--	    starting at X1,Y1 to X2,Y2 .

    --DrawCircle  ( me : mutable ; aPixel : anyPixel ;
		  --X, Y, R : in Integer from Standard) ;
	-- ---Level: Public
	-- ---Purpose: draw a circle in me with a Pixel

    Clear    ( me : mutable ) ;
	---Level: Public
	---Purpose: Fill the entire Image with the BackgroundPixel.

    Dump    ( me : immutable ) ;
	---Level: Public
	---Purpose: Debug
    
    -- ******************* Redefined method  *************************** 

--	ShallowCopy (me) returns mutable like me is redefined deferred ;
	---Level: Public
--	    ---Purpose: Returns a copy at the first level of <me>. The objects 
--	    --         referenced are not copied. Entities copied by 
--	    --         ShallowCopy are equal.
--	    ---C++:  function call

--	DeepCopy (me) returns mutable like me is redefined deferred ;
	---Level: Public
--	    ---Purpose: Returns a deep copy of <me>. The objects 
--	    --          referenced are copied. Entities copied by 
--	    --          DeepCopy are similar (c.f the Method IsSimilar).
--	    ---C++:  function call

    --  *******************  Private Method   ******************* 

    FlipHorizontal  ( me : mutable ) is private ;
    FlipVertical    ( me : mutable ) is private ;
    FlipMainDiagonal( me : mutable ) is private ;
    FlipAntiDiagonal( me : mutable ) is private ;
    Rotate90        ( me : mutable ) is private ;
    Rotate180       ( me : mutable ) is private ;
    Rotate270       ( me : mutable ) is private ;
    PixelField      ( me : immutable ) 
			returns PixelField from Image is private ;
    	---C++: return const &
    PixelFieldCopyTo(   me  : immutable ; 
		      	Dst : in out PixelField from Image ;
			LowR,LowC,UpR,UpC,
			DstLowR, DstLowC :in Integer from Standard) is private;
    PixelFieldCopyFrom( me  : mutable ; 
		      	Dst : PixelField from Image ;
			LowR,LowC,UpR,UpC,
			DstLowR, DstLowC :in Integer from Standard) is private;

    PixelFieldDestroy( me  : mutable ) is private ; 

    CirclePixels( me : mutable ;
		  Pixel : anyPixel ;
		  XCenter, YCenter, x,y : Integer from Standard ;
		  LowX,LowY,UpX,UpY : Integer from Standard ) is private ;

fields
    myX,myY		: Integer from Standard ;
    myPixelField	: Address from Standard ;
    myBackgroundPixel	: anyPixel;
end GImage from Image;