1.1 --- a/epoc32/include/icl/imagecodec.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/icl/imagecodec.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,436 @@
1.4 -imagecodec.h
1.5 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +// All rights reserved.
1.7 +// This component and the accompanying materials are made available
1.8 +// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
1.9 +// which accompanies this distribution, and is available
1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +//
1.12 +// Initial Contributors:
1.13 +// Nokia Corporation - initial contribution.
1.14 +//
1.15 +// Contributors:
1.16 +//
1.17 +// Description:
1.18 +//
1.19 +
1.20 +#ifndef __IMAGECODEC_H__
1.21 +#define __IMAGECODEC_H__
1.22 +
1.23 +#include <e32std.h>
1.24 +#include <fbs.h>
1.25 +
1.26 +// Pre-definitions needed to make sure everything always defined in the right order
1.27 +class TFrameInfo;
1.28 +class TImageDataBlock;
1.29 +class CFrameImageData;
1.30 +
1.31 +class CImageDecoder;
1.32 +class CImageEncoder;
1.33 +class CImageProcessor;
1.34 +class CImageProcessorReadCodecBody;
1.35 +class CImageMaskProcessorReadCodecBody;
1.36 +
1.37 +/**
1.38 +@publishedAll
1.39 +@released
1.40 +
1.41 +Indicates what processing has so far been completed on the frame.
1.42 +*/
1.43 +enum TFrameState
1.44 + {
1.45 + /** Processing incomplete.
1.46 + */
1.47 + EFrameIncomplete,
1.48 + /** Processing complete.
1.49 + */
1.50 + EFrameComplete,
1.51 + /** Unexpected end of frame data.
1.52 + */
1.53 + EUnexpectedEndOfData,
1.54 + /** Same as EFrameIncomplete but also requests a call to CImageReadCodec::GetNewDataPosition().
1.55 + */
1.56 + EFrameIncompleteRepositionRequest,
1.57 + /** Processing of streaming block is complete.
1.58 + */
1.59 + EBlockComplete
1.60 + };
1.61 +
1.62 +/**
1.63 +@internalComponent
1.64 +
1.65 +
1.66 +Class used to shadow the descriptor supplying the image data.
1.67 +
1.68 +It maintains a flag to determine whether the descriptor contains a
1.69 +filename or the image data itself.
1.70 +
1.71 +This class is not intended for public use.
1.72 +*/
1.73 +class TImageParameterData
1.74 + {
1.75 +public:
1.76 +
1.77 + /**
1.78 + Flag used to determine what the descriptor contains.
1.79 + */
1.80 + enum TImageParameterDataFlag
1.81 + {
1.82 + /** Field not set.
1.83 + */
1.84 + ENull = 0x00000000,
1.85 +
1.86 + /** Descriptor is a filename.
1.87 + */
1.88 + EFilename = 0x00000001,
1.89 +
1.90 + /** Descriptor contains data.
1.91 + */
1.92 + EData = 0x00000002
1.93 + };
1.94 +
1.95 + TImageParameterData();
1.96 + void SetFilenamePtr(const TDesC* aSourceFilenamePtr);
1.97 + void SetDataPtr(const TDesC8* aSourceDataPtr);
1.98 + IMPORT_C TBool IsFilename() const;
1.99 + IMPORT_C const TDesC* SourceFilenamePtr() const;
1.100 + IMPORT_C const TDesC8* SourceDataPtr() const;
1.101 +
1.102 +private:
1.103 + TImageParameterDataFlag iImageParameterDataFlag;
1.104 + union
1.105 + {
1.106 + const TDesC* iSourceFilenamePtr;
1.107 + const TDesC8* iSourceDataPtr;
1.108 + };
1.109 + };
1.110 +
1.111 +/**
1.112 +@publishedAll
1.113 +@released
1.114 +
1.115 +Utility class to allow forward iteration through the data contained in
1.116 +an 8 bit descriptor.
1.117 +
1.118 +@see TPtr8
1.119 +@see TPtrC8
1.120 +@see TDes8
1.121 +@see TDesC8
1.122 +*/
1.123 +class TBufPtr8 : public TPtr8
1.124 + {
1.125 +public:
1.126 + /**
1.127 + Default constructor.
1.128 + */
1.129 + TBufPtr8()
1.130 + : TPtr8(0, 0, 0) {};
1.131 + inline void Set(const TDes8& aDes);
1.132 + inline void SetLengthOnly(const TDes8& aDes);
1.133 + inline void Set(const TPtrC8& aDes);
1.134 + inline void Shift(TInt aOffset);
1.135 + };
1.136 +
1.137 +/**
1.138 +Produces a shallow copy of the argument descriptor.
1.139 +
1.140 +@param aDes
1.141 + A reference to the descriptor containing the relevant data.
1.142 +*/
1.143 +inline void TBufPtr8::Set(const TDes8& aDes)
1.144 + {
1.145 + TPtr8::Set(CONST_CAST(TUint8*,aDes.Ptr()), aDes.Length(), aDes.MaxLength());
1.146 + }
1.147 +
1.148 +/**
1.149 +Produces a shallow copy of the argument descriptor, but also restricts
1.150 +pointer access to the current actual size of the argument descriptor.
1.151 +
1.152 +@param aDes
1.153 + A reference to the descriptor containing the relevant data.
1.154 +*/
1.155 +inline void TBufPtr8::SetLengthOnly(const TDes8& aDes)
1.156 + {
1.157 + TPtr8::Set(CONST_CAST(TUint8*,aDes.Ptr()), aDes.Length(), aDes.Length());
1.158 + }
1.159 +/**
1.160 +Produces a shallow copy of the argument descriptor, but restricts
1.161 +pointer access to the size of the const argument descriptor.
1.162 +
1.163 +@param aDes
1.164 + A reference to the descriptor containing the relevant data.
1.165 +*/
1.166 +inline void TBufPtr8::Set(const TPtrC8& aDes)
1.167 + {
1.168 + TPtr8::Set(CONST_CAST(TUint8*,aDes.Ptr()), aDes.Length(), aDes.Length());
1.169 + }
1.170 +/**
1.171 +Seeks the current data pointer aOffset bytes from the current position.
1.172 +
1.173 +@param aOffset
1.174 + The number of bytes by which to seek.
1.175 +*/
1.176 +inline void TBufPtr8::Shift(TInt aOffset)
1.177 + {
1.178 + SetLength(Length() - aOffset); iMaxLength -= aOffset; iPtr += aOffset;
1.179 + }
1.180 +
1.181 +/**
1.182 +@publishedAll
1.183 +@released
1.184 +
1.185 +Provides read related processing functions for bitmaps.
1.186 +
1.187 +Note: For use by plugin writers only.
1.188 +*/
1.189 +class CImageReadCodec : public CBase
1.190 + {
1.191 +public:
1.192 + IMPORT_C ~CImageReadCodec();
1.193 +
1.194 + /**
1.195 + Performs initial processing of image data and mask bitmaps.
1.196 +
1.197 + This function processes the image frame using data supplied in
1.198 + aFrameInfo, aFrameImageData and using the flag aDisableErrorDiffusion. Not all codecs
1.199 + are expected to make use of all fields.
1.200 +
1.201 + This is a virtual function that each derived class must implement.
1.202 +
1.203 + @param aFrameInfo
1.204 + A reference to a TFrameInfo object.
1.205 + @param aFrameImageData
1.206 + A reference to a CFrameImageData object.
1.207 + @param aDisableErrorDiffusion
1.208 + A flag indicating whether error diffusion should be disabled.
1.209 + @param aDestination
1.210 + The destination bitmap.
1.211 + @param aDestinationMask
1.212 + The destination mask bitmap.
1.213 + */
1.214 + virtual void InitFrameL(TFrameInfo& aFrameInfo, CFrameImageData& aFrameImageData, TBool aDisableErrorDiffusion, CFbsBitmap& aDestination, CFbsBitmap* aDestinationMask) = 0;
1.215 +
1.216 + IMPORT_C virtual void InitFrameHeader(TFrameInfo& aFrameInfo, CFrameImageData& aFrameData);
1.217 + IMPORT_C virtual TFrameState ProcessFrameHeaderL(TBufPtr8& aData);
1.218 + IMPORT_C virtual void Complete(); // Called on frame completion and on underflow
1.219 + IMPORT_C virtual void GetNewDataPosition(TInt& aPosition, TInt& aLength); // Returns a new position for the data stream, (also length of data required)
1.220 +
1.221 + /**
1.222 + Processes the frame data contained in aSrc.
1.223 +
1.224 + This is a pure virtual function that each derived class must implement.
1.225 +
1.226 + @param aSrc
1.227 + A reference to the buffer containing the frame data.
1.228 +
1.229 + @return The current frame state after processing.
1.230 + */
1.231 + virtual TFrameState ProcessFrameL(TBufPtr8& aSrc) = 0;
1.232 + void SetCurrentFrame(TInt aFrameNumber);
1.233 +
1.234 + IMPORT_C virtual TInt ReductionFactor(const TSize& aOriginalSize, const TSize& aReducedSize) const;
1.235 + IMPORT_C virtual TInt ReducedSize(const TSize& aOriginalSize,TInt aReductionFactor, TSize& aReducedSize) const;
1.236 +
1.237 +protected:
1.238 + IMPORT_C CImageReadCodec();
1.239 + IMPORT_C void ConstructL();
1.240 +
1.241 + IMPORT_C void ClearBitmapL(CFbsBitmap& aBitmap, TRgb aColor);
1.242 + IMPORT_C TInt CurrentFrame() const;
1.243 +
1.244 +private:
1.245 + // Future proofing
1.246 + IMPORT_C virtual void ReservedVirtual1();
1.247 + IMPORT_C virtual void ReservedVirtual2();
1.248 + IMPORT_C virtual void ReservedVirtual3();
1.249 + IMPORT_C virtual void ReservedVirtual4();
1.250 +
1.251 +private:
1.252 + TInt iCurrentFrame; //make handle to body if additional properties are needed
1.253 + };
1.254 +
1.255 +/**
1.256 +@publishedAll
1.257 +@released
1.258 +
1.259 +Provides functions to determine or set features of the codec's CImageProcessor.
1.260 +
1.261 +Note:
1.262 +For use by plugin writers only.
1.263 +*/
1.264 +class CImageProcessorReadCodec : public CImageReadCodec
1.265 + {
1.266 +public:
1.267 + IMPORT_C ~CImageProcessorReadCodec();
1.268 +protected:
1.269 + IMPORT_C CImageProcessorReadCodec();
1.270 + IMPORT_C void ConstructL();
1.271 +
1.272 + IMPORT_C CImageProcessor* ImageProcessor() const;
1.273 + IMPORT_C void SetImageProcessor(CImageProcessor* aImageProc);
1.274 +
1.275 + IMPORT_C const TPoint& Pos() const;
1.276 + IMPORT_C TPoint& Pos();
1.277 + IMPORT_C void SetPos(const TPoint& aPos);
1.278 +private:
1.279 + CImageProcessorReadCodecBody* iBody;
1.280 + };
1.281 +
1.282 +/**
1.283 +@publishedAll
1.284 +@released
1.285 +
1.286 +Provides functions to determine or set features of the codec's CImageProcessor for a bitmap mask.
1.287 +
1.288 +Note: For use by plugin writers only.
1.289 +*/
1.290 +class CImageMaskProcessorReadCodec : public CImageProcessorReadCodec
1.291 + {
1.292 +public:
1.293 + IMPORT_C ~CImageMaskProcessorReadCodec();
1.294 +protected:
1.295 + IMPORT_C CImageMaskProcessorReadCodec();
1.296 + IMPORT_C void ConstructL();
1.297 +
1.298 + IMPORT_C CImageProcessor* MaskProcessor() const;
1.299 + IMPORT_C void SetMaskProcessor(CImageProcessor* aMaskProc);
1.300 +
1.301 +private:
1.302 + CImageMaskProcessorReadCodecBody* iBody;
1.303 + };
1.304 +
1.305 +
1.306 +/**
1.307 +@publishedAll
1.308 +@released
1.309 +
1.310 +Interface to be used by read codec implementations in conjunction with framework extension.
1.311 +*/
1.312 +class MReadCodecExtension
1.313 + {
1.314 +public:
1.315 + /**
1.316 + Obtains the scaling coefficient
1.317 + @param aOriginalSize A reference to the original size of an image.
1.318 + @param aDesiredSize A reference to the desired size of an image.
1.319 + @return The scaling coefficient, for example:
1.320 + Original size = 1 or -1,
1.321 + Half original size = -2,
1.322 + Quarter original size = -3 etc.
1.323 + */
1.324 + virtual TInt ScalingCoefficient(const TSize& aOriginalSize, const TSize& aDesiredSize) const = 0;
1.325 +
1.326 + /**
1.327 + Obtains the reduced size of the decoded bitmap based on the input parameters
1.328 + and updates aReducedSize with this value.
1.329 +
1.330 + @param aOriginalSize A reference to the original size of an image.
1.331 + @param aScalingCoeff The scaling coefficient to be applied.
1.332 + @param aReducedSize A reference to the new size of an image.
1.333 + @return KErrNone If the function call was successful.
1.334 + @return A range of system wide error values.
1.335 + */
1.336 + virtual TInt GetReducedSize(const TSize& aOriginalSize, TInt aScalingCoeff, TSize& aReducedSize) const = 0;
1.337 + };
1.338 +
1.339 +/**
1.340 +@publishedAll
1.341 +@released
1.342 +
1.343 +Provides functions to determine or set features of the codec's CImageProcessor plus
1.344 +provide extra functionality for Framework Extensions.
1.345 +
1.346 +Note:
1.347 +For use by plugin writers only.
1.348 +*/
1.349 +class CImageProcessorReadCodecExtension : public CImageProcessorReadCodec,
1.350 + public MReadCodecExtension
1.351 + {
1.352 +public:
1.353 + IMPORT_C ~CImageProcessorReadCodecExtension();
1.354 +protected:
1.355 + IMPORT_C CImageProcessorReadCodecExtension();
1.356 + IMPORT_C void ConstructL();
1.357 +
1.358 + // From MReadCodecExtension
1.359 + IMPORT_C TInt ScalingCoefficient(const TSize& aOriginalSize, const TSize& aDesiredSize) const;
1.360 + IMPORT_C TInt GetReducedSize(const TSize& aOriginalSize, TInt aScalingCoeff, TSize& aReducedSize) const;
1.361 + };
1.362 +
1.363 +/**
1.364 +@publishedAll
1.365 +@released
1.366 +
1.367 +Provides functions to determine or set features of the codec's CImageProcessor plus
1.368 +provide extra functionality for Framework Extensions.
1.369 +
1.370 +Note:
1.371 +For use by plugin writers only.
1.372 +*/
1.373 +class CImageMaskProcessorReadCodecExtension : public CImageMaskProcessorReadCodec,
1.374 + public MReadCodecExtension
1.375 + {
1.376 +public:
1.377 + IMPORT_C ~CImageMaskProcessorReadCodecExtension();
1.378 +protected:
1.379 + IMPORT_C CImageMaskProcessorReadCodecExtension();
1.380 + IMPORT_C void ConstructL();
1.381 +
1.382 + // From MReadCodecExtension
1.383 + IMPORT_C TInt ScalingCoefficient(const TSize& aOriginalSize, const TSize& aDesiredSize) const;
1.384 + IMPORT_C TInt GetReducedSize(const TSize& aOriginalSize, TInt aScalingCoeff, TSize& aReducedSize) const;
1.385 +
1.386 + };
1.387 +
1.388 +/**
1.389 +@publishedAll
1.390 +@released
1.391 +
1.392 +Provides read related processing functions for bitmaps.
1.393 +
1.394 +Note:
1.395 +For use by plugin writers only.
1.396 +*/
1.397 +class CImageWriteCodec : public CBase
1.398 + {
1.399 +public:
1.400 + IMPORT_C ~CImageWriteCodec();
1.401 + IMPORT_C virtual void InitFrameL(TBufPtr8& aDst, const CFbsBitmap& aSource);
1.402 +
1.403 + /**
1.404 + Processes the frame data contained in aDst.
1.405 +
1.406 + The internally held buffer must have been previously set, either by InitFrameL() or by a
1.407 + SetSource().
1.408 +
1.409 + This is a pure virtual function that each derived class must implement.
1.410 +
1.411 + @param aDst
1.412 + A reference to the buffer containing the frame data.
1.413 +
1.414 + @return The current frame state after processing.
1.415 + */
1.416 + virtual TFrameState ProcessFrameL(TBufPtr8& aDst) = 0;
1.417 +
1.418 + IMPORT_C const CFbsBitmap* Source() const;
1.419 + IMPORT_C void SetSource(const CFbsBitmap* aSource);
1.420 +protected:
1.421 + IMPORT_C void ConstructL();
1.422 + IMPORT_C CImageWriteCodec();
1.423 +private:
1.424 + // Future proofing
1.425 + IMPORT_C virtual void ReservedVirtual1();
1.426 + IMPORT_C virtual void ReservedVirtual2();
1.427 + IMPORT_C virtual void ReservedVirtual3();
1.428 + IMPORT_C virtual void ReservedVirtual4();
1.429 +private:
1.430 + const CFbsBitmap* iSource; // linked object
1.431 + };
1.432 +
1.433 +/**
1.434 +@internalComponent
1.435 +
1.436 +Max size of strings in extra resource files
1.437 +*/
1.438 +const TInt KCodecResourceStringMax=128;
1.439 +
1.440 +#endif // __IMAGECODEC_H__