sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef PIXELUTIL_H sl@0: #define PIXELUTIL_H sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: */ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: /** sl@0: Provides conversion between TDisplayMode/TUidPixelFormat and other pixel format related functionality. sl@0: */ sl@0: NONSHARABLE_STRUCT(PixelFormatUtil) sl@0: { sl@0: static TUidPixelFormat ConvertToPixelFormat(TDisplayMode aDisplayMode); sl@0: static TBool HasAlpha(TUidPixelFormat aPixelFormat); sl@0: static TInt BitsPerPixel(TUidPixelFormat aPixelFormat); sl@0: static TDisplayMode ConvertToDisplayMode(TUidPixelFormat aPixelFormat); sl@0: }; sl@0: sl@0: /** sl@0: Provides access to the contents of a pixel buffer. Functionality includes copying pixels into sl@0: user buffer and perform format conversion or scaling up/down. Copying can be performed sl@0: horizontally from left to right or right to left, and vertically from top to bottom or bottom sl@0: to up. sl@0: sl@0: Supported buffer pixel format: sl@0: -EUidPixelFormatRGB_565 sl@0: -EUidPixelFormatXRGB_8888 sl@0: -EUidPixelFormatARGB_8888 sl@0: -EUidPixelFormatARGB_8888_PRE sl@0: sl@0: Supported read pixel format: sl@0: -EUidPixelFormatRGB_565 sl@0: -EUidPixelFormatXRGB_8888 sl@0: -EUidPixelFormatARGB_8888 sl@0: -EUidPixelFormatARGB_8888_PRE sl@0: */ sl@0: NONSHARABLE_CLASS(TPixelBufferReader) sl@0: { sl@0: public: sl@0: enum TReadDirection sl@0: { sl@0: EReadHorizontal, sl@0: EReadHorizontalReverse, sl@0: EReadVertical, sl@0: EReadVerticalReverse sl@0: }; sl@0: sl@0: TPixelBufferReader(const TUint32* aPixelBuffer, const TSize& aSize, TInt aStride,TUidPixelFormat aFormat); sl@0: sl@0: void GetScanLine(TDes8& aReadBuf, const TPoint& aReadPos, TInt aReadLen, sl@0: TUidPixelFormat aReadFormat, TReadDirection aReadDir) const; sl@0: void GetScaledScanLine(TDes8& aReadBuf, const TPoint& aReadPos, TInt aClipDestPos, sl@0: TInt aClipDestLen, TInt aDestLen, TInt aSrcLen, TUidPixelFormat aReadFormat, sl@0: TReadDirection aReadDir) const; sl@0: sl@0: const TUint32* GetPixelAddr(const TPoint& aPos) const; sl@0: sl@0: private: sl@0: TPixelBufferReader(); //declare but not defined sl@0: const TUint32* GetScanLineAddr(TInt aRow) const; sl@0: sl@0: void GetScanLineRGB_565(TDes8& aReadBuf, const TPoint& aReadPos, TInt aReadLen, TReadDirection aReadDir) const; sl@0: void GetScanLineXRGB_8888(TDes8& aReadBuf, const TPoint& aReadPos, TInt aReadLen, TReadDirection aReadDir) const; sl@0: void GetScanLineARGB_8888(TDes8& aReadBuf, const TPoint& aReadPos, TInt aReadLen, TReadDirection aReadDir) const; sl@0: void GetScanLineARGB_8888_PRE(TDes8& aReadBuf, const TPoint& aReadPos, TInt aReadLen, TReadDirection aReadDir) const; sl@0: sl@0: void CopyFromRGB_565(TUint32* aDestPtr, const TUint16* aSrcPtr, TInt aLen, TInt aAdvance) const; sl@0: TInt GetAdvance(TReadDirection aReadDir) const; sl@0: sl@0: void GetScaledScanLineH(TDes8& aReadBuf, const TPoint& aReadPos, TInt aClipDestPos, sl@0: TInt aClipDestLen, TInt aDestLen, TInt aSrcLen, TUidPixelFormat aReadFormat, sl@0: TReadDirection aReadDir) const; sl@0: void GetScaledScanLineV(TDes8& aReadBuf, const TPoint& aReadPos, TInt aClipDestPos, sl@0: TInt aClipDestLen, TInt aDestLen, TInt aSrcLen, TUidPixelFormat aReadFormat, sl@0: TReadDirection aReadDir) const; sl@0: sl@0: private: sl@0: const TUint32* iBuffer; sl@0: TSize iSize; sl@0: TInt iStride; sl@0: TUidPixelFormat iFormat; sl@0: }; sl@0: sl@0: #endif /*PIXELUTIL_H*/