|
1 /* |
|
2 * Copyright (c) 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 Decoder class and observer interface. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CAM_IMAGEDECODER_H |
|
20 #define CAM_IMAGEDECODER_H |
|
21 |
|
22 // =========================================================================== |
|
23 // Included headers |
|
24 #include <e32std.h> |
|
25 #include <f32file.h> |
|
26 |
|
27 // =========================================================================== |
|
28 // Forward declarations |
|
29 class CFbsBitmap; |
|
30 class CImageDecoder; |
|
31 class MCameraBuffer; |
|
32 class CCamBufferShare; |
|
33 |
|
34 |
|
35 // =========================================================================== |
|
36 // Classes |
|
37 |
|
38 /** |
|
39 * Interface for Image Decoder Observers |
|
40 */ |
|
41 class MCamImageDecoderObserver |
|
42 { |
|
43 public: |
|
44 |
|
45 /** |
|
46 * Notify observer that the image decoding has finished. |
|
47 * @param aStatus Status code describing the success of the operation. |
|
48 * KErrNone if all went as planned. |
|
49 * @param aBitmap Decoded bitmap. NULL if errors in decoding. |
|
50 */ |
|
51 virtual void ImageDecoded( TInt aStatus, const CFbsBitmap* aBitmap ) = 0; |
|
52 |
|
53 }; |
|
54 |
|
55 |
|
56 /** |
|
57 * Image Decoder class |
|
58 */ |
|
59 class CCamImageDecoder : public CActive |
|
60 { |
|
61 // ======================================================= |
|
62 public: |
|
63 |
|
64 /** |
|
65 * 2-phase constructor. |
|
66 */ |
|
67 static CCamImageDecoder* NewL( MCamImageDecoderObserver& aObserver ); |
|
68 |
|
69 /** |
|
70 * Destructor. |
|
71 */ |
|
72 virtual ~CCamImageDecoder(); |
|
73 |
|
74 // ------------------------------------------------------- |
|
75 // From CActive |
|
76 protected: |
|
77 |
|
78 /** |
|
79 * Called when Cancel is requested and this AO is active. |
|
80 * @see CActive |
|
81 */ |
|
82 virtual void DoCancel(); |
|
83 |
|
84 /** |
|
85 * We get notified of the decoding success by a call to RunL |
|
86 * when decoding finishes. |
|
87 * @see CActive |
|
88 */ |
|
89 virtual void RunL(); |
|
90 |
|
91 /** |
|
92 * If a leave occurs in RunL, RunError gets called by the |
|
93 * Active Scheduler. |
|
94 * @param aError Leave code from RunL. |
|
95 * @see CActive |
|
96 */ |
|
97 virtual TInt RunError( TInt aError ); |
|
98 |
|
99 // ------------------------------------------------------- |
|
100 public: |
|
101 |
|
102 void StartConversionL( CCamBufferShare* aBuffer ); |
|
103 |
|
104 private: |
|
105 |
|
106 /** |
|
107 * Store the buffer and release any previous buffer. |
|
108 * Can be called with NULL to release current buffer. |
|
109 */ |
|
110 void SetImageData( CCamBufferShare* aBuffer ); |
|
111 |
|
112 /** |
|
113 * Get the image data in descriptor form. |
|
114 * No new memory is allocated to the returned buffer, |
|
115 * so ownership not transferred. |
|
116 * @return Pointer to image data that is to be used for image conversion. |
|
117 * If EXIF thumbnail is available, it is used, otherwise the |
|
118 * full image data is used instead. If the image data cannot be |
|
119 * read from the buffer, or the buffer has not been set, |
|
120 * leave will occur. |
|
121 * @leave KErrNotFound, if image buffer is not set or contains no image data. |
|
122 * Any other system error, e.g. KErrNoMemory. |
|
123 */ |
|
124 TDesC8* GetImageDataL(); |
|
125 |
|
126 /** |
|
127 * Read the EXIF thumbnail and return it in descriptor. |
|
128 * If any errors, return NULL. |
|
129 * @param aExifData The full image data containing EXIF part. |
|
130 * @return The EXIF thumbnail in a heap descriptor. NULL if |
|
131 * error occurs in reading (OOM, no data given, |
|
132 * no EXIF thumbnail found..). |
|
133 */ |
|
134 HBufC8* ReadExifThumbNail( const TDesC8& aExifData ); |
|
135 |
|
136 private: |
|
137 |
|
138 /** |
|
139 * 2nd phase constructor. |
|
140 */ |
|
141 void ConstructL(); |
|
142 |
|
143 /** |
|
144 * 1st phase constructor. |
|
145 * Cannot leave. |
|
146 */ |
|
147 CCamImageDecoder( MCamImageDecoderObserver& aObserver ); |
|
148 |
|
149 // ======================================================= |
|
150 // Data |
|
151 private: |
|
152 |
|
153 RFs iFs; |
|
154 MCamImageDecoderObserver& iObserver; |
|
155 |
|
156 |
|
157 CCamBufferShare* iSharedImageData; |
|
158 HBufC8* iThumbnailData; |
|
159 |
|
160 CFbsBitmap* iDecodedBitmap; |
|
161 CImageDecoder* iDecoder; |
|
162 |
|
163 TInt iRetryCounter; |
|
164 |
|
165 // ======================================================= |
|
166 }; |
|
167 |
|
168 // =========================================================================== |
|
169 #endif |
|
170 |
|
171 // end of file |