135
/** #OrientationBits# defines 3 mutually exclusive
136
bits to indicate the image orientation.
138
There are four possible rotation values for an image
139
which are 0 degrees, 90 degrees, 180 degrees, and 270 degrees.
140
In addition the image can be mirrored backwards in any of these
141
orientations, giving a possible of 8 orientations. To sanely deal
142
with these orientations, we have defined 3 mutually exclusive
143
bits. These are BOTTOM_UP, MIRROR, and ROTATE90_CW.
147
BOTTOM_UP=0x1, /* Upside down */
148
MIRROR=0x2, /* Written backwards. (right to left) */
149
ROTATE90_CW=0x4 /* rotated 90 degrees */
152
/** #Orientations# defines all 8 possible orientations, using
153
the three \Ref{OrientationBits}.
155
\item {\em TDLRNR} for Top Down, Left to Right, No Rotation.
156
\item {\em BULRNR} for Bottom Up, Left to Right, No Rotation.
157
\item {\em TDRLNR} for Top Down, Right to Left, No Rotation.
158
\item {\em BURLNR} for Bottom Up, Right to Left, No Rotation.
159
\item {\em TDLRCW} for Top Down, Left to Right, 90 degree CW rotation.
160
\item {\em BULRCW} for Bottom Up, Left to Right, 90 degree CW rotation.
161
\item {\em TDRLCW} for Top Down, Right to Left, 90 degree CW rotation.
162
\item {\em BURLCW} for Bottom Up, Right to Left, 90 degree CW rotation.
167
TDLRNR=0, /* normal orientation */
168
BULRNR=BOTTOM_UP, /* upside down */
169
TDRLNR=MIRROR, /* backwards (right to left) */
170
BURLNR=MIRROR|BOTTOM_UP, /* rotate 180 */
171
TDLRCW=ROTATE90_CW, /* rotated 90 */
172
BULRCW=ROTATE90_CW|BOTTOM_UP, /* backwards and rotate 180 */
173
TDRLCW=ROTATE90_CW|MIRROR, /* backwards and rotate 90 */
174
BURLCW=ROTATE90_CW|MIRROR|BOTTOM_UP /* rotate 270 */
178
rotate(const int angle,Orientations orientation)
180
for(int a=(((angle)%360)+405)%360;a>90;a-=90)
181
orientation=(Orientations)((int)orientation^(int)(orientation&ROTATE90_CW)?BURLCW:TDLRCW);
186
findangle(const Orientations orientation)
189
while(a&&(rotate(a,BURLNR)!=orientation)&&(rotate(a,TDRLNR)!=orientation))
194
142
/** Constructs an empty rectangle */
196
144
/** Constructs a rectangle given its minimal coordinates #xmin# and #ymin#,