1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __IMAGECODEC_H__
17 #define __IMAGECODEC_H__
22 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
23 #include <icl/imagecodecdef.h>
26 // Pre-definitions needed to make sure everything always defined in the right order
28 class TImageDataBlock;
29 class CFrameImageData;
33 class CImageProcessor;
34 class CImageProcessorReadCodecBody;
35 class CImageMaskProcessorReadCodecBody;
41 Indicates what processing has so far been completed on the frame.
45 /** Processing incomplete.
48 /** Processing complete.
51 /** Unexpected end of frame data.
54 /** Same as EFrameIncomplete but also requests a call to CImageReadCodec::GetNewDataPosition().
56 EFrameIncompleteRepositionRequest,
57 /** Processing of streaming block is complete.
66 Utility class to allow forward iteration through the data contained in
74 class TBufPtr8 : public TPtr8
82 inline void Set(const TDes8& aDes);
83 inline void SetLengthOnly(const TDes8& aDes);
84 inline void Set(const TPtrC8& aDes);
85 inline void Shift(TInt aOffset);
89 Produces a shallow copy of the argument descriptor.
92 A reference to the descriptor containing the relevant data.
94 inline void TBufPtr8::Set(const TDes8& aDes)
96 TPtr8::Set(CONST_CAST(TUint8*,aDes.Ptr()), aDes.Length(), aDes.MaxLength());
100 Produces a shallow copy of the argument descriptor, but also restricts
101 pointer access to the current actual size of the argument descriptor.
104 A reference to the descriptor containing the relevant data.
106 inline void TBufPtr8::SetLengthOnly(const TDes8& aDes)
108 TPtr8::Set(CONST_CAST(TUint8*,aDes.Ptr()), aDes.Length(), aDes.Length());
111 Produces a shallow copy of the argument descriptor, but restricts
112 pointer access to the size of the const argument descriptor.
115 A reference to the descriptor containing the relevant data.
117 inline void TBufPtr8::Set(const TPtrC8& aDes)
119 TPtr8::Set(CONST_CAST(TUint8*,aDes.Ptr()), aDes.Length(), aDes.Length());
122 Seeks the current data pointer aOffset bytes from the current position.
125 The number of bytes by which to seek.
127 inline void TBufPtr8::Shift(TInt aOffset)
129 SetLength(Length() - aOffset); iMaxLength -= aOffset; iPtr += aOffset;
136 Provides read related processing functions for bitmaps.
138 Note: For use by plugin writers only.
140 class CImageReadCodec : public CBase
143 IMPORT_C ~CImageReadCodec();
146 Performs initial processing of image data and mask bitmaps.
148 This function processes the image frame using data supplied in
149 aFrameInfo, aFrameImageData and using the flag aDisableErrorDiffusion. Not all codecs
150 are expected to make use of all fields.
152 This is a virtual function that each derived class must implement.
155 A reference to a TFrameInfo object.
156 @param aFrameImageData
157 A reference to a CFrameImageData object.
158 @param aDisableErrorDiffusion
159 A flag indicating whether error diffusion should be disabled.
161 The destination bitmap.
162 @param aDestinationMask
163 The destination mask bitmap.
165 virtual void InitFrameL(TFrameInfo& aFrameInfo, CFrameImageData& aFrameImageData, TBool aDisableErrorDiffusion, CFbsBitmap& aDestination, CFbsBitmap* aDestinationMask) = 0;
167 IMPORT_C virtual void InitFrameHeader(TFrameInfo& aFrameInfo, CFrameImageData& aFrameData);
168 IMPORT_C virtual TFrameState ProcessFrameHeaderL(TBufPtr8& aData);
169 IMPORT_C virtual void Complete(); // Called on frame completion and on underflow
170 IMPORT_C virtual void GetNewDataPosition(TInt& aPosition, TInt& aLength); // Returns a new position for the data stream, (also length of data required)
173 Processes the frame data contained in aSrc.
175 This is a pure virtual function that each derived class must implement.
178 A reference to the buffer containing the frame data.
180 @return The current frame state after processing.
182 virtual TFrameState ProcessFrameL(TBufPtr8& aSrc) = 0;
183 void SetCurrentFrame(TInt aFrameNumber);
185 IMPORT_C virtual TInt ReductionFactor(const TSize& aOriginalSize, const TSize& aReducedSize) const;
186 IMPORT_C virtual TInt ReducedSize(const TSize& aOriginalSize,TInt aReductionFactor, TSize& aReducedSize) const;
189 IMPORT_C CImageReadCodec();
190 IMPORT_C void ConstructL();
192 IMPORT_C void ClearBitmapL(CFbsBitmap& aBitmap, TRgb aColor);
193 IMPORT_C TInt CurrentFrame() const;
197 IMPORT_C virtual void ReservedVirtual1();
198 IMPORT_C virtual void ReservedVirtual2();
199 IMPORT_C virtual void ReservedVirtual3();
200 IMPORT_C virtual void ReservedVirtual4();
203 TInt iCurrentFrame; //make handle to body if additional properties are needed
210 Provides functions to determine or set features of the codec's CImageProcessor.
213 For use by plugin writers only.
215 class CImageProcessorReadCodec : public CImageReadCodec
218 IMPORT_C ~CImageProcessorReadCodec();
220 IMPORT_C CImageProcessorReadCodec();
221 IMPORT_C void ConstructL();
223 IMPORT_C CImageProcessor* ImageProcessor() const;
224 IMPORT_C void SetImageProcessor(CImageProcessor* aImageProc);
226 IMPORT_C const TPoint& Pos() const;
227 IMPORT_C TPoint& Pos();
228 IMPORT_C void SetPos(const TPoint& aPos);
230 CImageProcessorReadCodecBody* iBody;
237 Provides functions to determine or set features of the codec's CImageProcessor for a bitmap mask.
239 Note: For use by plugin writers only.
241 class CImageMaskProcessorReadCodec : public CImageProcessorReadCodec
244 IMPORT_C ~CImageMaskProcessorReadCodec();
246 IMPORT_C CImageMaskProcessorReadCodec();
247 IMPORT_C void ConstructL();
249 IMPORT_C CImageProcessor* MaskProcessor() const;
250 IMPORT_C void SetMaskProcessor(CImageProcessor* aMaskProc);
253 CImageMaskProcessorReadCodecBody* iBody;
261 Interface to be used by read codec implementations in conjunction with framework extension.
263 class MReadCodecExtension
267 Obtains the scaling coefficient
268 @param aOriginalSize A reference to the original size of an image.
269 @param aDesiredSize A reference to the desired size of an image.
270 @return The scaling coefficient, for example:
271 Original size = 1 or -1,
272 Half original size = -2,
273 Quarter original size = -3 etc.
275 virtual TInt ScalingCoefficient(const TSize& aOriginalSize, const TSize& aDesiredSize) const = 0;
278 Obtains the reduced size of the decoded bitmap based on the input parameters
279 and updates aReducedSize with this value.
281 @param aOriginalSize A reference to the original size of an image.
282 @param aScalingCoeff The scaling coefficient to be applied.
283 @param aReducedSize A reference to the new size of an image.
284 @return KErrNone If the function call was successful.
285 @return A range of system wide error values.
287 virtual TInt GetReducedSize(const TSize& aOriginalSize, TInt aScalingCoeff, TSize& aReducedSize) const = 0;
294 Provides functions to determine or set features of the codec's CImageProcessor plus
295 provide extra functionality for Framework Extensions.
298 For use by plugin writers only.
300 class CImageProcessorReadCodecExtension : public CImageProcessorReadCodec,
301 public MReadCodecExtension
304 IMPORT_C ~CImageProcessorReadCodecExtension();
306 IMPORT_C CImageProcessorReadCodecExtension();
307 IMPORT_C void ConstructL();
309 // From MReadCodecExtension
310 IMPORT_C TInt ScalingCoefficient(const TSize& aOriginalSize, const TSize& aDesiredSize) const;
311 IMPORT_C TInt GetReducedSize(const TSize& aOriginalSize, TInt aScalingCoeff, TSize& aReducedSize) const;
319 Provides functions to determine or set features of the codec's CImageProcessor plus
320 provide extra functionality for Framework Extensions.
323 For use by plugin writers only.
325 class CImageMaskProcessorReadCodecExtension : public CImageMaskProcessorReadCodec,
326 public MReadCodecExtension
329 IMPORT_C ~CImageMaskProcessorReadCodecExtension();
331 IMPORT_C CImageMaskProcessorReadCodecExtension();
332 IMPORT_C void ConstructL();
334 // From MReadCodecExtension
335 IMPORT_C TInt ScalingCoefficient(const TSize& aOriginalSize, const TSize& aDesiredSize) const;
336 IMPORT_C TInt GetReducedSize(const TSize& aOriginalSize, TInt aScalingCoeff, TSize& aReducedSize) const;
344 Provides read related processing functions for bitmaps.
347 For use by plugin writers only.
349 class CImageWriteCodec : public CBase
352 IMPORT_C ~CImageWriteCodec();
353 IMPORT_C virtual void InitFrameL(TBufPtr8& aDst, const CFbsBitmap& aSource);
356 Processes the frame data contained in aDst.
358 The internally held buffer must have been previously set, either by InitFrameL() or by a
361 This is a pure virtual function that each derived class must implement.
364 A reference to the buffer containing the frame data.
366 @return The current frame state after processing.
368 virtual TFrameState ProcessFrameL(TBufPtr8& aDst) = 0;
370 IMPORT_C const CFbsBitmap* Source() const;
371 IMPORT_C void SetSource(const CFbsBitmap* aSource);
373 IMPORT_C void ConstructL();
374 IMPORT_C CImageWriteCodec();
377 IMPORT_C virtual void ReservedVirtual1();
378 IMPORT_C virtual void ReservedVirtual2();
379 IMPORT_C virtual void ReservedVirtual3();
380 IMPORT_C virtual void ReservedVirtual4();
382 const CFbsBitmap* iSource; // linked object
388 Max size of strings in extra resource files
390 const TInt KCodecResourceStringMax=128;
392 #endif // __IMAGECODEC_H__