54
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-2010 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 |
class CSvgEngineInterfaceImpl;
|
|
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 ImageDecodedL( TInt aStatus, const CFbsBitmap* aBitmap, const CFbsBitmap* aMask ) = 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 |
void StartIconConversionL( TDesC* aFilePath, TSize& aSize );
|
|
105 |
|
|
106 |
private:
|
|
107 |
|
|
108 |
/**
|
|
109 |
* Store the buffer and release any previous buffer.
|
|
110 |
* Can be called with NULL to release current buffer.
|
|
111 |
*/
|
|
112 |
void SetImageData( CCamBufferShare* aBuffer );
|
|
113 |
|
|
114 |
/**
|
|
115 |
* Get the image data in descriptor form.
|
|
116 |
* No new memory is allocated to the returned buffer,
|
|
117 |
* so ownership not transferred.
|
|
118 |
* @return Pointer to image data that is to be used for image conversion.
|
|
119 |
* If EXIF thumbnail is available, it is used, otherwise the
|
|
120 |
* full image data is used instead. If the image data cannot be
|
|
121 |
* read from the buffer, or the buffer has not been set,
|
|
122 |
* leave will occur.
|
|
123 |
* @leave KErrNotFound, if image buffer is not set or contains no image data.
|
|
124 |
* Any other system error, e.g. KErrNoMemory.
|
|
125 |
*/
|
|
126 |
TDesC8* GetImageDataL();
|
|
127 |
|
|
128 |
/**
|
|
129 |
* Read the EXIF thumbnail and return it in descriptor.
|
|
130 |
* If any errors, return NULL.
|
|
131 |
* @param aExifData The full image data containing EXIF part.
|
|
132 |
* @return The EXIF thumbnail in a heap descriptor. NULL if
|
|
133 |
* error occurs in reading (OOM, no data given,
|
|
134 |
* no EXIF thumbnail found..).
|
|
135 |
*/
|
|
136 |
HBufC8* ReadExifThumbNail( const TDesC8& aExifData );
|
|
137 |
|
|
138 |
private:
|
|
139 |
|
|
140 |
/**
|
|
141 |
* 2nd phase constructor.
|
|
142 |
*/
|
|
143 |
void ConstructL();
|
|
144 |
|
|
145 |
/**
|
|
146 |
* 1st phase constructor.
|
|
147 |
* Cannot leave.
|
|
148 |
*/
|
|
149 |
CCamImageDecoder( MCamImageDecoderObserver& aObserver );
|
|
150 |
|
|
151 |
// =======================================================
|
|
152 |
// Data
|
|
153 |
private:
|
|
154 |
|
|
155 |
RFs iFs;
|
|
156 |
MCamImageDecoderObserver& iObserver;
|
|
157 |
CSvgEngineInterfaceImpl* iSvgEngine;
|
|
158 |
|
|
159 |
CCamBufferShare* iSharedImageData;
|
|
160 |
HBufC8* iThumbnailData;
|
|
161 |
|
|
162 |
CFbsBitmap* iDecodedBitmap;
|
|
163 |
CFbsBitmap* iDecodedMask;
|
|
164 |
CImageDecoder* iDecoder;
|
|
165 |
|
|
166 |
TInt iRetryCounter;
|
|
167 |
|
|
168 |
// =======================================================
|
|
169 |
};
|
|
170 |
|
|
171 |
// ===========================================================================
|
|
172 |
#endif
|
|
173 |
|
|
174 |
// end of file
|