1 /* |
|
2 * Copyright (c) 2006 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: Implementation of ImageFile class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CIHLFILEIMAGEEXTJPG_H |
|
20 #define CIHLFILEIMAGEEXTJPG_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <imageconversion.h> // TFrameInfo |
|
25 #include <gdi.h> // TDisplayMode |
|
26 #include "MIHLFileImageExtJpg.h" |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 class MIHLBitmap; |
|
30 class CIHLBitmap; |
|
31 class CExtJpegDecoder; |
|
32 class CVisualFrame; |
|
33 |
|
34 // CLASS DECLARATION |
|
35 /** |
|
36 * CIHLFileImageExtJpg |
|
37 * |
|
38 * Implementation of file based ext jpg image class. |
|
39 * @lib IHL.lib |
|
40 * @since 3.0 |
|
41 */ |
|
42 |
|
43 NONSHARABLE_CLASS( CIHLFileImageExtJpg ) : public CActive, public MIHLFileImageExtJpg |
|
44 { |
|
45 public: // Constructors and destructor |
|
46 |
|
47 /** |
|
48 * Two-phased constructor. |
|
49 */ |
|
50 static CIHLFileImageExtJpg* NewL( RFs& aFs, const TDesC8& aDataBuf, |
|
51 TInt aImageIndex, const TUint32 aOptions ); |
|
52 static CIHLFileImageExtJpg* NewL( RFs& aFs, const TDesC& aFilename, |
|
53 TInt aImageIndex, const TUint32 aOptions ); |
|
54 /* |
|
55 * Virtual destructor. |
|
56 */ |
|
57 virtual ~CIHLFileImageExtJpg(); |
|
58 |
|
59 public: // From base class MIHLImage |
|
60 |
|
61 TIHLInterfaceType Type() const; |
|
62 |
|
63 public: // From base class MIHLFileImage |
|
64 |
|
65 /* |
|
66 * From MIHLFileImage, see base class header. |
|
67 */ |
|
68 const TUid& ImageType() const; |
|
69 |
|
70 /* |
|
71 * From MIHLFileImage, see base class header. |
|
72 */ |
|
73 const TUid& ImageSubType() const; |
|
74 |
|
75 /* |
|
76 * From MIHLFileImage, see base class header. |
|
77 */ |
|
78 TInt ImageIndex() const; |
|
79 |
|
80 /* |
|
81 * From MIHLFileImage, see base class header. |
|
82 */ |
|
83 TInt ImageCount() const; |
|
84 |
|
85 /* |
|
86 * From MIHLFileImage, see base class header. |
|
87 */ |
|
88 TSize Size() const; |
|
89 |
|
90 /* |
|
91 * From MIHLFileImage, see base class header. |
|
92 */ |
|
93 TDisplayMode DisplayMode() const; |
|
94 |
|
95 /* |
|
96 * From MIHLFileImage, see base class header. |
|
97 */ |
|
98 TDisplayMode MaskDisplayMode() const; |
|
99 |
|
100 /* |
|
101 * From MIHLFileImage, see base class header. |
|
102 */ |
|
103 TRgb BackgroundColor() const; |
|
104 |
|
105 /* |
|
106 * From MIHLFileImage, see base class header. |
|
107 */ |
|
108 const RArray<TSize>& CustomLoadSizeArray() const; |
|
109 |
|
110 /* |
|
111 * From MIHLFileImage, see base class header. |
|
112 */ |
|
113 TBool IsFullyScaleable() const; |
|
114 |
|
115 /* |
|
116 * From MIHLFileImage, see base class header. |
|
117 */ |
|
118 TBool IsAnimation() const; |
|
119 |
|
120 /* |
|
121 * From MIHLFileImage, see base class header. |
|
122 */ |
|
123 TInt AnimationFrameCount() const; |
|
124 |
|
125 /* |
|
126 * From MIHLFileImage, see base class header. |
|
127 */ |
|
128 TTimeIntervalMicroSeconds32 AnimationFrameDelay( TInt aAnimationFrameIndex ) const; |
|
129 |
|
130 /* |
|
131 * From MIHLFileImage, see base class header. |
|
132 */ |
|
133 TInt Load( TRequestStatus& aStatus, MIHLBitmap& aDestination, TInt aFrameIndex = 0 ); |
|
134 |
|
135 /* |
|
136 * From MIHLFileImage, see base class header. |
|
137 */ |
|
138 TInt LoadAnimation( TRequestStatus& aStatus, MIHLBitmap& aDestination, TInt aAnimationFrameIndex ); |
|
139 |
|
140 /* |
|
141 * From MIHLFileImage, see base class header. |
|
142 */ |
|
143 TBool IsBusy() const; |
|
144 |
|
145 /* |
|
146 * From MIHLFileImage, see base class header. |
|
147 */ |
|
148 void CancelLoad(); |
|
149 |
|
150 /* |
|
151 * From MIHLFileImage, see base class header. |
|
152 */ |
|
153 void SetFilter( MIHLFilter* aFilter ); |
|
154 |
|
155 public: // From MIHLFileImageExtJpg |
|
156 |
|
157 /* |
|
158 * From MIHLFileImageExtJpg, see base class header. |
|
159 */ |
|
160 TInt Load( TRect aSrcRect, TRequestStatus& aStatus, MIHLBitmap& aDestination, TInt aFrameIndex = 0 ); |
|
161 |
|
162 /* |
|
163 * From MIHLFileImageExtJpg, see base class header. |
|
164 */ |
|
165 void SetCroppingL( TRect aCropRect ); |
|
166 |
|
167 /* |
|
168 * From MIHLFileImageExtJpg, see base class header. |
|
169 */ |
|
170 void SetStreamingL( TSize& aMacroBlockSize ); |
|
171 |
|
172 /* |
|
173 * From MIHLFileImageExtJpg, see base class header. |
|
174 */ |
|
175 void SetRotationL( TInt aDegree ); |
|
176 |
|
177 /* |
|
178 * From MIHLFileImageExtJpg, see base class header. |
|
179 */ |
|
180 void SetFlippingL(); |
|
181 |
|
182 /* |
|
183 * From MIHLFileImageExtJpg, see base class header. |
|
184 */ |
|
185 void SetMirroringL(); |
|
186 |
|
187 /* |
|
188 * From MIHLFileImageExtJpg, see base class header. |
|
189 */ |
|
190 void SetDctDecodingL(); |
|
191 |
|
192 /* |
|
193 * From MIHLFileImageExtJpg, see base class header. |
|
194 */ |
|
195 void ConvertL( |
|
196 TRequestStatus* aRequestStatus, |
|
197 const CVisualFrame* aDestinationFrame, |
|
198 TInt& aNoOfDecodedMBlocks, |
|
199 TInt aFrameNumber = 0 ); |
|
200 |
|
201 /* |
|
202 * From MIHLFileImageExtJpg, see base class header. |
|
203 */ |
|
204 void ContinueConvertL( |
|
205 TRequestStatus* aRequestStatus, |
|
206 const CVisualFrame* aDestinationFrame, |
|
207 TInt& aNoOfDecodedMBlocks, |
|
208 TInt aFrameNumber = 0 ); |
|
209 |
|
210 /* |
|
211 * From MIHLFileImageExtJpg, see base class header. |
|
212 */ |
|
213 TInt SupportedFormatsL(); |
|
214 |
|
215 /* |
|
216 * From MIHLFileImageExtJpg, see base class header. |
|
217 */ |
|
218 TInt CapabilitiesL(); |
|
219 |
|
220 private: // From base class CActive |
|
221 |
|
222 /* |
|
223 * From CActive, see base class header. |
|
224 */ |
|
225 void DoCancel(); |
|
226 |
|
227 /* |
|
228 * From CActive, see base class header. |
|
229 */ |
|
230 void RunL(); |
|
231 |
|
232 /* |
|
233 * From CActive, see base class header. |
|
234 */ |
|
235 TInt RunError( TInt aError ); |
|
236 |
|
237 public: // Internal interface |
|
238 |
|
239 /** |
|
240 * Return reference to used CExtJpegDecoder instance. |
|
241 * For internal use. |
|
242 * @since 3.0 |
|
243 * @return Reference to used CExtJpegDecoder instance. |
|
244 */ |
|
245 const CExtJpegDecoder& Decoder() const; |
|
246 |
|
247 private: // Private methods |
|
248 |
|
249 /* |
|
250 * Request load and start ActiveScheduler. |
|
251 * Called from Load() and LoadAnimation() methods. |
|
252 */ |
|
253 TInt LoadRequest( TRequestStatus& aStatus, MIHLBitmap& aDestination, TInt aFrameIndex ); |
|
254 |
|
255 /* |
|
256 * Start loading from file. Checks if image is still or animation. |
|
257 * Called by ActiveSheduler when state is EStartLoad. |
|
258 */ |
|
259 void StartLoadL(); |
|
260 |
|
261 /* |
|
262 * Loading complete. Build possible animation and notify client. |
|
263 * Called by ActiveSheduler when state is ECompleteLoad. |
|
264 */ |
|
265 void CompleteLoadL(); |
|
266 |
|
267 /* |
|
268 * Error cleanup. Called if error occurs during load. |
|
269 */ |
|
270 void ErrorCleanup(); |
|
271 |
|
272 /* |
|
273 * Complete dummy request. This causes RunL() method to be called. |
|
274 * Needed by state machine. |
|
275 */ |
|
276 void SelfComplete(); |
|
277 |
|
278 /* |
|
279 * Complete client load request. |
|
280 * This causes client RunL() method to be called. |
|
281 */ |
|
282 void RequestComplete( TInt aReason ); |
|
283 |
|
284 private: // Private constructors |
|
285 |
|
286 CIHLFileImageExtJpg( TInt aImageIndex ); |
|
287 |
|
288 void ConstructL( RFs& aFs, const TDesC& aFilename, const TUint32 aOptions ); |
|
289 void ConstructL( RFs& aFs, const TDesC8& aDataBuf, const TUint32 aOptions ); |
|
290 void ConstructCommonL(); |
|
291 |
|
292 private: // Private data types |
|
293 |
|
294 enum TImageState |
|
295 { |
|
296 EInactive, |
|
297 EStartLoad, |
|
298 ECompleteLoad, |
|
299 }; |
|
300 |
|
301 private: // Data |
|
302 |
|
303 // Ref: Image status & state |
|
304 TRequestStatus* iImageStatus; |
|
305 TImageState iImageState; |
|
306 |
|
307 // Own: Image decoder |
|
308 CExtJpegDecoder* iDecoder; |
|
309 |
|
310 // Image information |
|
311 TUid iImageType; |
|
312 TUid iImageSubType; |
|
313 TInt iImageIndex; |
|
314 TInt iImageCount; |
|
315 |
|
316 TBool iFullyScaleable; |
|
317 TFrameInfo iFrameInfo; |
|
318 TBool iAnimation; |
|
319 TInt iAnimationFrameCount; |
|
320 |
|
321 // Ref: Destination bitmap |
|
322 CIHLBitmap* iDestination; |
|
323 TInt iFrameIndex; |
|
324 |
|
325 RArray<TSize> iLoadSizeArray; |
|
326 }; |
|
327 |
|
328 #endif // CIHLFILEIMAGEEXTJPG_H |
|
329 |
|
330 // End of File |
|