testtoolsconn/stat/desktop/source/lib/inc/cstatdataformatconverter.h
changeset 0 3da2a79470a7
equal deleted inserted replaced
-1:000000000000 0:3da2a79470a7
       
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef CSTATDataFormatConverter_H
       
    22 #define CSTATDataFormatConverter_H
       
    23 
       
    24 #include <oaidl.h>
       
    25 #include <statcommon.h>
       
    26 #include "CSTATLogfile.h"
       
    27 
       
    28 const long int KWriteOnceFileStoreUid=268435511;
       
    29 const long int KMultiBitmapFileImageUid=268435522;
       
    30 const long int KMultiBitmapFileImageChecksum=1194943545;
       
    31 
       
    32 enum TBitmapColor
       
    33 {
       
    34 	EMonochromeBitmap,
       
    35 	EColorBitmap
       
    36 };
       
    37 
       
    38 enum TBitmapfileCompression
       
    39 {
       
    40 	ENoBitmapCompression=0,
       
    41 	EByteRLECompression,
       
    42 	ETwelveBitRLECompression,
       
    43 	ESixteenBitRLECompression,
       
    44 	ETwentyFourBitRLECompression
       
    45 };
       
    46 
       
    47 struct SEpocBitmapHeader
       
    48 {
       
    49 	long iBitmapSize;
       
    50 	long iStructSize;
       
    51 	long iWidthInPixels;
       
    52 	long iHeightInPixels;
       
    53 	long iWidthInTwips;
       
    54 	long iHeightInTwips;
       
    55 	long iBitsPerPixel;
       
    56 	TBitmapColor iColor;
       
    57 	long iPaletteEntries;	// always 0 in current implementations
       
    58 	TBitmapfileCompression iCompression;
       
    59 };
       
    60 
       
    61 #include <pshpack2.h>
       
    62 struct TRgbTriple
       
    63 {
       
    64 	unsigned char rgbtBlue;
       
    65 	unsigned char rgbtGreen;
       
    66 	unsigned char rgbtRed;
       
    67 };
       
    68 #include <poppack.h>
       
    69 
       
    70 struct TRgbQuad
       
    71 {
       
    72 	unsigned char iBlue;
       
    73 	unsigned char iGreen;
       
    74 	unsigned char iRed;
       
    75 	unsigned char iReserved;
       
    76 };
       
    77 
       
    78 class TRgb
       
    79 {
       
    80 public:
       
    81 	TRgb();
       
    82 	TRgb(long unsigned int val);
       
    83 	TRgb(int aRed,int aGreen,int aBlue);
       
    84 	TRgb &operator=(const TRgb& aColor);
       
    85 	int operator==(const TRgb& aColor);
       
    86 	int Difference(const TRgb& col) const;
       
    87 	int Gray2() const;
       
    88 	int Gray4() const;
       
    89 	int Gray16() const;
       
    90 	int Gray256() const;
       
    91 	int Color16() const;
       
    92 	int Color256() const;
       
    93 	int Color4K() const;
       
    94 	int Color64K() const;
       
    95 	long int Color16M() const;
       
    96 	static TRgb Gray2(int aGray2);
       
    97 	static TRgb Gray4(int aGray4);
       
    98 	static TRgb Gray16(int aGray16);
       
    99 	static TRgb Gray256(int aGray256);
       
   100 	static TRgb Color16(int aColor16);
       
   101 	static TRgb Color256(int aColor256);
       
   102 	static TRgb Color4K(int aColor64K);
       
   103 	static TRgb Color64K(int aColor64K);
       
   104 	static TRgb Color16M(long int aColor16M);
       
   105 public:
       
   106 	unsigned char iRed;
       
   107 	unsigned char iGreen;
       
   108 	unsigned char iBlue;
       
   109 	unsigned char iSpare;
       
   110 };
       
   111 
       
   112 class CSTATDataFormatConverter : public VARIANT
       
   113 {
       
   114 	public:
       
   115 		CSTATDataFormatConverter(CSTATLogFile *pLog);
       
   116 		virtual ~CSTATDataFormatConverter();
       
   117 		bool ConvertStringToUnicode(CString& data);
       
   118 		int ConvertScreenShot(CString &mbmdirectory, CString &destptr);
       
   119 		void GetScreenshotData(TBitmapFileHeader **ppFHeader, TBitmapInfoHeader **ppBMPHeader, char **ppBits, unsigned long *pSize)
       
   120 		{
       
   121 			*ppFHeader = &fileheader;
       
   122 			*ppBMPHeader = &bmpHeader;
       
   123 			*ppBits = bmpBits;
       
   124 			*pSize = lDataSize;
       
   125 		}
       
   126 
       
   127 		bool bWriteToFile;						// flag to write bitmap out to disk or not
       
   128 
       
   129 	private:
       
   130 		void EnsureBufSize(int size);
       
   131 		int LoadBitmap(CString &file);
       
   132 		int SaveBitmap(CString &file);
       
   133 		bool ExpandByteRLEData(char* aDest,int aDestSize,char* aSrce,int aSrceSize);
       
   134 		bool ExpandTwelveBitRLEData(char* aDest,int aDestSizeInBytes,char* aSrce,int aSrceSizeInBytes);
       
   135 		bool ExpandSixteenBitRLEData(char* aDest,int aDestSizeInBytes,char* aSrce,int aSrceSizeInBytes);
       
   136 		bool ExpandTwentyFourBitRLEData(char* aDest,int aDestSizeInBytes,char* aSrce,int aSrceSizeInBytes);
       
   137 		TRgb GetPixel(int aXCoord,int aYCoord);
       
   138 		int ByteWidth(int aPixelWidth,int aBitsPerPixel);
       
   139 
       
   140 		CSTATLogFile *pLogFile;					// pointer to our logging class
       
   141 		BYTE* m_index;							// command buffer access
       
   142 		int m_bufsize;							// command buffer size
       
   143 
       
   144 		SEpocBitmapHeader iPbmHeader;			// EPOC screenshot header info
       
   145 		char* pPbmBits;							// EPOC screenshot data
       
   146 		TBitmapFileHeader fileheader;			// converted screenshot header info
       
   147 		TBitmapInfoHeader bmpHeader;			// converted screenshot bitmap info
       
   148 		char* bmpBits;							// converted screenshot data
       
   149 		unsigned long lDataSize;
       
   150 };
       
   151 
       
   152 #endif