imaging/imagingfws/src/ImageProcessorPriv.h
changeset 0 5752a19fdefe
equal deleted inserted replaced
-1:000000000000 0:5752a19fdefe
       
     1 // Copyright (c) 1998-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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef ___IMAGEPROCESSORPRIV_H__
       
    17 #define ___IMAGEPROCESSORPRIV_H__
       
    18 
       
    19 #include <icl/imageprocessor.h>
       
    20 #include "fwextconstants.h"
       
    21 
       
    22 //The size of the index lookup table
       
    23 const TInt KIndexLookupSize = 256;
       
    24 
       
    25 class CColorImageProcessor; // declared here
       
    26 /**
       
    27  * @internalComponent
       
    28  *
       
    29  * @see CImageProcessor.
       
    30  *
       
    31  */
       
    32 NONSHARABLE_CLASS( CColorImageProcessor ): public CImageProcessorExtension
       
    33 	{
       
    34 public:
       
    35 	virtual ~CColorImageProcessor();
       
    36 	// From CImageProcessor (Default implementations)
       
    37 	TBool SetPixelRun(TRgb aColor,TInt aCount);
       
    38 	TBool SetPixels(TRgb* aColorBuffer,TInt aBufferLength);
       
    39 	TBool SetMonoPixel(TInt aGray256);
       
    40 	TBool SetMonoPixelRun(TInt aGray256,TInt aCount);
       
    41 	TBool SetMonoPixels(TUint32* aGray256Buffer,TInt aBufferLength);
       
    42 	TBool SetMonoPixelBlock(TUint32* aGray256Buffer);
       
    43 protected:
       
    44 	// New - to facilitate default implementation of SetMonoPixelBlock()
       
    45 	void CreateBlockBufferL(TInt aBlockArea);
       
    46 protected:
       
    47 	// Used by default implementation of SetMonoPixelBlock()
       
    48 	TRgb*	iBlockBuffer;
       
    49 	TInt	iBlockArea;
       
    50 	};
       
    51 
       
    52 class CMonochromeImageProcessor; // declared here
       
    53 /**
       
    54  * @internalComponent
       
    55  *
       
    56  * @see CImageProcessor.
       
    57  *
       
    58  */
       
    59 NONSHARABLE_CLASS( CMonochromeImageProcessor ): public CImageProcessorExtension
       
    60 	{
       
    61 public:
       
    62 	virtual ~CMonochromeImageProcessor();
       
    63 	// From CImageProcessor (Default implementations)
       
    64 	TBool SetPixel(TRgb aColor);
       
    65 	TBool SetPixelRun(TRgb aColor,TInt aCount);
       
    66 	TBool SetPixels(TRgb* aColorBuffer,TInt aBufferLength);
       
    67 	TBool SetPixelBlock(TRgb* aColorBuffer);
       
    68 	TBool SetMonoPixelRun(TInt aGray256,TInt aCount);
       
    69 	TBool SetMonoPixels(TUint32* aGray256Buffer,TInt aBufferLength);
       
    70 protected:
       
    71 	// New - to facilitate default implementation of SetPixelBlock()
       
    72 	void CreateBlockBufferL(TInt aBlockArea);
       
    73 protected:
       
    74 	// Used by default implementation of SetPixelBlock()
       
    75 	TUint32* iBlockBuffer;
       
    76 	TInt	 iBlockArea;
       
    77 	};
       
    78 
       
    79 class CPixelWriter; // declared here
       
    80 /**
       
    81  * @internalComponent
       
    82  *
       
    83  * @see CColorImageProcessor.
       
    84  *
       
    85  */
       
    86 NONSHARABLE_CLASS( CPixelWriter ): public CColorImageProcessor
       
    87 	{
       
    88 public:
       
    89 	static CPixelWriter* NewL();
       
    90 	virtual ~CPixelWriter();
       
    91 	// From CImageProcessor
       
    92 	void PrepareL(CFbsBitmap& aBitmap,const TRect& aImageRect);
       
    93 	void PrepareL(CFbsBitmap& aBitmap,const TRect& aImageRect,const TSize& aRgbBlockSize);
       
    94 	void SetYPosIncrement(TInt aYInc);
       
    95 	void SetLineRepeat(TInt aLineRepeat);
       
    96 	void SetPixelPadding(TInt aNumberOfPixels);
       
    97 	TBool SetPixel(TRgb aColor);
       
    98 	TBool SetPixelRun(TRgb aColor,TInt aCount);
       
    99 	TBool SetPixels(TRgb* aColorBuffer, TInt aBufferLength);
       
   100 	TBool SetPixelBlock(TRgb* aColorBuffer);
       
   101 	TBool SetPos(const TPoint& aPosition);
       
   102 	TBool FlushPixels();
       
   103 protected:
       
   104 	// New
       
   105 	CPixelWriter();
       
   106 	virtual void Reset();
       
   107 	virtual void DoPrepareL(CFbsBitmap& aBitmap,const TRect& aImageRect,const TSize* aBlockSize);
       
   108 	virtual void SetPixelBufferIndex(TRgb* aColorBuffer,TInt aCount);	//Used by FlushPixels to convert buffered 'SetPixel's
       
   109 	virtual void SetPixelBlockIndex(TRgb* aColorBuffer);	//Used by SetPixelBlock
       
   110 	virtual TBool NewLine();
       
   111 protected:
       
   112 	TInt iYInc;
       
   113 	TInt iLineRepeat;
       
   114 	TInt iPixelPadding;
       
   115 	TInt iPixelsToSkip;
       
   116 	TPoint iPos;
       
   117 	TRect iImageRegion;
       
   118 	TSize iBlockSize;
       
   119 	TInt iBlockArea;
       
   120 	TImageBitmapUtil iUtil;
       
   121 	TColorConvertor* iColorConv;
       
   122 	TRgb* iRgbBuffer;
       
   123 	TRgb* iRgbBufferPtr;
       
   124 	TRgb* iRgbBufferPtrLimit;
       
   125 	TUint32* iIndexBuffer;
       
   126 	TUint32* iIndexBufferPtrLimit;
       
   127 	TDisplayMode iDisplayMode;
       
   128 	TBool iDrawBottomUp;
       
   129 	};
       
   130 
       
   131 class CMonochromePixelWriter; // declared here
       
   132 /**
       
   133  * @internalComponent
       
   134  *
       
   135  * @see CMonochromeImageProcessor.
       
   136  *
       
   137  */
       
   138 NONSHARABLE_CLASS( CMonochromePixelWriter ): public CMonochromeImageProcessor
       
   139 	{
       
   140 public:
       
   141 	static CMonochromePixelWriter* NewL();
       
   142 	virtual ~CMonochromePixelWriter();
       
   143 	// From CImageProcessor
       
   144 	void PrepareL(CFbsBitmap& aBitmap,const TRect& aImageRect);
       
   145 	void PrepareL(CFbsBitmap& aBitmap,const TRect& aImageRect,const TSize& aRgbBlockSize);
       
   146 	void SetYPosIncrement(TInt aYInc);
       
   147 	void SetLineRepeat(TInt aLineRepeat);
       
   148 	void SetPixelPadding(TInt aNumberOfPixels);
       
   149 	TBool SetMonoPixel(TInt aGray256);
       
   150 	TBool SetMonoPixelRun(TInt aGray256,TInt aCount);
       
   151 	TBool SetMonoPixels(TUint32* aGray256Buffer,TInt aBufferLength);
       
   152 	TBool SetMonoPixelBlock(TUint32* aGray256Buffer);
       
   153 	TBool SetPos(const TPoint& aPosition);
       
   154 	TBool FlushPixels();
       
   155 protected:
       
   156 	// New
       
   157 	CMonochromePixelWriter();
       
   158 	virtual void Reset();
       
   159 	virtual void DoPrepareL(CFbsBitmap& aBitmap,const TRect& aImageRect,const TSize* aBlockSize);
       
   160 	virtual void SetPixelBufferIndex(TUint32* aGray256Buffer,TInt aCount);	//Used by FlushPixels to convert buffered 'SetPixel's
       
   161 	virtual void SetPixelBlockIndex(TUint32* aGray256Buffer);	//Used by SetPixelBlock
       
   162 	virtual TBool NewLine();
       
   163 protected:
       
   164 	TInt iYInc;
       
   165 	TInt iLineRepeat;
       
   166 	TInt iPixelPadding;
       
   167 	TInt iPixelsToSkip;
       
   168 	TPoint iPos;
       
   169 	TRect iImageRegion;
       
   170 	TSize iBlockSize;
       
   171 	TInt iBlockArea;
       
   172 	TImageBitmapUtil iUtil;
       
   173 	TColorConvertor* iColorConv;
       
   174 	TUint32* iGray256Buffer;
       
   175 	TUint32* iGray256BufferPtr;
       
   176 	TUint32* iGray256BufferPtrLimit;
       
   177 	TUint32* iIndexBuffer;
       
   178 	TUint32* iIndexBufferPtrLimit;
       
   179 	TUint32 iIndexLookup[KIndexLookupSize];
       
   180 	TBool iDrawBottomUp;
       
   181 	};
       
   182 
       
   183 class CErrorDiffuser; // declared here
       
   184 /**
       
   185  * @internalComponent
       
   186  *
       
   187  * @see CPixelWriter.
       
   188  *
       
   189  */
       
   190 NONSHARABLE_CLASS( CErrorDiffuser ): public CPixelWriter
       
   191 	{
       
   192 public:
       
   193 	IMPORT_C static CErrorDiffuser* NewL();
       
   194 	virtual ~CErrorDiffuser();
       
   195 protected:
       
   196 	CErrorDiffuser();
       
   197 private:
       
   198 	class TColorError
       
   199 		{
       
   200 	public:
       
   201 		inline void AdjustColor(TRgb& aColor) const;
       
   202 	public:
       
   203 		inline TColorError();
       
   204 		inline TColorError(TInt aRedError,TInt aGreenError,TInt aBlueError);
       
   205 		inline void SetError(TRgb aIdealColor,TRgb aActualColor);
       
   206 		inline TColorError operator+(const TColorError& aColorError) const;
       
   207 		inline TColorError operator-(const TColorError& aColorError) const;
       
   208 		inline TColorError operator<<(TInt aShift) const;
       
   209 		inline TColorError& operator+=(const TColorError& aColorError);
       
   210 	public:
       
   211 		TInt iRedError;
       
   212 		TInt iGreenError;
       
   213 		TInt iBlueError;
       
   214 		};
       
   215 private:
       
   216 	// From CPixelWriter
       
   217 	void Reset();
       
   218 	void DoPrepareL(CFbsBitmap& aBitmap,const TRect& aImageRect,const TSize* aBlockSize);
       
   219 	void SetPixelBufferIndex(TRgb* aColorBuffer,TInt aCount);
       
   220 	void SetPixelBlockIndex(TRgb* aColorBuffer);
       
   221 	void SetPixelBufferColor64KIndex(TRgb* aColorBuffer,TInt aCount);
       
   222 	// optimized version of ClampColorComponent
       
   223 	inline TInt ClipColorComponent(TInt value);
       
   224 	
       
   225 private:
       
   226 	TColorError* iScanlineErrorBuffer;
       
   227 	TColorError* iEdgeErrorBuffer;
       
   228 	TColorError iNextError;
       
   229 	TPoint iLastPos;
       
   230 	// for fast 64K mode
       
   231 	TInt8* iRedErrorLookupTable;
       
   232 	TInt8* iGreenErrorLookupTable;
       
   233 	TInt iNextRedError;
       
   234 	TInt iNextGreenError;
       
   235 	TInt iNextBlueError;
       
   236 	};
       
   237 
       
   238 class CMonochromeErrorDiffuser; // declared here
       
   239 /**
       
   240  * @internalComponent
       
   241  *
       
   242  * @see CMonochromePixelWriter.
       
   243  *
       
   244  */
       
   245 NONSHARABLE_CLASS( CMonochromeErrorDiffuser ): public CMonochromePixelWriter
       
   246 	{
       
   247 public:
       
   248 	static CMonochromeErrorDiffuser* NewL();
       
   249 	virtual ~CMonochromeErrorDiffuser();
       
   250 protected:
       
   251 	CMonochromeErrorDiffuser();
       
   252 private:
       
   253 	// From CMonochromePixelWriter
       
   254 	void Reset();
       
   255 	void DoPrepareL(CFbsBitmap& aBitmap,const TRect& aImageRect,const TSize* aBlockSize);
       
   256 	void SetPixelBufferIndex(TUint32* aGray256Buffer,TInt aCount);
       
   257 	void SetPixelBlockIndex(TUint32* aGray256Buffer);
       
   258 private:
       
   259 	TInt* iScanlineErrorBuffer;
       
   260 	TInt* iEdgeErrorBuffer;
       
   261 	TInt iNextError;
       
   262 	TPoint iLastPos;
       
   263 	};
       
   264 
       
   265 class CThumbnailProcessor; // declared here
       
   266 /**
       
   267  * @internalComponent
       
   268  *
       
   269  * @see CColorImageProcessor.
       
   270  *
       
   271  */
       
   272 NONSHARABLE_CLASS( CThumbnailProcessor ): public CColorImageProcessor
       
   273 	{
       
   274 public:
       
   275 	static CThumbnailProcessor* NewL(CImageProcessorExtension* aImageProc,TInt aReductionFactor);
       
   276 	virtual ~CThumbnailProcessor();
       
   277 	// From CImageProcessor
       
   278 	void PrepareL(CFbsBitmap& aBitmap,const TRect& aImageRect);
       
   279 	void PrepareL(CFbsBitmap& aBitmap,const TRect& aImageRect,const TSize& aRgbBlockSize);
       
   280 	void SetYPosIncrement(TInt aYInc);
       
   281 	void SetLineRepeat(TInt aLineRepeat);
       
   282 	void SetPixelPadding(TInt aNumberOfPixels);
       
   283 	TBool SetPixel(TRgb aColor);
       
   284 	TBool SetPixelBlock(TRgb* aColorBuffer);
       
   285 	TBool SetPos(const TPoint& aPosition);
       
   286 	TBool FlushPixels();
       
   287 private:
       
   288 	// New
       
   289 	CThumbnailProcessor(CImageProcessorExtension* aImageProc,TInt aReductionFactor);
       
   290 	void PrepareCommonL(const TRect& aImageRect);
       
   291 	void DoFlushPixels();
       
   292 	TBool NewLine();
       
   293 private:
       
   294 	class TColorSum
       
   295 		{
       
   296 	public:
       
   297 		TInt iRed;
       
   298 		TInt iGreen;
       
   299 		TInt iBlue;
       
   300 		TInt iCount;
       
   301 		};
       
   302 private:
       
   303 	CImageProcessorExtension* iImageProc;
       
   304 	TPoint iPos;
       
   305 	TBool iPositionChanged;
       
   306 	TInt iPixelPadding;
       
   307 	TInt iEndOfLineX;
       
   308 	TInt iYInc;
       
   309 	TRect iImageRegion;
       
   310 	TSize iOriginalBlockSize;
       
   311 	TInt iReductionFactor;
       
   312 	TRect iReducedImageRegion;
       
   313 	TSize iReducedBlockSize;
       
   314 	TRgb* iReducedPixelBuffer;
       
   315 	TColorSum* iReducedSumBuffer;
       
   316 	TBool iDrawBottomUp;
       
   317 	};
       
   318 
       
   319 class CMonochromeThumbnailProcessor; // declared here
       
   320 /**
       
   321  * @internalComponent
       
   322  *
       
   323  * @see CMonochromeImageProcessor.
       
   324  *
       
   325  */
       
   326 NONSHARABLE_CLASS( CMonochromeThumbnailProcessor ): public CMonochromeImageProcessor
       
   327 	{
       
   328 public:
       
   329 	static CMonochromeThumbnailProcessor* NewL(CImageProcessorExtension* aImageProc,TInt aReductionFactor);
       
   330 	virtual ~CMonochromeThumbnailProcessor();
       
   331 	// From CImageProcessor
       
   332 	void PrepareL(CFbsBitmap& aBitmap,const TRect& aImageRect);
       
   333 	void PrepareL(CFbsBitmap& aBitmap,const TRect& aImageRect,const TSize& aRgbBlockSize);
       
   334 	void SetYPosIncrement(TInt aYInc);
       
   335 	void SetLineRepeat(TInt aLineRepeat);
       
   336 	void SetPixelPadding(TInt aNumberOfPixels);
       
   337 	TBool SetMonoPixel(TInt aGray256);
       
   338 	TBool SetMonoPixelRun(TInt aGray256,TInt aCount);
       
   339 	TBool SetMonoPixelBlock(TUint32* aGray256Buffer);
       
   340 	TBool SetPos(const TPoint& aPosition);
       
   341 	TBool FlushPixels();
       
   342 private:
       
   343 	// New
       
   344 	CMonochromeThumbnailProcessor(CImageProcessorExtension* aImageProc,TInt aReductionFactor);
       
   345 	void PrepareCommonL(const TRect& aImageRect);
       
   346 	void DoFlushPixels();
       
   347 	TBool NewLine();
       
   348 private:
       
   349 	class TMonochromeSum
       
   350 		{
       
   351 	public:
       
   352 		TInt iLevel;
       
   353 		TInt iCount;
       
   354 		};
       
   355 private:
       
   356 	CImageProcessorExtension* iImageProc;
       
   357 	TPoint iPos;
       
   358 	TBool iPositionChanged;
       
   359 	TInt iPixelPadding;
       
   360 	TInt iEndOfLineX;
       
   361 	TInt iYInc;
       
   362 	TRect iImageRegion;
       
   363 	TSize iOriginalBlockSize;
       
   364 	TInt iReductionFactor;
       
   365 	TRect iReducedImageRegion;
       
   366 	TSize iReducedBlockSize;
       
   367 	TUint32* iReducedPixelBuffer;
       
   368 	TMonochromeSum* iReducedSumBuffer;
       
   369 	TBool iDrawBottomUp;
       
   370 	};
       
   371 
       
   372 #endif // ___IMAGEPROCESSORPRIV_H__
       
   373 
       
   374 
       
   375