williamr@2
|
1 |
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
2 |
// All rights reserved.
|
williamr@2
|
3 |
// This component and the accompanying materials are made available
|
williamr@4
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
williamr@2
|
5 |
// which accompanies this distribution, and is available
|
williamr@4
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
williamr@2
|
7 |
//
|
williamr@2
|
8 |
// Initial Contributors:
|
williamr@2
|
9 |
// Nokia Corporation - initial contribution.
|
williamr@2
|
10 |
//
|
williamr@2
|
11 |
// Contributors:
|
williamr@2
|
12 |
//
|
williamr@2
|
13 |
// Description:
|
williamr@2
|
14 |
//
|
williamr@2
|
15 |
|
williamr@2
|
16 |
#ifndef __IMAGECODEC_H__
|
williamr@2
|
17 |
#define __IMAGECODEC_H__
|
williamr@2
|
18 |
|
williamr@2
|
19 |
#include <e32std.h>
|
williamr@2
|
20 |
#include <fbs.h>
|
williamr@2
|
21 |
|
williamr@4
|
22 |
#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
|
williamr@4
|
23 |
#include <icl/imagecodecdef.h>
|
williamr@4
|
24 |
#endif
|
williamr@4
|
25 |
|
williamr@2
|
26 |
// Pre-definitions needed to make sure everything always defined in the right order
|
williamr@2
|
27 |
class TFrameInfo;
|
williamr@2
|
28 |
class TImageDataBlock;
|
williamr@2
|
29 |
class CFrameImageData;
|
williamr@2
|
30 |
|
williamr@2
|
31 |
class CImageDecoder;
|
williamr@2
|
32 |
class CImageEncoder;
|
williamr@2
|
33 |
class CImageProcessor;
|
williamr@2
|
34 |
class CImageProcessorReadCodecBody;
|
williamr@2
|
35 |
class CImageMaskProcessorReadCodecBody;
|
williamr@2
|
36 |
|
williamr@2
|
37 |
/**
|
williamr@2
|
38 |
@publishedAll
|
williamr@2
|
39 |
@released
|
williamr@2
|
40 |
|
williamr@2
|
41 |
Indicates what processing has so far been completed on the frame.
|
williamr@2
|
42 |
*/
|
williamr@2
|
43 |
enum TFrameState
|
williamr@2
|
44 |
{
|
williamr@2
|
45 |
/** Processing incomplete.
|
williamr@2
|
46 |
*/
|
williamr@2
|
47 |
EFrameIncomplete,
|
williamr@2
|
48 |
/** Processing complete.
|
williamr@2
|
49 |
*/
|
williamr@2
|
50 |
EFrameComplete,
|
williamr@2
|
51 |
/** Unexpected end of frame data.
|
williamr@2
|
52 |
*/
|
williamr@2
|
53 |
EUnexpectedEndOfData,
|
williamr@2
|
54 |
/** Same as EFrameIncomplete but also requests a call to CImageReadCodec::GetNewDataPosition().
|
williamr@2
|
55 |
*/
|
williamr@2
|
56 |
EFrameIncompleteRepositionRequest,
|
williamr@2
|
57 |
/** Processing of streaming block is complete.
|
williamr@2
|
58 |
*/
|
williamr@2
|
59 |
EBlockComplete
|
williamr@2
|
60 |
};
|
williamr@2
|
61 |
|
williamr@2
|
62 |
/**
|
williamr@2
|
63 |
@publishedAll
|
williamr@2
|
64 |
@released
|
williamr@2
|
65 |
|
williamr@2
|
66 |
Utility class to allow forward iteration through the data contained in
|
williamr@2
|
67 |
an 8 bit descriptor.
|
williamr@2
|
68 |
|
williamr@2
|
69 |
@see TPtr8
|
williamr@2
|
70 |
@see TPtrC8
|
williamr@2
|
71 |
@see TDes8
|
williamr@2
|
72 |
@see TDesC8
|
williamr@2
|
73 |
*/
|
williamr@2
|
74 |
class TBufPtr8 : public TPtr8
|
williamr@2
|
75 |
{
|
williamr@2
|
76 |
public:
|
williamr@2
|
77 |
/**
|
williamr@2
|
78 |
Default constructor.
|
williamr@2
|
79 |
*/
|
williamr@2
|
80 |
TBufPtr8()
|
williamr@2
|
81 |
: TPtr8(0, 0, 0) {};
|
williamr@2
|
82 |
inline void Set(const TDes8& aDes);
|
williamr@2
|
83 |
inline void SetLengthOnly(const TDes8& aDes);
|
williamr@2
|
84 |
inline void Set(const TPtrC8& aDes);
|
williamr@2
|
85 |
inline void Shift(TInt aOffset);
|
williamr@2
|
86 |
};
|
williamr@2
|
87 |
|
williamr@2
|
88 |
/**
|
williamr@2
|
89 |
Produces a shallow copy of the argument descriptor.
|
williamr@2
|
90 |
|
williamr@2
|
91 |
@param aDes
|
williamr@2
|
92 |
A reference to the descriptor containing the relevant data.
|
williamr@2
|
93 |
*/
|
williamr@2
|
94 |
inline void TBufPtr8::Set(const TDes8& aDes)
|
williamr@2
|
95 |
{
|
williamr@2
|
96 |
TPtr8::Set(CONST_CAST(TUint8*,aDes.Ptr()), aDes.Length(), aDes.MaxLength());
|
williamr@2
|
97 |
}
|
williamr@2
|
98 |
|
williamr@2
|
99 |
/**
|
williamr@2
|
100 |
Produces a shallow copy of the argument descriptor, but also restricts
|
williamr@2
|
101 |
pointer access to the current actual size of the argument descriptor.
|
williamr@2
|
102 |
|
williamr@2
|
103 |
@param aDes
|
williamr@2
|
104 |
A reference to the descriptor containing the relevant data.
|
williamr@2
|
105 |
*/
|
williamr@2
|
106 |
inline void TBufPtr8::SetLengthOnly(const TDes8& aDes)
|
williamr@2
|
107 |
{
|
williamr@2
|
108 |
TPtr8::Set(CONST_CAST(TUint8*,aDes.Ptr()), aDes.Length(), aDes.Length());
|
williamr@2
|
109 |
}
|
williamr@2
|
110 |
/**
|
williamr@2
|
111 |
Produces a shallow copy of the argument descriptor, but restricts
|
williamr@2
|
112 |
pointer access to the size of the const argument descriptor.
|
williamr@2
|
113 |
|
williamr@2
|
114 |
@param aDes
|
williamr@2
|
115 |
A reference to the descriptor containing the relevant data.
|
williamr@2
|
116 |
*/
|
williamr@2
|
117 |
inline void TBufPtr8::Set(const TPtrC8& aDes)
|
williamr@2
|
118 |
{
|
williamr@2
|
119 |
TPtr8::Set(CONST_CAST(TUint8*,aDes.Ptr()), aDes.Length(), aDes.Length());
|
williamr@2
|
120 |
}
|
williamr@2
|
121 |
/**
|
williamr@2
|
122 |
Seeks the current data pointer aOffset bytes from the current position.
|
williamr@2
|
123 |
|
williamr@2
|
124 |
@param aOffset
|
williamr@2
|
125 |
The number of bytes by which to seek.
|
williamr@2
|
126 |
*/
|
williamr@2
|
127 |
inline void TBufPtr8::Shift(TInt aOffset)
|
williamr@2
|
128 |
{
|
williamr@2
|
129 |
SetLength(Length() - aOffset); iMaxLength -= aOffset; iPtr += aOffset;
|
williamr@2
|
130 |
}
|
williamr@2
|
131 |
|
williamr@2
|
132 |
/**
|
williamr@2
|
133 |
@publishedAll
|
williamr@2
|
134 |
@released
|
williamr@2
|
135 |
|
williamr@2
|
136 |
Provides read related processing functions for bitmaps.
|
williamr@2
|
137 |
|
williamr@2
|
138 |
Note: For use by plugin writers only.
|
williamr@2
|
139 |
*/
|
williamr@2
|
140 |
class CImageReadCodec : public CBase
|
williamr@2
|
141 |
{
|
williamr@2
|
142 |
public:
|
williamr@2
|
143 |
IMPORT_C ~CImageReadCodec();
|
williamr@2
|
144 |
|
williamr@2
|
145 |
/**
|
williamr@2
|
146 |
Performs initial processing of image data and mask bitmaps.
|
williamr@2
|
147 |
|
williamr@2
|
148 |
This function processes the image frame using data supplied in
|
williamr@2
|
149 |
aFrameInfo, aFrameImageData and using the flag aDisableErrorDiffusion. Not all codecs
|
williamr@2
|
150 |
are expected to make use of all fields.
|
williamr@2
|
151 |
|
williamr@2
|
152 |
This is a virtual function that each derived class must implement.
|
williamr@2
|
153 |
|
williamr@2
|
154 |
@param aFrameInfo
|
williamr@2
|
155 |
A reference to a TFrameInfo object.
|
williamr@2
|
156 |
@param aFrameImageData
|
williamr@2
|
157 |
A reference to a CFrameImageData object.
|
williamr@2
|
158 |
@param aDisableErrorDiffusion
|
williamr@2
|
159 |
A flag indicating whether error diffusion should be disabled.
|
williamr@2
|
160 |
@param aDestination
|
williamr@2
|
161 |
The destination bitmap.
|
williamr@2
|
162 |
@param aDestinationMask
|
williamr@2
|
163 |
The destination mask bitmap.
|
williamr@2
|
164 |
*/
|
williamr@2
|
165 |
virtual void InitFrameL(TFrameInfo& aFrameInfo, CFrameImageData& aFrameImageData, TBool aDisableErrorDiffusion, CFbsBitmap& aDestination, CFbsBitmap* aDestinationMask) = 0;
|
williamr@2
|
166 |
|
williamr@2
|
167 |
IMPORT_C virtual void InitFrameHeader(TFrameInfo& aFrameInfo, CFrameImageData& aFrameData);
|
williamr@2
|
168 |
IMPORT_C virtual TFrameState ProcessFrameHeaderL(TBufPtr8& aData);
|
williamr@2
|
169 |
IMPORT_C virtual void Complete(); // Called on frame completion and on underflow
|
williamr@2
|
170 |
IMPORT_C virtual void GetNewDataPosition(TInt& aPosition, TInt& aLength); // Returns a new position for the data stream, (also length of data required)
|
williamr@2
|
171 |
|
williamr@2
|
172 |
/**
|
williamr@2
|
173 |
Processes the frame data contained in aSrc.
|
williamr@2
|
174 |
|
williamr@2
|
175 |
This is a pure virtual function that each derived class must implement.
|
williamr@2
|
176 |
|
williamr@2
|
177 |
@param aSrc
|
williamr@2
|
178 |
A reference to the buffer containing the frame data.
|
williamr@2
|
179 |
|
williamr@2
|
180 |
@return The current frame state after processing.
|
williamr@2
|
181 |
*/
|
williamr@2
|
182 |
virtual TFrameState ProcessFrameL(TBufPtr8& aSrc) = 0;
|
williamr@2
|
183 |
void SetCurrentFrame(TInt aFrameNumber);
|
williamr@2
|
184 |
|
williamr@2
|
185 |
IMPORT_C virtual TInt ReductionFactor(const TSize& aOriginalSize, const TSize& aReducedSize) const;
|
williamr@2
|
186 |
IMPORT_C virtual TInt ReducedSize(const TSize& aOriginalSize,TInt aReductionFactor, TSize& aReducedSize) const;
|
williamr@2
|
187 |
|
williamr@2
|
188 |
protected:
|
williamr@2
|
189 |
IMPORT_C CImageReadCodec();
|
williamr@2
|
190 |
IMPORT_C void ConstructL();
|
williamr@2
|
191 |
|
williamr@2
|
192 |
IMPORT_C void ClearBitmapL(CFbsBitmap& aBitmap, TRgb aColor);
|
williamr@2
|
193 |
IMPORT_C TInt CurrentFrame() const;
|
williamr@2
|
194 |
|
williamr@2
|
195 |
private:
|
williamr@2
|
196 |
// Future proofing
|
williamr@2
|
197 |
IMPORT_C virtual void ReservedVirtual1();
|
williamr@2
|
198 |
IMPORT_C virtual void ReservedVirtual2();
|
williamr@2
|
199 |
IMPORT_C virtual void ReservedVirtual3();
|
williamr@2
|
200 |
IMPORT_C virtual void ReservedVirtual4();
|
williamr@2
|
201 |
|
williamr@2
|
202 |
private:
|
williamr@2
|
203 |
TInt iCurrentFrame; //make handle to body if additional properties are needed
|
williamr@2
|
204 |
};
|
williamr@2
|
205 |
|
williamr@2
|
206 |
/**
|
williamr@2
|
207 |
@publishedAll
|
williamr@2
|
208 |
@released
|
williamr@2
|
209 |
|
williamr@2
|
210 |
Provides functions to determine or set features of the codec's CImageProcessor.
|
williamr@2
|
211 |
|
williamr@2
|
212 |
Note:
|
williamr@2
|
213 |
For use by plugin writers only.
|
williamr@2
|
214 |
*/
|
williamr@2
|
215 |
class CImageProcessorReadCodec : public CImageReadCodec
|
williamr@2
|
216 |
{
|
williamr@2
|
217 |
public:
|
williamr@2
|
218 |
IMPORT_C ~CImageProcessorReadCodec();
|
williamr@2
|
219 |
protected:
|
williamr@2
|
220 |
IMPORT_C CImageProcessorReadCodec();
|
williamr@2
|
221 |
IMPORT_C void ConstructL();
|
williamr@2
|
222 |
|
williamr@2
|
223 |
IMPORT_C CImageProcessor* ImageProcessor() const;
|
williamr@2
|
224 |
IMPORT_C void SetImageProcessor(CImageProcessor* aImageProc);
|
williamr@2
|
225 |
|
williamr@2
|
226 |
IMPORT_C const TPoint& Pos() const;
|
williamr@2
|
227 |
IMPORT_C TPoint& Pos();
|
williamr@2
|
228 |
IMPORT_C void SetPos(const TPoint& aPos);
|
williamr@2
|
229 |
private:
|
williamr@2
|
230 |
CImageProcessorReadCodecBody* iBody;
|
williamr@2
|
231 |
};
|
williamr@2
|
232 |
|
williamr@2
|
233 |
/**
|
williamr@2
|
234 |
@publishedAll
|
williamr@2
|
235 |
@released
|
williamr@2
|
236 |
|
williamr@2
|
237 |
Provides functions to determine or set features of the codec's CImageProcessor for a bitmap mask.
|
williamr@2
|
238 |
|
williamr@2
|
239 |
Note: For use by plugin writers only.
|
williamr@2
|
240 |
*/
|
williamr@2
|
241 |
class CImageMaskProcessorReadCodec : public CImageProcessorReadCodec
|
williamr@2
|
242 |
{
|
williamr@2
|
243 |
public:
|
williamr@2
|
244 |
IMPORT_C ~CImageMaskProcessorReadCodec();
|
williamr@2
|
245 |
protected:
|
williamr@2
|
246 |
IMPORT_C CImageMaskProcessorReadCodec();
|
williamr@2
|
247 |
IMPORT_C void ConstructL();
|
williamr@2
|
248 |
|
williamr@2
|
249 |
IMPORT_C CImageProcessor* MaskProcessor() const;
|
williamr@2
|
250 |
IMPORT_C void SetMaskProcessor(CImageProcessor* aMaskProc);
|
williamr@2
|
251 |
|
williamr@2
|
252 |
private:
|
williamr@2
|
253 |
CImageMaskProcessorReadCodecBody* iBody;
|
williamr@2
|
254 |
};
|
williamr@2
|
255 |
|
williamr@2
|
256 |
|
williamr@2
|
257 |
/**
|
williamr@2
|
258 |
@publishedAll
|
williamr@2
|
259 |
@released
|
williamr@2
|
260 |
|
williamr@2
|
261 |
Interface to be used by read codec implementations in conjunction with framework extension.
|
williamr@2
|
262 |
*/
|
williamr@2
|
263 |
class MReadCodecExtension
|
williamr@2
|
264 |
{
|
williamr@2
|
265 |
public:
|
williamr@2
|
266 |
/**
|
williamr@2
|
267 |
Obtains the scaling coefficient
|
williamr@2
|
268 |
@param aOriginalSize A reference to the original size of an image.
|
williamr@2
|
269 |
@param aDesiredSize A reference to the desired size of an image.
|
williamr@2
|
270 |
@return The scaling coefficient, for example:
|
williamr@2
|
271 |
Original size = 1 or -1,
|
williamr@2
|
272 |
Half original size = -2,
|
williamr@2
|
273 |
Quarter original size = -3 etc.
|
williamr@2
|
274 |
*/
|
williamr@2
|
275 |
virtual TInt ScalingCoefficient(const TSize& aOriginalSize, const TSize& aDesiredSize) const = 0;
|
williamr@2
|
276 |
|
williamr@2
|
277 |
/**
|
williamr@2
|
278 |
Obtains the reduced size of the decoded bitmap based on the input parameters
|
williamr@2
|
279 |
and updates aReducedSize with this value.
|
williamr@2
|
280 |
|
williamr@2
|
281 |
@param aOriginalSize A reference to the original size of an image.
|
williamr@2
|
282 |
@param aScalingCoeff The scaling coefficient to be applied.
|
williamr@2
|
283 |
@param aReducedSize A reference to the new size of an image.
|
williamr@2
|
284 |
@return KErrNone If the function call was successful.
|
williamr@2
|
285 |
@return A range of system wide error values.
|
williamr@2
|
286 |
*/
|
williamr@2
|
287 |
virtual TInt GetReducedSize(const TSize& aOriginalSize, TInt aScalingCoeff, TSize& aReducedSize) const = 0;
|
williamr@2
|
288 |
};
|
williamr@2
|
289 |
|
williamr@2
|
290 |
/**
|
williamr@2
|
291 |
@publishedAll
|
williamr@2
|
292 |
@released
|
williamr@2
|
293 |
|
williamr@2
|
294 |
Provides functions to determine or set features of the codec's CImageProcessor plus
|
williamr@2
|
295 |
provide extra functionality for Framework Extensions.
|
williamr@2
|
296 |
|
williamr@2
|
297 |
Note:
|
williamr@2
|
298 |
For use by plugin writers only.
|
williamr@2
|
299 |
*/
|
williamr@2
|
300 |
class CImageProcessorReadCodecExtension : public CImageProcessorReadCodec,
|
williamr@2
|
301 |
public MReadCodecExtension
|
williamr@2
|
302 |
{
|
williamr@2
|
303 |
public:
|
williamr@2
|
304 |
IMPORT_C ~CImageProcessorReadCodecExtension();
|
williamr@2
|
305 |
protected:
|
williamr@2
|
306 |
IMPORT_C CImageProcessorReadCodecExtension();
|
williamr@2
|
307 |
IMPORT_C void ConstructL();
|
williamr@2
|
308 |
|
williamr@2
|
309 |
// From MReadCodecExtension
|
williamr@2
|
310 |
IMPORT_C TInt ScalingCoefficient(const TSize& aOriginalSize, const TSize& aDesiredSize) const;
|
williamr@2
|
311 |
IMPORT_C TInt GetReducedSize(const TSize& aOriginalSize, TInt aScalingCoeff, TSize& aReducedSize) const;
|
williamr@2
|
312 |
};
|
williamr@2
|
313 |
|
williamr@2
|
314 |
/**
|
williamr@2
|
315 |
@publishedAll
|
williamr@2
|
316 |
@released
|
williamr@2
|
317 |
|
williamr@4
|
318 |
|
williamr@2
|
319 |
Provides functions to determine or set features of the codec's CImageProcessor plus
|
williamr@2
|
320 |
provide extra functionality for Framework Extensions.
|
williamr@2
|
321 |
|
williamr@2
|
322 |
Note:
|
williamr@2
|
323 |
For use by plugin writers only.
|
williamr@2
|
324 |
*/
|
williamr@2
|
325 |
class CImageMaskProcessorReadCodecExtension : public CImageMaskProcessorReadCodec,
|
williamr@2
|
326 |
public MReadCodecExtension
|
williamr@2
|
327 |
{
|
williamr@2
|
328 |
public:
|
williamr@2
|
329 |
IMPORT_C ~CImageMaskProcessorReadCodecExtension();
|
williamr@2
|
330 |
protected:
|
williamr@2
|
331 |
IMPORT_C CImageMaskProcessorReadCodecExtension();
|
williamr@2
|
332 |
IMPORT_C void ConstructL();
|
williamr@2
|
333 |
|
williamr@2
|
334 |
// From MReadCodecExtension
|
williamr@2
|
335 |
IMPORT_C TInt ScalingCoefficient(const TSize& aOriginalSize, const TSize& aDesiredSize) const;
|
williamr@2
|
336 |
IMPORT_C TInt GetReducedSize(const TSize& aOriginalSize, TInt aScalingCoeff, TSize& aReducedSize) const;
|
williamr@2
|
337 |
|
williamr@2
|
338 |
};
|
williamr@2
|
339 |
|
williamr@2
|
340 |
/**
|
williamr@2
|
341 |
@publishedAll
|
williamr@2
|
342 |
@released
|
williamr@2
|
343 |
|
williamr@2
|
344 |
Provides read related processing functions for bitmaps.
|
williamr@2
|
345 |
|
williamr@2
|
346 |
Note:
|
williamr@2
|
347 |
For use by plugin writers only.
|
williamr@2
|
348 |
*/
|
williamr@2
|
349 |
class CImageWriteCodec : public CBase
|
williamr@2
|
350 |
{
|
williamr@2
|
351 |
public:
|
williamr@2
|
352 |
IMPORT_C ~CImageWriteCodec();
|
williamr@2
|
353 |
IMPORT_C virtual void InitFrameL(TBufPtr8& aDst, const CFbsBitmap& aSource);
|
williamr@2
|
354 |
|
williamr@2
|
355 |
/**
|
williamr@2
|
356 |
Processes the frame data contained in aDst.
|
williamr@2
|
357 |
|
williamr@2
|
358 |
The internally held buffer must have been previously set, either by InitFrameL() or by a
|
williamr@2
|
359 |
SetSource().
|
williamr@2
|
360 |
|
williamr@2
|
361 |
This is a pure virtual function that each derived class must implement.
|
williamr@2
|
362 |
|
williamr@2
|
363 |
@param aDst
|
williamr@2
|
364 |
A reference to the buffer containing the frame data.
|
williamr@2
|
365 |
|
williamr@2
|
366 |
@return The current frame state after processing.
|
williamr@2
|
367 |
*/
|
williamr@2
|
368 |
virtual TFrameState ProcessFrameL(TBufPtr8& aDst) = 0;
|
williamr@2
|
369 |
|
williamr@2
|
370 |
IMPORT_C const CFbsBitmap* Source() const;
|
williamr@2
|
371 |
IMPORT_C void SetSource(const CFbsBitmap* aSource);
|
williamr@2
|
372 |
protected:
|
williamr@2
|
373 |
IMPORT_C void ConstructL();
|
williamr@2
|
374 |
IMPORT_C CImageWriteCodec();
|
williamr@2
|
375 |
private:
|
williamr@2
|
376 |
// Future proofing
|
williamr@2
|
377 |
IMPORT_C virtual void ReservedVirtual1();
|
williamr@2
|
378 |
IMPORT_C virtual void ReservedVirtual2();
|
williamr@2
|
379 |
IMPORT_C virtual void ReservedVirtual3();
|
williamr@2
|
380 |
IMPORT_C virtual void ReservedVirtual4();
|
williamr@2
|
381 |
private:
|
williamr@2
|
382 |
const CFbsBitmap* iSource; // linked object
|
williamr@2
|
383 |
};
|
williamr@2
|
384 |
|
williamr@2
|
385 |
/**
|
williamr@2
|
386 |
@internalComponent
|
williamr@2
|
387 |
|
williamr@2
|
388 |
Max size of strings in extra resource files
|
williamr@2
|
389 |
*/
|
williamr@2
|
390 |
const TInt KCodecResourceStringMax=128;
|
williamr@2
|
391 |
|
williamr@2
|
392 |
#endif // __IMAGECODEC_H__
|