|
1 /* |
|
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Image Transforms subsystem. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #ifndef CVTIMAGEROTATOR_H |
|
23 #define CVTIMAGEROTATOR_H |
|
24 |
|
25 // INCLUDE FILES |
|
26 |
|
27 #include <e32base.h> |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 |
|
31 class CVtImage; |
|
32 class CFbsBitmap; |
|
33 class CVtImageRotatorImpl; |
|
34 |
|
35 // CLASS DECLARATIONS |
|
36 |
|
37 /** |
|
38 * Image rotator observer interface. |
|
39 * |
|
40 * @lib videosource.lib |
|
41 */ |
|
42 class MVtImageRotatorObserver |
|
43 { |
|
44 public: |
|
45 /** |
|
46 * Callback method that is called by CVtImageRotator when rotation |
|
47 * process has been finished. |
|
48 * @param "aError" KErrNone if the rotation was done successfully, one |
|
49 * of the system wide error codes otherwise. |
|
50 * @return Pointer to newly created instance. |
|
51 */ |
|
52 virtual void RotationFinished( TInt aError ) = 0; |
|
53 }; |
|
54 |
|
55 /** |
|
56 * Image rotator. |
|
57 * |
|
58 * @lib videosource.lib |
|
59 */ |
|
60 class CVtImageRotator : public CActive |
|
61 { |
|
62 public: |
|
63 /** |
|
64 * An enumeration within the CVtImageRotator namespace. |
|
65 * It provides a set of panic codes that may happen during |
|
66 * rotation process. |
|
67 */ |
|
68 enum TPanics |
|
69 { |
|
70 /** |
|
71 * RotateL() is called while previous rotation process |
|
72 * has not yet been finished. |
|
73 */ |
|
74 EBusy = 1 |
|
75 }; |
|
76 |
|
77 /** |
|
78 * An enumeration within the CVtImageRotator namespace. |
|
79 * It provides a set of supported rotation and mirror angles. |
|
80 */ |
|
81 enum TRotationAngle |
|
82 { |
|
83 /** |
|
84 * Uninitialized place holder. Giving this rotation angle |
|
85 * to RotateL() will make RotateL() leave with error code |
|
86 * KErrNotSupported. |
|
87 */ |
|
88 ERotationNone = -1, |
|
89 |
|
90 /** |
|
91 * Rotates image 90 degrees in a clockwise direction. |
|
92 */ |
|
93 E90DegreesClockwise, |
|
94 |
|
95 /** |
|
96 * Rotates image 180 degrees in a clockwise direction. |
|
97 * (flip & mirror) |
|
98 */ |
|
99 E180DegreesClockwise, |
|
100 |
|
101 /** |
|
102 * Rotates image 270 degrees in a clockwise direction. |
|
103 */ |
|
104 E270DegreesClockwise, |
|
105 |
|
106 /** |
|
107 * Mirrors the bitmap around the horizontal axis. |
|
108 */ |
|
109 EMirrorHorizontalAxis, |
|
110 |
|
111 /** |
|
112 * Flips the image around the vertical axis. |
|
113 */ |
|
114 EFlipVerticalAxis, |
|
115 }; |
|
116 |
|
117 public: |
|
118 |
|
119 /** |
|
120 * Creates new instance of CVtImageRotator. |
|
121 * @param "aObserver" Reference to instance observer. |
|
122 * @param "aPriority" Active object priority. |
|
123 * @exception In error situation leaves with one of the system wide |
|
124 * error codes. |
|
125 * @return Pointer to newly created instance. |
|
126 */ |
|
127 IMPORT_C static CVtImageRotator* NewL( |
|
128 MVtImageRotatorObserver& aObserver, |
|
129 TPriority aPriority = EPriorityLow ); |
|
130 |
|
131 /** |
|
132 * C++ destructor. |
|
133 */ |
|
134 IMPORT_C ~CVtImageRotator(); |
|
135 |
|
136 /** |
|
137 * Rotates image to given angle. |
|
138 * @param "aSource" Source image that will be rotated. |
|
139 * @param "aTarget" Target image that will hold the rotated image. |
|
140 * @param "aAngle" Rotation angle. |
|
141 * @exception In error situation leaves with one of the system wide |
|
142 * error codes. |
|
143 */ |
|
144 IMPORT_C void RotateL( const CVtImage& aSource, CVtImage& aTarget, |
|
145 const TRotationAngle& aAngle ); |
|
146 |
|
147 /** |
|
148 * Rotates image to given angle. Possible error during initialization is |
|
149 * returned via MVtImageRotatorObserver. |
|
150 * @param "aSource" Source image that will be rotated. |
|
151 * @param "aTarget" Target image that will hold the rotated image. |
|
152 * @param "aAngle" Rotation angle. |
|
153 */ |
|
154 IMPORT_C void Rotate( const CVtImage& aSource, CVtImage& aTarget, |
|
155 const TRotationAngle& aAngle ); |
|
156 |
|
157 private: // internal |
|
158 |
|
159 /** |
|
160 * C++ default constructor. |
|
161 */ |
|
162 CVtImageRotator(); |
|
163 |
|
164 /** |
|
165 * C++ constructor. |
|
166 * @param "aObserver" Reference to observer. |
|
167 * @param "aPriority" Active object priority. |
|
168 * @exception In error situation leaves with one of the system wide |
|
169 * error codes. |
|
170 */ |
|
171 CVtImageRotator( MVtImageRotatorObserver& aObserver, TPriority aPriority ); |
|
172 |
|
173 /** |
|
174 * Second phase constructor. |
|
175 * @exception In error situation leaves with one of the system wide |
|
176 * error codes. |
|
177 */ |
|
178 void ConstructL(); |
|
179 |
|
180 /** |
|
181 * Creates new instance of rotator implementation if needed. |
|
182 * @param "aAngle" Used rotation angle. |
|
183 * @exception In error situation leaves with one of the system wide |
|
184 * error codes. |
|
185 */ |
|
186 void CreateRotatorL( const TRotationAngle& aAngle ); |
|
187 |
|
188 /** |
|
189 * Sets iStatus to KRequestPending and calls CActive::SetActive(). |
|
190 */ |
|
191 void Activate(); |
|
192 |
|
193 /** |
|
194 * Signals this instance AO with given error code. |
|
195 * @param "aError" Signalling error code. |
|
196 */ |
|
197 void Signal( TInt aError ); |
|
198 |
|
199 private: // from CActive |
|
200 |
|
201 /** |
|
202 * This is defined in CActive. Check CActive for description. |
|
203 */ |
|
204 void RunL(); |
|
205 |
|
206 /** |
|
207 * This is defined in CActive. Check CActive for description. |
|
208 */ |
|
209 void DoCancel(); |
|
210 |
|
211 /** |
|
212 * Rotate method called by the CAsyncCallBack. |
|
213 */ |
|
214 static TInt StaticRotate( TAny* aPtr ); |
|
215 |
|
216 /** |
|
217 * Rotate method called by the StaticScale. |
|
218 */ |
|
219 void DoRotate(); |
|
220 |
|
221 private: |
|
222 |
|
223 // Scaling observer |
|
224 MVtImageRotatorObserver& iObserver; |
|
225 |
|
226 // Bitmap that will be used for locking global bitmap heap |
|
227 CFbsBitmap* iHeapLock; // owned |
|
228 |
|
229 // Rotator implementation |
|
230 CVtImageRotatorImpl* iRotatorImpl; // owned |
|
231 |
|
232 // Asynccallback instance |
|
233 CAsyncCallBack* iAsyncCallBack; // owned |
|
234 |
|
235 // This is set to ETrue in DoCancel() method, and when CAsyncCallBack |
|
236 // gets executed, iCancelled is checked whether scaling should be done |
|
237 // or not. |
|
238 TBool iCancelled; |
|
239 }; |
|
240 |
|
241 #endif // CVTIMAGEROTATOR_H |
|
242 |
|
243 // End of File |
|
244 |
|
245 |