|
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 CVTIMAGESCALER_H |
|
23 #define CVTIMAGESCALER_H |
|
24 |
|
25 // INCLUDE FILES |
|
26 |
|
27 #include <e32base.h> |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 |
|
31 class CVtImageScalerImpl; |
|
32 class CVtImage; |
|
33 class CFbsBitmap; |
|
34 |
|
35 // CLASS DECLARATIONS |
|
36 |
|
37 /** |
|
38 * Image scaler observer interface. |
|
39 * |
|
40 * @lib videosource.lib |
|
41 */ |
|
42 class MVtImageScalerObserver |
|
43 { |
|
44 public: |
|
45 /** |
|
46 * Callback method that is called by CVtImageScaler when scaling has |
|
47 * finished. |
|
48 * @param "aError" KErrNone if the scaling was done successfully, one |
|
49 * of the system wide error codes otherwise. |
|
50 * @return Pointer to newly created instance. |
|
51 */ |
|
52 virtual void ScalingFinished( TInt aError ) = 0; |
|
53 }; |
|
54 |
|
55 /** |
|
56 * Image scaler. |
|
57 * |
|
58 * @lib videosource.lib |
|
59 */ |
|
60 class CVtImageScaler : public CActive |
|
61 { |
|
62 public: |
|
63 |
|
64 /** |
|
65 * An enumeration within the CVtImageScaler namespace. |
|
66 * It provides a set of panic codes that may happen during |
|
67 * scaling process. |
|
68 */ |
|
69 enum TPanics |
|
70 { |
|
71 /** |
|
72 * RotateL() is called while previous rotation process |
|
73 * has not yet been finished. |
|
74 */ |
|
75 EBusy = 1 |
|
76 }; |
|
77 |
|
78 /** |
|
79 * An enumeration within the CVtImageScaler namespace. |
|
80 * It provides a set of supported scaling quality settings. |
|
81 */ |
|
82 enum TQuality |
|
83 { |
|
84 /** |
|
85 * Nearest neigbour algorithm. Fast but poor image quality |
|
86 * when scale factor exceeds 2x. |
|
87 */ |
|
88 ENearest, |
|
89 |
|
90 /** |
|
91 * Weighted average algorithm. Slower than Nearest Neighbour |
|
92 * but also better image quality when scaling at factor 2x or |
|
93 * higher. |
|
94 */ |
|
95 EWeightedAverage, |
|
96 |
|
97 /** |
|
98 * Bilinear scaling algorithm. Slower than Weighted Average |
|
99 * but also better image quality. |
|
100 */ |
|
101 EBilinear |
|
102 }; |
|
103 |
|
104 public: |
|
105 |
|
106 /** |
|
107 * Creates new instance of CVtImageScaler. |
|
108 * @param "aObserver" Reference to instance observer. |
|
109 * @param "aQuality" Scaling quality. If this is omitted, then default |
|
110 * value of EWeightedAverage is used. |
|
111 * @param "aPriority" Active object priority. |
|
112 * @exception In error situation leaves with one of the system wide |
|
113 * error codes. |
|
114 * @return Pointer to newly created instance. |
|
115 */ |
|
116 IMPORT_C static CVtImageScaler* NewL( |
|
117 MVtImageScalerObserver& aObserver, |
|
118 TQuality aQuality = EWeightedAverage, |
|
119 TPriority aPriority = EPriorityStandard ); |
|
120 |
|
121 /** |
|
122 * C++ destructor. |
|
123 */ |
|
124 IMPORT_C ~CVtImageScaler(); |
|
125 |
|
126 /** |
|
127 * Sets scaling quality. |
|
128 * @param "aQuality" Scaling quality. |
|
129 * @exception In error situation leaves with one of the system wide |
|
130 * error codes. |
|
131 */ |
|
132 IMPORT_C void SetQualityL( TQuality aQuality ); |
|
133 |
|
134 /** |
|
135 * Scales image to new size. |
|
136 * @param "aSource" Source image that will be scaled. |
|
137 * @param "aTarget" Target image that will hold the scaled image. New |
|
138 * image's dimensions |
|
139 * will be taken from the size of target image. |
|
140 * @exception In error situation leaves with one of the system wide |
|
141 * error codes. |
|
142 */ |
|
143 IMPORT_C void ScaleL( const CVtImage& aSource, CVtImage& aTarget ); |
|
144 |
|
145 /** |
|
146 * Scales image to new size. Possible error during initialization is |
|
147 * returned via MVtImageScalerObserver. |
|
148 * @param "aSource" Source image that will be scaled. |
|
149 * @param "aTarget" Target image that will hold the scaled image. New |
|
150 * image's dimensions will be taken from the size of target image. |
|
151 */ |
|
152 IMPORT_C void Scale( const CVtImage& aSource, CVtImage& aTarget ); |
|
153 |
|
154 /** |
|
155 * Scales image to new size. This scale method is synchronous and |
|
156 * aTarget will contain scaled image of aSource on return. This method |
|
157 * may leave if aSource and/or aTarget are not suitable for scaling. |
|
158 * MVtImageScalerObserver::ScalingFinished is not called when this |
|
159 * method is used. |
|
160 * @param "aSource" Source image that will be scaled. |
|
161 * @param "aTarget" Target image that will hold the scaled image. New |
|
162 * image's dimensions will be taken from the size of target image. |
|
163 */ |
|
164 IMPORT_C void ScaleNowL( const CVtImage& aSource, CVtImage& aTarget ); |
|
165 |
|
166 private: // internal |
|
167 |
|
168 /** |
|
169 * C++ default constructor. |
|
170 */ |
|
171 CVtImageScaler(); |
|
172 |
|
173 /** |
|
174 * C++ constructor. |
|
175 * @param "aObserver" Reference to observer. |
|
176 * @param "aPriority" Active object priority. |
|
177 * @exception In error situation leaves with one of the system wide |
|
178 * error codes. |
|
179 */ |
|
180 CVtImageScaler( MVtImageScalerObserver& aObserver, TPriority aPriority ); |
|
181 |
|
182 /** |
|
183 * Second phase constructor. |
|
184 * @param "aQuality" Quality of the scaling. |
|
185 * @exception In error situation leaves with one of the system wide |
|
186 * error codes. |
|
187 */ |
|
188 void ConstructL( TQuality aQuality ); |
|
189 |
|
190 /** |
|
191 * Sets iStatus to KRequestPending and calls CActive::SetActive(). |
|
192 */ |
|
193 void Activate(); |
|
194 |
|
195 /** |
|
196 * Signals this instance AO with given error code. |
|
197 * @param "aError" Signalling error code. |
|
198 */ |
|
199 void Signal( TInt aError ); |
|
200 |
|
201 private: // from CActive |
|
202 |
|
203 /** |
|
204 * This is defined in CActive. Check CActive for description. |
|
205 */ |
|
206 void RunL(); |
|
207 |
|
208 /** |
|
209 * This is defined in CActive. Check CActive for description. |
|
210 */ |
|
211 void DoCancel(); |
|
212 |
|
213 /** |
|
214 * Scale method called by the CAsyncCallBack. |
|
215 */ |
|
216 static TInt StaticScale( TAny* aPtr ); |
|
217 |
|
218 /** |
|
219 * Scale method called by the StaticScale. |
|
220 */ |
|
221 void DoScale(); |
|
222 |
|
223 private: |
|
224 |
|
225 // Scaling observer |
|
226 MVtImageScalerObserver& iObserver; |
|
227 |
|
228 // Active quality implementation |
|
229 CVtImageScalerImpl* iScalerImpl; // owned |
|
230 |
|
231 // Bitmap that will be used for locking global bitmap heap |
|
232 CFbsBitmap* iHeapLock; // owned |
|
233 |
|
234 // Asynccallback instance |
|
235 CAsyncCallBack* iAsyncCallBack; // owned |
|
236 |
|
237 // This is set to ETrue in DoCancel() method, and when CAsyncCallBack |
|
238 // gets executed, iCancelled is checked whether scaling should be done |
|
239 // or not. |
|
240 TBool iCancelled; |
|
241 }; |
|
242 |
|
243 #endif // CVTIMAGESCALER_H |
|
244 |
|
245 // End of File |
|
246 |
|
247 |