1 /* |
|
2 * Copyright (c) 2006-2007 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 thumbnail decoder. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef THUMBNAILIMAGEDECODER_H |
|
20 #define THUMBNAILIMAGEDECODER_H |
|
21 |
|
22 #include "thumbnailprovider.h" |
|
23 |
|
24 class CImageDecoder; |
|
25 class CFbsBitmap; |
|
26 |
|
27 // Size of buffer to load from file start to get EXIF thumbnail |
|
28 const TInt KJpegLoadBufferSize = 64 * 1024; |
|
29 |
|
30 |
|
31 /** |
|
32 * Image thumbnail decoder. |
|
33 * |
|
34 * @since S60 v5.0 |
|
35 */ |
|
36 class CThumbnailImageDecoder: public CActive |
|
37 { |
|
38 public: |
|
39 |
|
40 /** |
|
41 * C++ default constructor |
|
42 * |
|
43 * @since S60 v5.0 |
|
44 * @param aFs File server session |
|
45 * @return New image thumbnail decoder instance. |
|
46 */ |
|
47 CThumbnailImageDecoder( RFs& aFs ); |
|
48 |
|
49 /** |
|
50 * Destructor |
|
51 * |
|
52 * @since S60 v5.0 |
|
53 */ |
|
54 virtual ~CThumbnailImageDecoder(); |
|
55 |
|
56 /** |
|
57 * Creates a decoder from the given image file and gets image |
|
58 * information |
|
59 * |
|
60 * @since S60 v5.0 |
|
61 * @param aFile Source image file. |
|
62 * @param aObserver Observer to relay notifications about completed |
|
63 * operations. |
|
64 * @param aFlags Decoding option flags. |
|
65 * @param aMimeType Mime-type of image to be decoded. |
|
66 * @param aSize desired size of thumbnail. |
|
67 * @param aRotateIfNeeded If ETrue rectangle is rotated to maximize the decoded size (full screen images only) |
|
68 */ |
|
69 void CreateL( RFile64& aFile, MThumbnailProviderObserver& aObserver, const |
|
70 CThumbnailManager::TThumbnailQualityPreference aFlags, const TDataType& aMimeType, |
|
71 const TSize& aSize ); |
|
72 |
|
73 /** |
|
74 * Creates a decoder from the given image buffer and gets image |
|
75 * information |
|
76 * |
|
77 * @since S60 v5.0 |
|
78 * @param aBuffer Source image buffer. |
|
79 * @param aObserver Observer to relay notifications about completed |
|
80 * operations. |
|
81 * @param aFlags Decoding option flags. |
|
82 * @param aMimeType Mime-type of image to be decoded. |
|
83 * @param aSize desired size of thumbnail. |
|
84 * @param aRotateIfNeeded If ETrue rectangle is rotated to maximize the decoded size (full screen images only) |
|
85 */ |
|
86 void CreateL( const TDesC8* aBuffer, MThumbnailProviderObserver& |
|
87 aObserver, const CThumbnailManager::TThumbnailQualityPreference aFlags, const |
|
88 TDataType& aMimeType, const TSize& aSize); |
|
89 |
|
90 /** |
|
91 * Decode image. |
|
92 * |
|
93 * @since S60 v5.0 |
|
94 * @param aDisplayMode Preferred display mode. |
|
95 */ |
|
96 void DecodeL( const TDisplayMode aDisplayMode, const CThumbnailManager::TThumbnailFlags aFlags ); |
|
97 |
|
98 /** |
|
99 * Returns the size of original image. |
|
100 * |
|
101 * @since S60 v5.0 |
|
102 * @return Size of original image. |
|
103 */ |
|
104 const TSize& OriginalSize()const; |
|
105 |
|
106 /** |
|
107 * Leave if image is corrupt |
|
108 * |
|
109 * @since S60 v5.0 |
|
110 */ |
|
111 void LeaveIfCorruptL(const TInt aError ); |
|
112 |
|
113 private: |
|
114 /** |
|
115 * Used to release reserved resources. |
|
116 * |
|
117 * @since S60 v5.0 |
|
118 */ |
|
119 void Release(); |
|
120 |
|
121 /** |
|
122 * Implements cancellation of an outstanding request. |
|
123 * |
|
124 * @since S60 v5.0 |
|
125 */ |
|
126 void DoCancel(); |
|
127 |
|
128 /** |
|
129 * Handles an active object's request completion event. |
|
130 * |
|
131 * @since S60 v5.0 |
|
132 */ |
|
133 void RunL(); |
|
134 |
|
135 /** |
|
136 * Used to check if source is jpg/jpeg image. |
|
137 * |
|
138 * @since S60 v5.0 |
|
139 * @return ETrue if image was jpg/jpeg format, otherwise EFalse |
|
140 */ |
|
141 TBool IsJpeg(); |
|
142 |
|
143 /** |
|
144 * Used to check if source is svg image. |
|
145 * |
|
146 * @since S60 v5.0 |
|
147 * @return ETrue if image was in svg format, otherwise EFalse |
|
148 */ |
|
149 TBool IsSvg(); |
|
150 |
|
151 /** |
|
152 * Creates image decoder to be used. |
|
153 * |
|
154 * @since S60 v5.0 |
|
155 */ |
|
156 void CreateDecoderL( CThumbnailManager::TThumbnailQualityPreference aFlags ); |
|
157 |
|
158 /** |
|
159 * Creates ExifDecoder. |
|
160 * |
|
161 * @since S60 v5.0 |
|
162 */ |
|
163 void CreateExifDecoderL( CThumbnailManager::TThumbnailQualityPreference aFlags ); |
|
164 |
|
165 private: |
|
166 // data |
|
167 |
|
168 /** |
|
169 * Requested size. |
|
170 */ |
|
171 TSize iSize; |
|
172 |
|
173 /** |
|
174 * Image decoder. |
|
175 * Own. |
|
176 */ |
|
177 CImageDecoder* iDecoder; |
|
178 |
|
179 /** |
|
180 * Decoded bitmap. |
|
181 * Own. |
|
182 */ |
|
183 CFbsBitmap* iBitmap; |
|
184 |
|
185 /** |
|
186 * Image info flags (from TFrameInfo) |
|
187 */ |
|
188 TUint32 iFrameInfoFlags; |
|
189 |
|
190 /** |
|
191 * Original size of the image in pixels. |
|
192 */ |
|
193 TSize iOriginalSize; |
|
194 |
|
195 /** |
|
196 * Buffer for reading the beginning of a JPEG file to get the |
|
197 * EXIF thumbnail data. |
|
198 */ |
|
199 HBufC8* iJpegReadBuffer; |
|
200 |
|
201 /** |
|
202 * EXIF thumbnail image compressed as JPEG |
|
203 */ |
|
204 HBufC8* iExifThumbImage; |
|
205 |
|
206 /** |
|
207 * Used fileserver. |
|
208 */ |
|
209 RFs& iFs; |
|
210 |
|
211 /** |
|
212 * File from which thumbnail is to be created. |
|
213 */ |
|
214 RFile64 iFile; |
|
215 |
|
216 /** |
|
217 * Buffer from which thumbnail is to be created. |
|
218 */ |
|
219 const TDesC8* iBuffer; |
|
220 |
|
221 /** |
|
222 * Observer. |
|
223 */ |
|
224 MThumbnailProviderObserver* iObserver; // not own |
|
225 |
|
226 /** |
|
227 * Mime-type. |
|
228 */ |
|
229 TDataType iMimeType; |
|
230 |
|
231 /** |
|
232 * Is origin EXIF |
|
233 */ |
|
234 TBool iEXIF; |
|
235 |
|
236 /** |
|
237 * Portrait image |
|
238 */ |
|
239 TBool iPortrait; |
|
240 }; |
|
241 |
|
242 #endif // THUMBNAILIMAGEDECODER_H |
|