epoc32/include/icl/imageprocessor.h
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 2fe1408b6811
child 4 837f303aceeb
     1.1 --- a/epoc32/include/icl/imageprocessor.h	Tue Mar 16 16:12:26 2010 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,526 +0,0 @@
     1.4 -// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 -// All rights reserved.
     1.6 -// This component and the accompanying materials are made available
     1.7 -// 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.8 -// which accompanies this distribution, and is available
     1.9 -// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.10 -//
    1.11 -// Initial Contributors:
    1.12 -// Nokia Corporation - initial contribution.
    1.13 -//
    1.14 -// Contributors:
    1.15 -//
    1.16 -// Description:
    1.17 -//
    1.18 -
    1.19 -#ifndef ___IMAGEPROCESSOR_H__
    1.20 -#define ___IMAGEPROCESSOR_H__
    1.21 -
    1.22 -#include <gdi.h>
    1.23 -#include <fbs.h>
    1.24 -
    1.25 -/**
    1.26 -@internalTechnology
    1.27 -*/
    1.28 -enum TImageBitmapUtilPanic
    1.29 -	{
    1.30 -	ECorrupt
    1.31 -	};
    1.32 -
    1.33 -/**
    1.34 -@publishedAll
    1.35 -@released
    1.36 -
    1.37 -Interface to colour conversion classes for various display modes.
    1.38 -Manages the mapping between RGB/Greyscale values and the index
    1.39 -into the color palette for the given display mode.
    1.40 -*/
    1.41 -class TColorConvertor
    1.42 -	{
    1.43 -public:
    1.44 -	IMPORT_C static	TColorConvertor* NewL(TDisplayMode aDisplayMode);
    1.45 -
    1.46 -	/**
    1.47 -	Returns the colour index corresponding to the supplied RGB value.
    1.48 -	Operates in the context of the current display mode.
    1.49 -
    1.50 -	This is a virtual function that each derived class must implement.
    1.51 -
    1.52 -	@param  aColor
    1.53 -	        The colour in RGB format.
    1.54 -	
    1.55 -	@return The colour index.
    1.56 -	*/
    1.57 -	virtual TInt ColorIndex(TRgb aColor) const = 0;
    1.58 -
    1.59 -	/**
    1.60 -	Returns the RGB value corresponding to the supplied colour index.
    1.61 -	Operates in the context of the current display mode.
    1.62 -
    1.63 -	This is a virtual function that each derived class must implement.
    1.64 -
    1.65 -	@param  aColorIndex
    1.66 -	        The colour in RGB format.
    1.67 -
    1.68 -	@return The RGB value.
    1.69 -	*/
    1.70 -	virtual TRgb Color(TInt aColorIndex) const = 0;
    1.71 -
    1.72 -	/**
    1.73 -	Gets an array of colour indices from a corresponding array of RGB values.
    1.74 -	Operates in the context of the current display mode.
    1.75 -
    1.76 -	This is a virtual function that each derived class must implement.
    1.77 -
    1.78 -	@param  aIndexBuffer
    1.79 -	        A pointer to the first element in destination array.
    1.80 -	@param  aColorBuffer
    1.81 -	        A pointer to the first element in the source array.
    1.82 -	@param  aCount
    1.83 -	        The number of elements to get.
    1.84 -	*/
    1.85 -	virtual void ColorToIndex(TInt* aIndexBuffer,TRgb* aColorBuffer,TInt aCount) const = 0;
    1.86 -
    1.87 -	inline static TInt RgbToMonochrome(TRgb aRgb);
    1.88 -	};
    1.89 -
    1.90 -
    1.91 -/**
    1.92 -@publishedAll
    1.93 -@released
    1.94 -
    1.95 -Bitmap utility class.
    1.96 -*/
    1.97 -class TImageBitmapUtil
    1.98 -	{
    1.99 -public:
   1.100 -	IMPORT_C TImageBitmapUtil();
   1.101 -	IMPORT_C void Begin();
   1.102 -	IMPORT_C TBool Begin(const TPoint& aPosition);
   1.103 -	IMPORT_C void End();
   1.104 -	IMPORT_C void SetBitmapL(CFbsBitmap* aBitmap);
   1.105 -	IMPORT_C void SetPixel(TUint32 aPixelIndex);
   1.106 -	IMPORT_C void SetPixels(TUint32* aPixelIndex,TInt aNumberOfPixels);
   1.107 -	IMPORT_C TBool SetPos(const TPoint& aPosition);
   1.108 -	
   1.109 -private:
   1.110 -	union TDataPointer
   1.111 -		{
   1.112 -		TUint32* iWordPos;
   1.113 -		TUint8* iBytePos;
   1.114 -		};
   1.115 -private:
   1.116 -	CFbsBitmap* iBitmap;
   1.117 -	TSize iSize;
   1.118 -	TPoint iPosition;
   1.119 -	TDataPointer iData;
   1.120 -	TDataPointer iBase;
   1.121 -	TInt iBpp;
   1.122 -	TInt iBppShift;
   1.123 -	TInt iPixelShift;
   1.124 -	TInt iPixelsPerWord;
   1.125 -	TInt iBitShift;
   1.126 -	TInt iScanlineWordLength;
   1.127 -	TUint32 iMask;
   1.128 -	TBool iWordAccess;
   1.129 -	};
   1.130 -
   1.131 -
   1.132 -class CImageProcessor;
   1.133 -class CImageProcessorExtension;
   1.134 -
   1.135 -/**
   1.136 -@publishedAll
   1.137 -@released
   1.138 -
   1.139 -Utility class providing static factory functions for creating instances of
   1.140 -CImageProcessor derived classes.
   1.141 -*/
   1.142 -class ImageProcessorUtility
   1.143 -	{
   1.144 -public:
   1.145 -	IMPORT_C static TInt ReductionFactor(const TSize& aOriginalSize,const TSize& aReducedSize);
   1.146 -	IMPORT_C static CImageProcessor* NewImageProcessorL(const CFbsBitmap& aBitmap,const TSize& aImageSize,TDisplayMode aImageDisplayMode, TBool aDisableErrorDiffusion);
   1.147 -	IMPORT_C static CImageProcessor* NewImageProcessorL(const CFbsBitmap& aBitmap,TInt aReductionFactor,TDisplayMode aImageDisplayMode, TBool aDisableErrorDiffusion);
   1.148 -	IMPORT_C static CImageProcessorExtension* ImageProcessorUtility::NewImageProcessorExtensionL(const CFbsBitmap& aBitmap,TInt aReductionFactor,TDisplayMode aImageDisplayMode, TBool aDisableErrorDiffusion);
   1.149 -	
   1.150 -private:
   1.151 -	TBool static UseErrorDiffuser(const TDisplayMode& aBitmapDisplayMode, const TDisplayMode& aImageDisplayMode);
   1.152 -	TBool static IsMonochrome(const TDisplayMode& aBitmapDisplayMode, const TDisplayMode& aImageDisplayMode);
   1.153 -	};
   1.154 -
   1.155 -
   1.156 -
   1.157 -/**
   1.158 -@publishedAll
   1.159 -@released
   1.160 -
   1.161 -Interface to image processing classes.
   1.162 -*/
   1.163 -class CImageProcessor : public CBase
   1.164 -	{
   1.165 -public:
   1.166 -	// Setup
   1.167 -
   1.168 -	/**
   1.169 -	Initialises internal data structures prior to conversion.
   1.170 -
   1.171 -	This is a virtual function that each derived class must implement.
   1.172 -
   1.173 -	@param  aBitmap
   1.174 -	        A reference to a fully constucted bitmap with the required
   1.175 -	        display mode and size.
   1.176 -	@param  aImageRect
   1.177 -	        The region of the image to convert.
   1.178 -	*/
   1.179 -	virtual void PrepareL(CFbsBitmap& aBitmap,const TRect& aImageRect) = 0;
   1.180 -
   1.181 -	/**
   1.182 -	Initialises internal data structures prior to the manipulation of the specified pixel block.
   1.183 -
   1.184 -	This overloaded version allows specification of a block size
   1.185 -	for those formats which support blocked pixel data eg. JPEG
   1.186 -
   1.187 -	This is a virtual function that each derived class must implement.
   1.188 -
   1.189 -	@param  aBitmap
   1.190 -	        A reference to a fully constucted bitmap with the required
   1.191 -	        display mode and size.
   1.192 -	@param  aImageRect
   1.193 -	        The region of the image to convert.
   1.194 -	@param  aRgbBlockSize
   1.195 -	        The size of the block to use.
   1.196 -	*/
   1.197 -	virtual void PrepareL(CFbsBitmap& aBitmap,const TRect& aImageRect,const TSize& aRgbBlockSize) = 0;
   1.198 -
   1.199 -	/**
   1.200 -	Sets the number of pixels by which to increment the current position in
   1.201 -	the Y-axis. This is used when rendering images supporting interlacing.
   1.202 -	eg GIF
   1.203 -
   1.204 -	This is a virtual function that each derived class must implement.
   1.205 -
   1.206 -	@param  aYInc
   1.207 -	        The number of pixels.
   1.208 -	*/
   1.209 -	virtual void SetYPosIncrement(TInt aYInc) = 0;
   1.210 -
   1.211 -	/**
   1.212 -	Sets the number times the current line should be repeated. The lines
   1.213 -	are repeated in the same direction as set by SetYPosIncrement(). This
   1.214 -	is used to fill blank lines when rendering interlaced images. eg GIF.
   1.215 -	@param aLineRepeat The number of times the current line should be repeated
   1.216 -	*/
   1.217 -	virtual void SetLineRepeat(TInt aLineRepeat) = 0;
   1.218 -
   1.219 -	/**
   1.220 -	Sets the pixel padding to the value specified by aNumberOfPixels.
   1.221 -
   1.222 -	This is a virtual function that each derived class must implement.
   1.223 -
   1.224 -	@param  aNumberOfPixels
   1.225 -	        The number of pixels to use for padding.
   1.226 -	*/
   1.227 -	virtual void SetPixelPadding(TInt aNumberOfPixels) = 0;
   1.228 -
   1.229 -	// Color pixel writing
   1.230 -
   1.231 -	/**
   1.232 -	Sets the pixel at the current position to aColor.
   1.233 -
   1.234 -	This is a virtual function that each derived class must implement.
   1.235 -	
   1.236 -	@post    
   1.237 -	The current position is updated.
   1.238 -
   1.239 -	@param  aColor
   1.240 -	        The RGB value to set the current pixel to.
   1.241 -
   1.242 -	@return A boolean indicating if the operation was successful. ETrue if the operation succeeded, 
   1.243 -            otherwise EFalse.
   1.244 -    */
   1.245 -	virtual TBool SetPixel(TRgb aColor) = 0;
   1.246 -
   1.247 -	/**
   1.248 -	Sets aCount number of pixels to the value given by aColor, starting at
   1.249 -	the current position.
   1.250 -
   1.251 -	This is a virtual function that each derived class must implement.
   1.252 -
   1.253 -	@post    
   1.254 -	On success, the current position is updated.
   1.255 -
   1.256 -	@param  aColor
   1.257 -	        The RGB value to set the pixels to.
   1.258 -	@param  aCount
   1.259 -	        The number of pixels to set.
   1.260 -
   1.261 -	@return A boolean indicating if the operation was successful. ETrue if the operation succeeded, 
   1.262 -	        otherwise EFalse.
   1.263 -	*/
   1.264 -	virtual TBool SetPixelRun(TRgb aColor,TInt aCount) = 0;
   1.265 -
   1.266 -	/**
   1.267 -	Updates the bitmap with colour information from the array of colour values.
   1.268 -
   1.269 -	Uses the array of colour values supplied by aColorBuffer, whose length
   1.270 -	is specified by aBufferLength, to update successive pixels with values in the
   1.271 -	buffer, starting at the current	position.
   1.272 -
   1.273 -	This is a virtual function that each derived class must implement.
   1.274 -	
   1.275 -	@post   
   1.276 -	The current position is updated.
   1.277 -
   1.278 -	@param  aColorBuffer
   1.279 -	        A pointer to the first element in the array.
   1.280 -	@param  aBufferLength
   1.281 -	        The number of elements in the array.
   1.282 -
   1.283 -	@return A boolean indicating if the operation was successful. ETrue if the operation succeeded, 
   1.284 -	        otherwise EFalse.
   1.285 -	*/
   1.286 -	virtual TBool SetPixels(TRgb* aColorBuffer,TInt aBufferLength) = 0;
   1.287 -
   1.288 -    /**
   1.289 -    Sets the current pixel block using the data supplied in aColorBuffer.
   1.290 -
   1.291 -	Note:
   1.292 -	For use with image types that support blocking of pixels eg JPEG.
   1.293 -
   1.294 -	This is a virtual function that each derived class must implement.
   1.295 -
   1.296 -	@param  aColorBuffer
   1.297 -	        A pointer to a buffer representing a block of pixel color values.
   1.298 -
   1.299 -	@return A boolean indicating if the operation was successful. ETrue if the operation succeeded, 
   1.300 -	        otherwise EFalse.
   1.301 -	*/
   1.302 -	virtual TBool SetPixelBlock(TRgb* aColorBuffer) = 0;
   1.303 -
   1.304 -	// Monochrome pixel writing
   1.305 -
   1.306 -	/**
   1.307 -	Sets the pixel at the current position to aGray256.
   1.308 -
   1.309 -	This is a virtual function that each derived class must implement.
   1.310 -
   1.311 -    @post   
   1.312 -	The current position is updated.
   1.313 -
   1.314 -	@param  aGray256
   1.315 -	        The greyscale value to set the current pixel to.
   1.316 -
   1.317 -	@return A boolean indicating if the operation was successful. ETrue if the operation succeeded, 
   1.318 -	        otherwise EFalse.
   1.319 -	*/
   1.320 -	virtual TBool SetMonoPixel(TInt aGray256) = 0;
   1.321 -
   1.322 -	/**
   1.323 -	Sets the number of pixels specified by aCount to the value given by aGray256, starting at
   1.324 -	the current position.
   1.325 -
   1.326 -	This is a virtual function that each derived class must implement.
   1.327 -	
   1.328 -	@post   
   1.329 -	The current position is updated.
   1.330 -
   1.331 -	@param  aGray256
   1.332 -	        The greyscale value to set the pixels to.
   1.333 -	@param  aCount
   1.334 -	        The number of pixels to set.
   1.335 -
   1.336 -	@return A boolean indicating if the operation was successful. ETrue if the operation succeeded, 
   1.337 -	        otherwise EFalse.
   1.338 -	*/
   1.339 -	virtual TBool SetMonoPixelRun(TInt aGray256,TInt aCount) = 0;
   1.340 -
   1.341 -	/**
   1.342 -	Updates the bitmap with greyscale information from the array of greyscale values.
   1.343 -
   1.344 -	The array of values supplied by aGray256Buffer, whose length
   1.345 -	is specified in aBufferLength, is used to update successive pixels with the
   1.346 -	greyscales values.
   1.347 -
   1.348 -	This is a virtual function that each derived class must implement.
   1.349 -
   1.350 -	@post
   1.351 -	The current position is updated.
   1.352 -
   1.353 -	@param  aGray256Buffer
   1.354 -	        A pointer to the first element in the array of greyscale values.
   1.355 -	@param  aBufferLength
   1.356 -	        The number of elements in the array.
   1.357 -
   1.358 -	@return A boolean indicating if the operation was successful. ETrue if the operation succeeded, 
   1.359 -	        otherwise EFalse.
   1.360 -	*/
   1.361 -	virtual TBool SetMonoPixels(TUint32* aGray256Buffer,TInt aBufferLength) = 0;
   1.362 -
   1.363 -    /**
   1.364 -    Sets a specified number of pixels to the specified greyscale value.
   1.365 -
   1.366 -	For image types which support blocking of pixels eg JPEG, the current
   1.367 -	pixel block is set using the data supplied in aGray256Buffer.
   1.368 -
   1.369 -	This is a virtual function that each derived class must implement.
   1.370 -
   1.371 -	@param  aGray256Buffer
   1.372 -	        A pointer to a buffer representing a block of pixel color values.
   1.373 -
   1.374 -	@return A boolean indicating if the operation was successful. ETrue if the operation succeeded, 
   1.375 -	        otherwise EFalse.
   1.376 -	*/
   1.377 -	virtual TBool SetMonoPixelBlock(TUint32* aGray256Buffer) = 0;
   1.378 -
   1.379 -	// Processor flow control
   1.380 -
   1.381 -	/**
   1.382 -	Sets the current position in the bitmap to aPosition.
   1.383 -
   1.384 -	This is a virtual function that each derived class must implement.
   1.385 -
   1.386 -	@param  aPosition
   1.387 -	        A reference to TPoint object defining the position to move to.
   1.388 -
   1.389 -	@return	A boolean indicating if the operation was successful. ETrue if the operation succeeded, 
   1.390 -	        otherwise EFalse.
   1.391 -	*/
   1.392 -	virtual TBool SetPos(const TPoint& aPosition) = 0;
   1.393 -
   1.394 -	/**
   1.395 -	Commits the changes made to the current bitmap by flushing the buffer.
   1.396 -
   1.397 -	This is a virtual function that each derived class must implement.
   1.398 -
   1.399 -	@post
   1.400 -	The current position is updated.
   1.401 -
   1.402 -	@return	A boolean indicating if the operation was successful. ETrue if the operation succeeded, 
   1.403 -	        otherwise EFalse.
   1.404 -    */
   1.405 -	virtual TBool FlushPixels() = 0;
   1.406 -	
   1.407 -private:
   1.408 -	// Future proofing
   1.409 -	IMPORT_C virtual void ReservedVirtual1();
   1.410 -	IMPORT_C virtual void ReservedVirtual2();
   1.411 -	IMPORT_C virtual void ReservedVirtual3();
   1.412 -	IMPORT_C virtual void ReservedVirtual4();
   1.413 -	};
   1.414 -
   1.415 -/**
   1.416 -@publishedAll
   1.417 -@released
   1.418 -
   1.419 -Flag used to determine the type of transformation which is the result of 
   1.420 -single or multiple transformation operations requested via calls to
   1.421 -COperationExtension::AddOperationL.
   1.422 -
   1.423 -8 unique orientations:
   1.424 -
   1.425 -@code
   1.426 -normal  90      180     270
   1.427 -00 10   01 00   11 01   10 11
   1.428 -01 11   11 10   10 00   00 01
   1.429 -
   1.430 -V flip  90      180     270
   1.431 -10 00   11 10   =Hflip  =Hflip+90
   1.432 -11 01   01 00
   1.433 -
   1.434 -H flip  90      180     270
   1.435 -01 11   00 01   =Vflip  =Vflip+90
   1.436 -00 10   10 11
   1.437 -@endcode
   1.438 -
   1.439 -@see COperationExtension::AddOperationL
   1.440 -*/
   1.441 -enum TTransformOptions
   1.442 -	{
   1.443 -	/** Normal Decode
   1.444 -	*/
   1.445 -	EDecodeNormal = 0x11011000,
   1.446 -
   1.447 -	/** Rotate 90 degrees.
   1.448 -	*/
   1.449 -	EDecodeRotate90	= 0x10110001,
   1.450 -
   1.451 -	/** Rotate 180 degrees.
   1.452 -	*/
   1.453 -	EDecodeRotate180 = 0x00100111,
   1.454 -
   1.455 -	/** Rotate 270 degrees.
   1.456 -	*/
   1.457 -	EDecodeRotate270 = 0x01001110,
   1.458 -	
   1.459 -	/** Horizontal flip.
   1.460 -	*/
   1.461 -	EDecodeHorizontalFlip = 0x10001101,
   1.462 -	
   1.463 -	/** Horizontal flip and rotate 90 degrees.
   1.464 -	*/
   1.465 -	EDecodeHorizontalFlipRotate90 = 0x11100100,
   1.466 -
   1.467 -	/** Vertical flip.
   1.468 -	*/
   1.469 -	EDecodeVerticalFlip	= 0x01110010,
   1.470 -
   1.471 -	/** Vertical flip and rotate 90 degrees.
   1.472 -	*/
   1.473 -	EDecodeVerticalFlipRotate90 = 0x00011011
   1.474 -	};
   1.475 -
   1.476 -
   1.477 -/**
   1.478 -@publishedAll
   1.479 -@released
   1.480 -
   1.481 -Class that provides support for Framework Extensions.
   1.482 -
   1.483 -@see CImageProcessor
   1.484 -@see CImageReadCodec
   1.485 -@see CImageDecoderPlugin
   1.486 -*/
   1.487 -class CImageProcessorExtension : public CImageProcessor
   1.488 -	{
   1.489 -public:
   1.490 -	IMPORT_C virtual ~CImageProcessorExtension();
   1.491 -	IMPORT_C void SetClippingRect(const TRect& aRect);
   1.492 -	IMPORT_C void SetScaling(TInt aScalingCoeff);
   1.493 -	IMPORT_C void SetScaling(const TSize& aDesiredSize);
   1.494 -	IMPORT_C void SetOperation(TTransformOptions aOperation);
   1.495 -	IMPORT_C void SetInitialScanlineSkipPadding(TInt aNumberOfScanlines);
   1.496 -
   1.497 -protected:
   1.498 -	IMPORT_C CImageProcessorExtension();
   1.499 -
   1.500 -protected:
   1.501 -	/** Clipping rectangle */
   1.502 -	TRect iClippingRect;
   1.503 -	/** Scaling coefficient */
   1.504 -	TInt iScalingCoeff;
   1.505 -	/** Desired size after scaling */
   1.506 -	TSize iDesiredSize;
   1.507 -	/** Operations to apply to image */
   1.508 -	TTransformOptions iOperation;
   1.509 -	/** Position in destination at which start rendering */
   1.510 -	TPoint iStartPosition;
   1.511 -	/** Position in destination at which rendering is complete */
   1.512 -	TPoint iEndPosition;
   1.513 -	/** An initial one-off number of scanlines to be skipped */
   1.514 -	TInt iNumberOfScanlinesToSkip;
   1.515 -	};
   1.516 -   
   1.517 -inline TInt TColorConvertor::RgbToMonochrome(TRgb aRgb)
   1.518 -	{
   1.519 -	TInt value = aRgb.Internal();
   1.520 -	TInt r = value&0xFF0000;
   1.521 -	TInt g = value&0xFF00;
   1.522 -	value  = (value&0xFF)<<16;	// blue<<16
   1.523 -	value += r<<1;     		// + (red<<16)*2
   1.524 -	value += g<<(16+2-8);	// + (green<<16)*4
   1.525 -	value += g<<(16+0-8);	// + (green<<16)
   1.526 -	return value>>(16+3);	// total/8
   1.527 -	}
   1.528 -
   1.529 -#endif //___IMAGEPROCESSOR_H__