Revision: 201003 default
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 02 Feb 2010 01:11:11 +0200
changeset 0 f453ebb75370
child 1 23f0e6a5b752
Revision: 201003 Kit: 201005
gfxconversion/bmconv_s60/group/bld.inf
gfxconversion/bmconv_s60/group/bmconv.mmp
gfxconversion/bmconv_s60/src/BMCONV.H
gfxconversion/bmconv_s60/src/BMTOPBM.CPP
gfxconversion/bmconv_s60/src/MAINFUNC.CPP
gfxconversion/bmconv_s60/src/PBMCOMP.CPP
gfxconversion/bmconv_s60/src/PBMTOBM.CPP
gfxconversion/bmconv_s60/src/RGB.CPP
gfxconversion/bmconv_s60/src/RGB.H
gfxconversion/bmconv_s60/src/TOOLSVER.H
gfxconversion/bmconv_s60/src/UTILS.CPP
gfxconversion/group/bld.inf
gfxconversion/mifconv/group/ReleaseNotes_Mifconv.txt
gfxconversion/mifconv/group/bld.inf
gfxconversion/mifconv/group/mifconv.mmp
gfxconversion/mifconv/inc/mifconv.h
gfxconversion/mifconv/inc/mifconv_argument.h
gfxconversion/mifconv/inc/mifconv_argumentmanager.h
gfxconversion/mifconv/inc/mifconv_bitmapconverter.h
gfxconversion/mifconv/inc/mifconv_bitmapheaderconverter.h
gfxconversion/mifconv/inc/mifconv_convertermanager.h
gfxconversion/mifconv/inc/mifconv_exception.h
gfxconversion/mifconv/inc/mifconv_fileconverter.h
gfxconversion/mifconv/inc/mifconv_iconbinaryconverter.h
gfxconversion/mifconv/inc/mifconv_mifconverter.h
gfxconversion/mifconv/inc/mifconv_sourcefile.h
gfxconversion/mifconv/inc/mifconv_types.h
gfxconversion/mifconv/inc/mifconv_util.h
gfxconversion/mifconv/makefile_templates/config/export.mk
gfxconversion/mifconv/makefile_templates/makefile
gfxconversion/mifconv/makefile_templates/mifconv.flm
gfxconversion/mifconv/makefile_templates/mifconv.meta
gfxconversion/mifconv/makefile_templates/mifconv.mk
gfxconversion/mifconv/makefile_templates/mifconv.xml
gfxconversion/mifconv/makefile_templates/mifconv_global_options.make
gfxconversion/mifconv/makefile_templates/mifconv_option_reader.make
gfxconversion/mifconv/makefile_templates/mifconv_option_reader_recursive.make
gfxconversion/mifconv/makefile_templates/mifconv_step1.make
gfxconversion/mifconv/makefile_templates/mifconv_step2.make
gfxconversion/mifconv/makefile_templates/mifconv_step3.make
gfxconversion/mifconv/makefile_templates/mifconv_step4.make
gfxconversion/mifconv/src/mifconv.cpp
gfxconversion/mifconv/src/mifconv_argument.cpp
gfxconversion/mifconv/src/mifconv_argumentmanager.cpp
gfxconversion/mifconv/src/mifconv_bitmapconverter.cpp
gfxconversion/mifconv/src/mifconv_bitmapheaderconverter.cpp
gfxconversion/mifconv/src/mifconv_convertermanager.cpp
gfxconversion/mifconv/src/mifconv_exception.cpp
gfxconversion/mifconv/src/mifconv_iconbinaryconverter.cpp
gfxconversion/mifconv/src/mifconv_mifconverter.cpp
gfxconversion/mifconv/src/mifconv_sourcefile.cpp
gfxconversion/mifconv/src/mifconv_util.cpp
group/bld.inf
layers.sysdef.xml
package_definition.xml
sysdef_1_4_0.dtd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/bmconv_s60/group/bld.inf	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+PRJ_PLATFORMS
+#ifdef SBSV2
+  TOOLS2
+#else
+  TOOLS
+#endif
+
+
+PRJ_MMPFILES
+#if defined (TOOLS) || defined(TOOLS2)
+  bmconv.mmp
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/bmconv_s60/group/bmconv.mmp	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include <platform_paths.hrh>
+
+
+TARGET           bmconv.exe
+TARGETTYPE       exe
+
+
+SOURCEPATH       ../src
+SOURCE           MAINFUNC.CPP 
+SOURCE           BMTOPBM.CPP
+SOURCE           PBMCOMP.CPP
+SOURCE           PBMTOBM.CPP
+SOURCE           RGB.CPP
+SOURCE           UTILS.CPP
+
+MW_LAYER_SYSTEMINCLUDE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/bmconv_s60/src/BMCONV.H	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,460 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef __BMCONV_H__
+#define __BMCONV_H__
+
+#include <string.h>
+#ifdef WIN32
+    #include <io.h>
+#else
+    #include <sys/io.h>
+#endif
+
+#if defined (__MSVCDOTNET__) || defined(__TOOLS2__) || defined(__CW32__)
+#include <fstream>
+#include <iostream>
+using namespace std;
+#else //!(__MSVCDOTNET__||__TOOLS2__||__CW32__)
+#include <fstream.h>
+#include <iostream.h>
+#endif //!(__MSVCDOTNET__||__TOOLS2__||__CW32__)
+
+#include <stdlib.h>
+
+#ifdef __linux__
+    #define GNUPACK __attribute__((packed)) 
+    #define OPTCHAR '-'
+    /* on Linux the '/' optchar cannot be supported as filenames can start with '/'. */
+    #define ALTERNATE_OPTCHAR '-'
+#else
+    #define GNUPACK
+    #define OPTCHAR '-' 
+    #define ALTERNATE_OPTCHAR '/'
+#endif
+
+
+/**
+@internalComponent
+*/
+const long int KWriteOnceFileStoreUid=268435511;
+const long int KCBitwiseBitmapUid=268435520;
+const long int KMultiBitmapRomImageUid=268435521;
+const long int KMultiBitmapFileImageUid=268435522;
+const long int KMultiBitmapFileImageChecksum=1194943545;
+/**
+@internalComponent
+*/
+enum TBitmapColor
+	{
+	EMonochromeBitmap,
+	EColorBitmap,
+	EColorBitmapAlpha,	
+	EColorBitmapUndefined	
+	};
+
+/** 
+Defines the types of file compression. 
+@internalComponent
+*/
+enum TBitmapfileCompression
+	{
+	/** Bitmap file is not compressed. */
+	ENoBitmapCompression=0,
+	/** File is compressed using run-length encoding compression. */
+	EByteRLECompression,
+	/** File is compressed using twelve bit run-length encoding compression. */
+	ETwelveBitRLECompression,
+	/** File is compressed using sixteen bit run-length encoding compression. */
+	ESixteenBitRLECompression,
+	/** File is compressed using twenty four bit run-length encoding compression. */
+	ETwentyFourBitRLECompression,
+	/** File is compressed using unsigned thirty two bit run-length encoding compression. */
+	EThirtyTwoUBitRLECompression,
+	/** File is compressed using unsigned thirty two bit run-length encoding compression and includes an alpha channel. */
+	EThirtyTwoABitRLECompression,
+	/** Insert new compression types here */
+	ERLECompressionLast = 255
+	};
+/**
+@internalComponent
+*/
+enum TStoreType
+	{
+	ENoStore,
+	EFileStore,
+	ERomStore,
+	ECompressedRomStore
+	};
+/**
+@internalComponent
+*/
+enum Errors
+	{
+	NoCompression=-1,
+	NoError=0,
+	NoMemory,
+	Arg,
+	Files,
+	SourceFile,
+	DestFile,
+	CommandFile,
+	OutOfRange,
+	TooManyArgs,
+	UnknownCompression,
+	CompressionError,
+	DecompressionError,
+	Bpp,
+	PaletteFile,
+	PaletteSupportNotImplemented,
+	AlphaFiles,
+	AlphaDimensions,
+	AlphaBpp
+	};
+/**
+@internalComponent
+*/
+struct SEpocBitmapHeader
+/** Contains information about the bitmap when streaming bitmaps to stores. */
+	{
+	/** The size of the bitmap data, in bytes. */
+	long iBitmapSize;
+	/** The size of the structure in which the bitmap data is stored. */
+	long iStructSize;
+	long iWidthInPixels;
+	long iHeightInPixels;
+	long iWidthInTwips;
+	long iHeightInTwips;
+	/** The bitmaps number of bits per pixel */
+	long iBitsPerPixel;
+	/** Whether or not the bitmap is colour. A true value means that the bitmap 
+	is colour. */
+	TBitmapColor iColor;
+	/** The number of entries in the bitmap's palette. */
+	long iPaletteEntries;	// always 0 in current implementations
+	/** The type of compression used to store the bitmap. */
+	TBitmapfileCompression iCompression;
+	};
+
+#ifndef __linux__ 
+#include <pshpack2.h>
+#endif 
+/**
+@internalComponent
+*/
+struct TRgb24bit
+	{
+	unsigned char iBlue;
+	unsigned char iGreen;
+	unsigned char iRed;
+	} GNUPACK;
+#ifndef __linux__ 
+#include <poppack.h>
+#endif 
+
+#ifndef __linux__ 
+#include <pshpack2.h>
+#endif 
+/**
+@internalComponent
+*/
+struct TBitmapFileHeader
+	{
+	unsigned short bfType;
+	unsigned long bfSize;
+	unsigned short bfReserved1;
+	unsigned short bfReserved2;
+	unsigned long bfOffBits;
+	} GNUPACK;
+#ifndef __linux__ 
+#include <poppack.h>
+#endif 
+/**
+@internalComponent
+*/
+struct TBitmapInfoHeader
+	{
+	unsigned long biSize;
+	long biWidth;
+	long biHeight;
+	unsigned short biPlanes;
+	unsigned short biBitCount;
+	unsigned long biCompression;
+	unsigned long biSizeImage;
+	long biXPelsPerMeter;
+	long biYPelsPerMeter;
+	unsigned long biClrUsed;
+	unsigned long biClrImportant;
+	};
+
+#ifndef __linux__ 
+#include <pshpack2.h>
+#endif 
+/**
+@internalComponent
+*/
+struct TRgbTriple
+	{
+	unsigned char rgbtBlue;
+	unsigned char rgbtGreen;
+	unsigned char rgbtRed;
+	} GNUPACK;
+#ifndef __linux__ 
+#include <poppack.h>
+#endif 
+/**
+@internalComponent
+*/
+struct TRgbQuad
+	{
+	unsigned char iBlue;
+	unsigned char iGreen;
+	unsigned char iRed;
+	unsigned char iReserved;
+	};
+
+class TRgb
+/** 
+24-bit RGB colour value with 8 bits each for red, green and blue.
+
+All Graphics drawing functions are specified in terms of a 32-bit TRgb colour 
+containing the three colour values plus 8 unused bits. For hardware which 
+does not support 24-bit colour, a mapping from TRgb to display colours is 
+performed. 
+
+The supported display modes are enumerated in the TDisplayMode type. In each 
+display mode a unique index can represent each physical colours supported, 
+and which can be mapped onto a full RGB value. The mappings are as follows: 
+
+16-colour displays use the EGA colour set: black, white, and then both light 
+and dark versions of grey, red, green, blue, cyan, magenta and yellow
+
+256-colour displays support 216 colours made up of 6x6x6 RGB values, each 
+containing all possible multiples of 51 for R,G,B values. Additionally, all 
+remaining 10 shades of pure red, green, blue and grey are represented, by 
+adding all remaining multiples of 17. This use of 256 colours is sometimes 
+known as the Netscape colour cube.
+
+4096-colour displays effectively support RGB values with 4 bits per primary 
+colour
+
+64k-colour displays effectively support RGB values with 5 bits allocated to 
+red, 6 to green and 5 to blue
+
+16 million-colour displays support true colour with 8 bits allocated to each 
+primary colour
+
+@see TDisplayMode
+@see DynamicPalette 
+@internalComponent
+*/
+	{
+public:
+	TRgb();
+	TRgb(long unsigned int val);
+	TRgb(int aRed,int aGreen,int aBlue);
+	TRgb &operator=(const TRgb& aColor);
+	int operator==(const TRgb& aColor);
+	int Difference(const TRgb& col) const;
+	int Gray2() const;
+	int Gray4() const;
+	int Gray16() const;
+	int Gray256() const;
+	int Color16() const;
+	int Color256() const;
+	int Color4K() const;
+	int Color64K() const;
+	long int Color16M() const;
+	static TRgb Gray2(int aGray2);
+	static TRgb Gray4(int aGray4);
+	static TRgb Gray16(int aGray16);
+	static TRgb Gray256(int aGray256);
+	static TRgb Color16(int aColor16);
+	static TRgb Color256(int aColor256);
+	static TRgb Color4K(int aColor64K);
+	static TRgb Color64K(int aColor64K);
+	static TRgb Color16M(long int aColor16M);
+public:
+	unsigned char iRed;
+	unsigned char iGreen;
+	unsigned char iBlue;
+	unsigned char iSpare;
+	};
+
+class Bitmap
+/**
+@internalComponent
+*/
+	{
+public:
+	int iUid;
+	int iDispMode;
+	void* iHeap;
+	void* iPile;
+	int iByteWidth;
+	SEpocBitmapHeader iHeader;
+	int iChunk;
+	int iDataOffset; // offset from "this"
+	};
+
+class TSourceFile
+	{
+public:
+	enum TCompileInfo
+		{
+		EFormatNotImportant,
+		ENokiaBitmap,
+		EThirdPartyBitmap
+		};
+public:
+	TSourceFile();
+	char*& FileName();
+	void SetCompileInfo(TCompileInfo aInfo);
+	void WriteCompileInfo(ostream& aOut);
+private:
+	char* iFileName;
+	TCompileInfo iInfo;
+	};
+
+class BitmapCompiler
+/**
+Historical note - Pbm is an abbreviation for "Symbian Bitmap"
+@internalComponent
+*/
+	{
+public:
+	BitmapCompiler(TSourceFile* aSourcefilenames,int aNumSources);
+	~BitmapCompiler();
+	int Compile(TStoreType aSt,int aCompress,char* aDestfilename,char* aHeaderFilename,char* aPaletteFilename);
+private:
+	int AllocatePbmSourcesArray();
+	int LoadSourcefiles();
+	int LoadPbmFile(char* aPbmFilename);
+	int RomImage(bool aCompress);
+	int FileImage(int aCompress);
+	int WriteRomheader();
+	int WriteRombitmap(SEpocBitmapHeader* aPbm);
+	int WriteFileheader();
+	int WriteFilebitmap(SEpocBitmapHeader* aPbm);
+	int WriteHeadStream();
+	int CreateHeader(char* aHeaderFilename);
+	char* UnadornedName(char* aName);	// returns pointer to static buffer
+	int LoadPalette(char* aPaletteFilename);
+	void CalculateInversePalette();
+	void WritePalette();
+	int CompressBitmap(SEpocBitmapHeader*& aPbm);
+	int CompressByteData(char*& aDest,char* aSrce,int aSize);
+	int WriteCompressedByteData(char*& aDest,char* aData,int aLength, const char* aDestEnd);
+	int WriteCompressedByteValues(char*& aDest,char aValue,int aLength, const char* aDestEnd);
+	int CompressTwelveBitData(char*& aDest,char* aSrce,int aSizeInBytes);
+	int WriteCompressedTwelveBitData(unsigned short*& aDest,unsigned short aData,int aLength);
+	int CompressSixteenBitData(char*& aDest,char* aSrce,int aSize);
+	int WriteCompressedSixteenBitData(char*& aDest,unsigned short* aData,int aLength, const char* aDestEnd);
+	int WriteCompressedSixteenBitValues(char*& aDest,unsigned short aValue,int aLength, const char* aDestEnd);
+	int CompressTwentyFourBitData(char*& aDest,char* aSrce,int aSizeInBytes);
+	int WriteCompressedTwentyFourBitData(char*& aDest,char* aData,int aLength, const char* aDestEnd);
+	int WriteCompressedTwentyFourBitValues(char*& aDest,char aComponent1,char aComponent2,char aComponent3,int aLength, const char* aDestEnd);
+	int CompressThirtyTwoUBitData(char*& aDest,char* aSrce,int aSizeInBytes);
+	int WriteCompressedThirtyTwoUBitData(char*& aDest,char* aData, int aLength, const char* aDestEnd);
+	int WriteCompressedThirtyTwoUBitValues(char*& aDest,char aComponent1, char aComponent2,char aComponent3, int aLength, const char* aDestEnd);
+	int TrueColorPointerCompare(char* aColorPointer,char aComponent1,char aComponent2,char aComponent3);
+	int CompressThirtyTwoABitData(char*& aDest,char* aSrce,int aSizeInBytes);
+	int WriteCompressedThirtyTwoABitData(char*& aDest,char* aData,int aLength,const char* aDestEnd);
+	int WriteCompressedThirtyTwoABitValues(char*& aDest,char aComponent1,char aComponent2,char aComponent3,char aComponent4,int aLength,const char* aDestEnd);
+	int ColorAlphaPointerCompare(char* aColorPointer,char aComponent1,char aComponent2,char aComponent3,char aComponent4);
+	int ReadHexString(char aHexBuf[10],char*& aDataPtr,char* aDataPtrLimit);
+	int HexToInt(char aHighNibble,char aLowNibble);
+	int HexToInt(char aNibble);
+	static void CopyTail(void* aDst, void* aSrc, int aFullSize, int aSkipped);
+private:
+	fstream iDestFile;
+	TSourceFile* iSourcefilenames;
+	SEpocBitmapHeader** iPbmSources;
+	int iNumSources;
+	int iDefaultPalette;
+	TRgb iPalette[256];
+	char iInversePalette[4096];
+	};
+
+class BitmapLoader
+/**
+@internalComponent
+*/
+	{
+public:
+	BitmapLoader();
+	~BitmapLoader();
+	int LoadBitmap(TSourceFile& aFileName,int aBpp,TBitmapColor aColor,SEpocBitmapHeader*& aPbm);
+private:
+	int DoLoad(char* aFileName);
+	int DoLoadAlpha(char* aAlphaFileName);
+	int DoConvert(int aBpp,TBitmapColor aColor,SEpocBitmapHeader*& aPbm);
+	TRgb GetBmpPixel(long aXCoord,long aYCoord);
+	unsigned char GetAlphaPixel(long aXCoord,long aYCoord);
+private:
+	TSourceFile* iSourceFile;
+	TBitmapInfoHeader iBmpHeader;
+	int iNumBmpColors;
+	TRgbQuad* iBmpColors;
+	char* iBmpBits;
+	char* iAlphaBits;
+	};
+
+class EpocLoader
+/**
+@internalComponent
+*/
+	{
+public:
+	EpocLoader();
+	~EpocLoader();
+	int EpocBitmapCount(char* aFilename,int& aCount,int& isRomFormat);
+	int LoadEpocBitmap(char* aFilename,int aIndex);
+	int SaveBitmap(char* aFilename);
+	int SaveAlpha(char* aFilename);
+	int DupBitmap(SEpocBitmapHeader*& aPbm);
+	SEpocBitmapHeader Header() const { return iOriginalPbmHeader;}
+private:
+	int LoadFile(char* aFilename,int aIndex);
+	int LoadRom(char* aFilename,int aIndex);
+	TRgb GetPixel(int aXCoord,int aYCoord);
+	unsigned char GetAlpha(int aXCoord,int aYCoord);
+	int DoLoadFile(fstream& aFile);
+	int DoLoadRom(fstream& aFile);
+	int ExpandByteRLEData(char* aDest,int aDestSize,char* aSrce,int aSrceSize);
+	int ExpandTwelveBitRLEData(char* aDest,int aDestSizeInBytes,char* aSrce,int aSrceSizeInBytes);
+	int ExpandSixteenBitRLEData(char* aDest,int aDestSizeInBytes,char* aSrce,int aSrceSizeInBytes);
+	int ExpandTwentyFourBitRLEData(char* aDest,int aDestSizeInBytes,char* aSrce,int aSrceSizeInBytes);
+	int ExpandThirtyTwoUBitRLEData(char* aDest,int aDestSizeInBytes,char* aSrce,int aSrceSizeInBytes);
+	int ExpandThirtyTwoABitRLEData(char* aDest,int aDestSizeInBytes,char* aSrce,int aSrceSizeInBytes);
+	int Decompress(int aSize);
+private:
+	SEpocBitmapHeader iOriginalPbmHeader;
+	SEpocBitmapHeader iPbmHeader;
+	char* iPbmBits;
+	};
+
+class BitmapUtils
+/**
+@internalComponent
+*/
+	{
+public:
+	static int ByteWidth(int aPixelWidth,int aBitsPerPixel);
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/bmconv_s60/src/BMTOPBM.CPP	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,499 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include "BMCONV.H"
+
+const TRgbQuad KNokiaBrandBlue = {0xcc,0x33,0,0};
+const TRgbQuad KNokiaBrandGreen = {0x33,0x99,0,0};
+const int KNokiaBrandBlueIndex = 254;
+const int KNokiaBrandGreenIndex = 253;
+
+const unsigned char ColorRemapTable[256] = 
+	{
+	0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+	0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+	0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+	0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+	0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+	0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
+	0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+	0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
+	0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+	0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
+	0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
+	0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
+	0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+	0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0x00, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
+	0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xd7
+	};
+
+BitmapLoader::BitmapLoader():
+	iNumBmpColors(0),
+	iBmpColors(NULL),
+	iBmpBits(NULL),
+	iAlphaBits(NULL)
+	{}
+
+BitmapLoader::~BitmapLoader()
+	{
+	delete [] iBmpColors;
+	delete [] iBmpBits;
+	delete [] iAlphaBits;
+	}
+
+int BitmapLoader::LoadBitmap(TSourceFile& aFileName,int aBpp,TBitmapColor aColor,SEpocBitmapHeader*& aPbm)
+	{
+	iSourceFile = &aFileName;
+	char sig[2];
+#if defined(__MSVCDOTNET__) || defined(__LINUX__) || defined(__TOOLS2__) || defined(__CW32__)
+	fstream file(aFileName.FileName(), ios::in | ios::binary);
+#else	
+	fstream file(aFileName.FileName(), ios::in | ios::binary | ios::nocreate);	
+#endif		
+
+	if (file.is_open()==0)
+		return Files;
+	file.read(sig,2);
+	file.close();
+	if (file.gcount()!=2)
+		return SourceFile ;
+	if (sig[0]!='B'||sig[1]!='M')
+		return SourceFile;
+
+	int ret = DoLoad(aFileName.FileName());
+
+    // Iff we have >8bit color BMP file and c8, change to c16
+    if( (aColor==EColorBitmap) && (aBpp==8) && 
+        (iBmpHeader.biBitCount>8) )
+        {
+        // cout << "Note: " << aFileName.FileName() << " changed c8 -> c16" << "\n";
+        aBpp = 16;
+        }
+	if (!ret && aColor==EColorBitmapAlpha)
+		{
+		int fileNameLen = strlen(aFileName.FileName());
+		char* alphaFileName = new char[fileNameLen + 7];// -alpha suffix is 6 chars, plus NUL termination
+		if (alphaFileName == NULL)
+			return NoMemory;
+		int dotPos = -1;
+		for (int i = 0; i < fileNameLen; ++i)
+			if (aFileName.FileName()[i]=='.')
+				dotPos=i;
+		int prefixLen = (dotPos>=0?dotPos:fileNameLen);
+		memcpy(alphaFileName,aFileName.FileName(),prefixLen);
+		const char* suffix = "-alpha";
+		memcpy(alphaFileName+prefixLen,suffix,6);
+		if (dotPos>=0)
+			memcpy(alphaFileName+prefixLen+6,aFileName.FileName()+dotPos,fileNameLen-dotPos);
+		*(alphaFileName + fileNameLen + 6) = '\0';
+		ret = DoLoadAlpha(alphaFileName); // overlay alpha data from separate file
+		delete [] alphaFileName;
+		}
+	if (!ret)
+		ret = DoConvert(aBpp,aColor,aPbm);
+	return ret;
+	}
+
+int BitmapLoader::DoLoad(char* aFileName)
+	{
+#if defined (__MSVCDOTNET__)  || defined(__TOOLS2__) || defined(__CW32__)    	
+	fstream file(aFileName, ios::in | ios::binary);
+#else //!__MSVCDOTNET__
+	fstream file(aFileName, ios::in | ios::binary | ios::nocreate);
+#endif //__MSVCDOTNET__
+	if (file.is_open()==0)
+		return Files;
+	TBitmapFileHeader bmpfile;
+	long size=sizeof(TBitmapFileHeader);
+	file.read((char *)&bmpfile,size);
+	if (file.gcount()!=size)
+		return SourceFile;
+	size=sizeof(TBitmapInfoHeader);
+	file.read((char *)&iBmpHeader,size);
+	if (file.gcount()!=size)
+		return SourceFile;
+	if (iBmpHeader.biCompression != 0)
+		return UnknownCompression;
+	size=bmpfile.bfSize-sizeof(TBitmapInfoHeader)-sizeof(TBitmapFileHeader);
+	long bitcount=iBmpHeader.biBitCount;
+	long colors=iBmpHeader.biClrUsed;
+	if (colors==0)
+		{
+		if (bitcount==24)
+			iNumBmpColors=0;
+		else if (bitcount==32)
+			iNumBmpColors=0;//See MSDN - BITMAPFILEHEADER and BITMAPINFOHEADER structures.
+                            //If biCompression is 0 - we don't have TRgbQuad array! 
+		else
+			iNumBmpColors=1<<bitcount;
+		}
+	else
+		iNumBmpColors=colors;
+	if (iNumBmpColors > 256)
+		return SourceFile;
+	if (iNumBmpColors>0)
+		{
+		iBmpColors = new TRgbQuad[iNumBmpColors];
+		if (iBmpColors == NULL)
+			return NoMemory;
+		memset(iBmpColors,0,iNumBmpColors*sizeof(TRgbQuad));
+		}
+	size-=iNumBmpColors*sizeof(TRgbQuad);
+	iBmpBits = new char[size];
+	if (iBmpBits == NULL)
+		return NoMemory;
+	memset(iBmpBits,0xff,size);
+
+	if(iBmpColors != NULL)
+	    {
+		file.read((char *)iBmpColors,iNumBmpColors*sizeof(TRgbQuad));
+		if (file.gcount()!=(int)(iNumBmpColors*sizeof(TRgbQuad)))
+			return SourceFile;
+	    }
+	file.read(iBmpBits,size);
+	file.close();
+	if (file.gcount()!=size)
+		return SourceFile;
+	return NoError;
+	}
+
+int BitmapLoader::DoLoadAlpha(char* aAlphaFileName)
+	{
+#if defined(__MSVCDOTNET__) || defined(__TOOLS2__)
+	fstream file(aAlphaFileName, ios::in | ios::binary);
+#else //!__MSVCDOTNET__
+	fstream file(aAlphaFileName, ios::in | ios::binary | ios::nocreate);
+#endif //__MSVCDOTNET__
+	if (file.is_open()==0)
+		return AlphaFiles;
+	TBitmapFileHeader alphaBmpfile;
+	long size=sizeof(TBitmapFileHeader);
+	file.read((char *)&alphaBmpfile,size);
+	if (file.gcount()!=size)
+		return SourceFile;
+	size=sizeof(TBitmapInfoHeader);
+	TBitmapInfoHeader alphaBmpInfo;
+	file.read((char *)&alphaBmpInfo,size);
+	if (file.gcount()!=size)
+		return SourceFile;
+	if (alphaBmpInfo.biCompression != 0)
+		return UnknownCompression;
+	if (alphaBmpInfo.biWidth != iBmpHeader.biWidth || alphaBmpInfo.biHeight != iBmpHeader.biHeight)
+		return AlphaDimensions;
+	if (alphaBmpInfo.biBitCount != 8)
+		return AlphaBpp;
+	size=alphaBmpfile.bfSize-sizeof(TBitmapInfoHeader)-sizeof(TBitmapFileHeader);
+	long numBmpColors=alphaBmpInfo.biClrUsed;
+	if (numBmpColors == 0)
+		numBmpColors = 256;
+	if (numBmpColors != 256)
+		return SourceFile;
+	size-=numBmpColors*sizeof(TRgbQuad);
+	iAlphaBits = new char[size];
+	if (iAlphaBits == NULL)
+		{
+		return NoMemory;
+		}
+	memset(iAlphaBits,0xff,size);
+	char* bmpColors = new char[numBmpColors*sizeof(TRgbQuad)];
+	file.read((char *)bmpColors,numBmpColors*sizeof(TRgbQuad));
+	delete [] bmpColors; // we aren't interested in the palette data for the 8bpp grayscale alpha bmp
+	if (file.gcount()!=(int)(numBmpColors*sizeof(TRgbQuad)))
+		return SourceFile;
+	file.read(iAlphaBits,size);
+	file.close();
+	if (file.gcount()!=size)
+		return SourceFile;
+	return NoError;
+	}
+
+TRgb BitmapLoader::GetBmpPixel(long aXCoord,long aYCoord)
+	{
+	TRgb darkgray(128,128,128);
+	TRgb darkgrayex(127,127,127);
+	TRgb lightgray(192,192,192);
+	TRgb lightgrayex(187,187,187);
+	unsigned char col;
+	TRgb color;
+
+	switch(iBmpHeader.biBitCount)
+		{
+		case 1:
+			col=iBmpBits[(iBmpHeader.biHeight-aYCoord-1)*(((iBmpHeader.biWidth+31)>>5)<<2)+(aXCoord>>3)];
+			col&=(0x80>>(aXCoord%8));
+			if (iBmpColors)
+				{
+				TRgbQuad rgbq;
+				if (col)
+					rgbq = iBmpColors[1];
+				else
+					rgbq = iBmpColors[0];
+				color = TRgb(rgbq.iRed,rgbq.iGreen,rgbq.iBlue);
+				}
+			else
+				{
+				if (col)
+					color = TRgb(0x00ffffff);
+				else
+					color = TRgb(0);
+				}
+			break;
+		case 4:
+			col=iBmpBits[(iBmpHeader.biHeight-aYCoord-1)*(((iBmpHeader.biWidth+7)>>3)<<2)+(aXCoord>>1)];
+			if (aXCoord%2==0)
+				col=(unsigned char)(col>>4);
+			col&=0x0f;
+			if (iBmpColors)
+				{
+				TRgbQuad rgbq = iBmpColors[col];
+				color = TRgb(rgbq.iRed,rgbq.iGreen,rgbq.iBlue);
+				}
+			else
+				{
+				col *= 17;
+				color = TRgb(col,col,col);
+				}
+			break;
+		case 8:
+			col=iBmpBits[(iBmpHeader.biHeight-aYCoord-1)*((iBmpHeader.biWidth+3)&~3)+aXCoord];
+			if (iBmpColors)
+				{
+				TRgbQuad rgbq = iBmpColors[col];
+				color = TRgb(rgbq.iRed,rgbq.iGreen,rgbq.iBlue);
+				}
+			else
+				color = TRgb(col,col,col);
+			break;
+		case 16:
+			{
+			unsigned short int* wordptr = (unsigned short int*)&iBmpBits[(iBmpHeader.biHeight-aYCoord-1)*(((iBmpHeader.biWidth+1)&~1)<<1)+(aXCoord<<1)];
+			color = TRgb((*wordptr&0x7c)>>10,(*wordptr&0x3e)>>5,(*wordptr&0x1f));
+			}
+			break;
+		case 24:
+			{
+			TRgbTriple rgbcol = *((TRgbTriple *)&(iBmpBits[(iBmpHeader.biHeight-aYCoord-1)*((3*iBmpHeader.biWidth+3)&~3)+aXCoord+(aXCoord<<1)]));
+			color = TRgb(rgbcol.rgbtRed,rgbcol.rgbtGreen,rgbcol.rgbtBlue);
+			}
+			break;
+		case 32:
+			{
+			unsigned long int* dwordptr = (unsigned long int*)&iBmpBits[(iBmpHeader.biHeight-aYCoord-1)*((iBmpHeader.biWidth)<<2)+(aXCoord<<2)];
+			color = TRgb((*dwordptr&0xff0000)>>16,(*dwordptr&0xff00)>>8,*dwordptr&0xff);
+			}
+			break;
+		default:
+			break;
+		}
+	if (color == darkgray)
+		color = darkgrayex;
+	else if (color == lightgray)
+		color = lightgrayex;
+	return color;
+	}
+
+unsigned char BitmapLoader::GetAlphaPixel(long aXCoord,long aYCoord)
+	{
+	return iAlphaBits[(iBmpHeader.biHeight-aYCoord-1)*((iBmpHeader.biWidth+3)&~3)+aXCoord];
+	}
+
+int BitmapLoader::DoConvert(int aBpp,TBitmapColor aColor,SEpocBitmapHeader*& aPbm)
+	{
+	bool useAlpha = (aColor==EColorBitmapAlpha);
+	long desttwipswidth = 0;
+	long desttwipsheight = 0;
+
+	long bytewidth = BitmapUtils::ByteWidth(iBmpHeader.biWidth,aBpp);
+	long destlength = iBmpHeader.biHeight * bytewidth;
+
+	if (iBmpHeader.biXPelsPerMeter>0)
+		desttwipswidth = iBmpHeader.biWidth*1440000/254/iBmpHeader.biXPelsPerMeter;
+	if (iBmpHeader.biYPelsPerMeter>0)
+		desttwipsheight = iBmpHeader.biHeight*1440000/254/iBmpHeader.biYPelsPerMeter;
+
+	aPbm = (SEpocBitmapHeader*)new char[sizeof(SEpocBitmapHeader) + destlength];
+	if (aPbm == NULL)
+		return NoMemory;
+	memset(aPbm,0,sizeof(SEpocBitmapHeader));
+
+	// aBitmap->iByteWidth = bytewidth;
+	// aBitmap->iDataOffset = sizeof(Bitmap);
+
+	aPbm->iBitmapSize = sizeof(SEpocBitmapHeader) + destlength;
+	aPbm->iStructSize = sizeof(SEpocBitmapHeader);
+	aPbm->iWidthInPixels = iBmpHeader.biWidth;
+	aPbm->iHeightInPixels = iBmpHeader.biHeight;
+	aPbm->iWidthInTwips = desttwipswidth;
+	aPbm->iHeightInTwips = desttwipsheight;
+	aPbm->iBitsPerPixel = aBpp;
+	aPbm->iColor = aColor;
+	aPbm->iPaletteEntries = 0;
+	aPbm->iCompression = ENoBitmapCompression;
+
+	char* pbmBits = ((char*)aPbm) + sizeof(SEpocBitmapHeader);
+	memset(pbmBits,0xff,destlength);
+
+	long col = 0;
+	char* pixadd = 0;
+	bool indicesOnly = false;
+	if (aColor == EColorBitmap && aBpp == 8)
+		{
+		indicesOnly =
+			(iNumBmpColors==256 &&
+			 iBmpColors[KNokiaBrandGreenIndex].iRed == KNokiaBrandGreen.iRed &&
+			 iBmpColors[KNokiaBrandGreenIndex].iBlue == KNokiaBrandGreen.iBlue &&
+			 iBmpColors[KNokiaBrandGreenIndex].iGreen == KNokiaBrandGreen.iGreen &&
+			 iBmpColors[KNokiaBrandBlueIndex].iRed == KNokiaBrandBlue.iRed &&
+			 iBmpColors[KNokiaBrandBlueIndex].iBlue == KNokiaBrandBlue.iBlue &&
+			 iBmpColors[KNokiaBrandBlueIndex].iGreen == KNokiaBrandBlue.iGreen);
+		}
+
+	switch(aBpp)
+		{
+	case 1:
+		{
+		for(long ycrd=0;ycrd<iBmpHeader.biHeight;ycrd++)
+			for(long xcrd=0;xcrd<iBmpHeader.biWidth;xcrd++)
+				{
+				TRgb color=GetBmpPixel(xcrd,ycrd);
+				col=color.Gray2();
+				pixadd=&(pbmBits[ycrd*bytewidth+(xcrd>>3)]);
+				(*pixadd)&=~(1<<((xcrd&7)));
+				(*pixadd)|=(unsigned char)(col<<(xcrd&7));
+				}
+		}
+		break;
+	case 2:
+		{
+		for(long ycrd=0;ycrd<iBmpHeader.biHeight;ycrd++)
+			for(long xcrd=0;xcrd<iBmpHeader.biWidth;xcrd++)
+				{
+				TRgb color=GetBmpPixel(xcrd,ycrd);
+				col=color.Gray4();
+				pixadd=&(pbmBits[ycrd*bytewidth+(xcrd>>2)]);
+				(*pixadd)&=~(0x3<<(2*(xcrd%4)));
+				(*pixadd)|=(unsigned char)(col<<(2*(xcrd%4)));
+				}
+		}
+		break;
+	case 4:
+		{
+		for(long ycrd=0;ycrd<iBmpHeader.biHeight;ycrd++)
+			for(long xcrd=0;xcrd<iBmpHeader.biWidth;xcrd++)
+				{
+				TRgb color=GetBmpPixel(xcrd,ycrd);
+				if (aColor == EMonochromeBitmap)
+					col = color.Gray16();
+				else
+					col = color.Color16();
+				pixadd=&(pbmBits[ycrd*bytewidth+(xcrd>>1)]);
+				if (xcrd%2!=0)
+					*pixadd=(unsigned char)((unsigned char)((col<<4)|(*pixadd&0x0f)));
+				else
+					*pixadd=(unsigned char)((unsigned char)(col|(*pixadd&0xf0)));
+				}
+		}
+		break;
+	case 8:
+		{
+		for(long ycrd=0;ycrd<iBmpHeader.biHeight;ycrd++)
+			for(long xcrd=0;xcrd<iBmpHeader.biWidth;xcrd++)
+				{
+				if (indicesOnly)
+					{
+					unsigned char pixel = iBmpBits[(iBmpHeader.biHeight-ycrd-1)*((iBmpHeader.biWidth+3)&~3)+xcrd];
+					col = ColorRemapTable[pixel];
+					iSourceFile->SetCompileInfo(TSourceFile::ENokiaBitmap);
+					}
+				else
+					{
+					TRgb color=GetBmpPixel(xcrd,ycrd);
+					if (aColor == EMonochromeBitmap)
+						col = color.Gray256();
+					else
+						col = color.Color256();
+					iSourceFile->SetCompileInfo(TSourceFile::EThirdPartyBitmap);
+					}
+				pixadd=&(pbmBits[ycrd*((iBmpHeader.biWidth+3)&~3)+xcrd]);
+				*pixadd=(unsigned char)col;
+				}
+		}
+		break;
+	case 12:
+		{
+		for(long ycrd=0;ycrd<iBmpHeader.biHeight;ycrd++)
+			for(long xcrd=0;xcrd<iBmpHeader.biWidth;xcrd++)
+				{
+				TRgb color=GetBmpPixel(xcrd,ycrd);
+				col=color.Color4K();
+				pixadd=&(pbmBits[ycrd*bytewidth+(xcrd<<1)]);
+				unsigned short* wordadd=(unsigned short*)pixadd;
+				*wordadd=(unsigned short)col;
+				}
+		}
+		break;
+	case 16:
+		{
+		for(long ycrd=0;ycrd<iBmpHeader.biHeight;ycrd++)
+			for(long xcrd=0;xcrd<iBmpHeader.biWidth;xcrd++)
+				{
+				TRgb color=GetBmpPixel(xcrd,ycrd);
+				col=color.Color64K();
+				pixadd=&(pbmBits[ycrd*bytewidth+(xcrd<<1)]);
+				unsigned short* wordadd=(unsigned short*)pixadd;
+				*wordadd=(unsigned short)col;
+				}
+		}
+		break;
+	case 24:
+		{
+		for(long ycrd=0;ycrd<iBmpHeader.biHeight;ycrd++)
+			{
+			unsigned char* bytePtr = (unsigned char*)&pbmBits[ycrd*bytewidth];
+			for(long xcrd=0;xcrd<iBmpHeader.biWidth;xcrd++)
+				{
+				TRgb col = GetBmpPixel(xcrd,ycrd);
+				*bytePtr++ = (unsigned char) col.iBlue;
+				*bytePtr++ = (unsigned char) col.iGreen;
+				*bytePtr++ = (unsigned char) col.iRed;
+				}
+			}
+		}
+		break;
+	case 32:
+		{
+		for(long ycrd=0;ycrd<iBmpHeader.biHeight;ycrd++)
+			{
+			unsigned char* bytePtr = (unsigned char*)&pbmBits[ycrd*bytewidth];
+			for(long xcrd=0;xcrd<iBmpHeader.biWidth;xcrd++)
+				{
+				TRgb col = GetBmpPixel(xcrd,ycrd);
+				unsigned char alpha = useAlpha?GetAlphaPixel(xcrd,ycrd):(unsigned char)0;
+				*bytePtr++ = (unsigned char) col.iBlue;
+				*bytePtr++ = (unsigned char) col.iGreen;
+				*bytePtr++ = (unsigned char) col.iRed;
+				*bytePtr++ = alpha;	
+				}
+			}
+		}
+		break;
+		};
+
+	return NoError;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/bmconv_s60/src/MAINFUNC.CPP	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,652 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#if defined(__MSVCDOTNET__) || defined(__TOOLS2__) || defined(__CW32__)
+#include <ostream>
+#include <iostream>
+using namespace std;
+#else //!__MSVCDOTNET__ && !__TOOLS2__ && !__CW32__
+#pragma warning(disable: 4100)
+#pragma warning(disable: 4511)
+#pragma warning(disable: 4512)
+#pragma warning(disable: 4530)
+#pragma warning(disable: 4663)
+#pragma warning(disable: 4710)
+#pragma warning(disable: 4786)
+#pragma warning(disable: 4800)
+#include <ostream.h>
+#endif //__MSVCDOTNET__
+
+#include "TOOLSVER.H"
+#include "BMCONV.H"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <string>
+
+const int KMaxPaletteFileLen = 256;
+
+#ifdef __linux__
+const char* DefaultPaletteFileSearchLocations[] =
+{
+    "/epoc32/include/mw/ThirdPartyBitmap.pal",
+    "/epoc32/include/middleware/ThirdPartyBitmap.pal",
+    "/epoc32/include/ThirdPartyBitmap.pal"
+};
+#else
+const char* DefaultPaletteFileSearchLocations[] =
+{
+    "\\epoc32\\include\\mw\\ThirdPartyBitmap.pal",
+    "\\epoc32\\include\\middleware\\ThirdPartyBitmap.pal",
+    "\\epoc32\\include\\ThirdPartyBitmap.pal"
+};
+#endif
+
+/**
+Returns an informative error message, the result of the program actions performed.
+@return Informative error string
+@param aErrorNumber The error returned from the actions performed
+@param aDestfile The multiple bitmap store file name
+@param aDestCreated True if the multiple bitmap store has been created/modified
+*/
+
+char* ErrorMessage(int aErrorNumber, char* aDestfile=NULL, bool aDestCreated=false)
+	{
+	// Remove the multiple bitmap store if it has been created/modified during an fstream session and there has been an error
+	if(aDestfile && (aErrorNumber != NoError) && (aDestCreated == true))
+		{
+		remove(aDestfile);
+		}
+
+	switch(aErrorNumber)
+		{
+		case NoError:
+			return "Success.";
+		case NoMemory:
+			return "Out of memory.";
+		case Arg:
+			return "Bad argument.";
+		case Files:
+			return "File does not exist";
+		case SourceFile:
+			return "Bad source file(s).";
+		case DestFile:
+			return "Bad destination file(s).";
+		case CommandFile:
+			return "Bad command file.";
+		case OutOfRange:
+			return "Number of sources/targets mismatch.";
+		case TooManyArgs:
+			return "Too many arguments.";
+		case UnknownCompression:
+			return "Unknown source compression type.";
+		case CompressionError:
+			return "Compression error.";
+		case DecompressionError:
+			return "Decompression error.";
+		case Bpp:
+			return "Invalid bitmap mode specified.";
+		case PaletteFile:
+			return "Bad palette file.";
+		case PaletteSupportNotImplemented:
+			return "Palettes not supported";
+		case AlphaFiles:
+			return "Alpha bitmap file does not exist";
+		case AlphaDimensions:
+			return "Alpha channel bitmap's dimensions don't match pixel bitmap's dimensions.";
+		case AlphaBpp:
+			return "Alpha channel bitmap must be 8bpp.";
+		default:
+			return "Unknown error!";
+		};
+	}
+
+void Header()
+	{
+	cout << "\n";
+	cout << "\n";
+	cout << "BMCONV S60 version "<< version << ".\n";
+	}
+	
+void Report(int aError)
+	{
+	Header();
+	cout << ErrorMessage(aError) << "\n";
+	}
+
+/**
+Compiliation information to print to the user at the end of the program.
+@param aQuiet Flag if the user selected quiet output mode
+@param aError The error returned from the actions performed
+@param aType The multiple bitmap store type created
+@param aDestfile The multiple bitmap store file name
+@param aBitmapFiles The array of bitmaps used
+@param aNumFiles The amount of bitmaps used
+@param aDestCreated True if the multiple bitmap store has been created/modified
+*/
+
+void CompilationReport(int aQuiet,int aError,TStoreType aType,char* aDestfile,TSourceFile* aBitmapFiles,int aNumFiles, bool aDestCreated)
+	{	
+	if(!aQuiet || aError)
+		{
+		Header();
+		cout << "Compiling...\n";
+		if(aType!=ENoStore)
+			cout << "Multiple bitmap store type: ";
+		if(aType==EFileStore)
+			cout << "File store" << "\n";
+		else if(aType==ERomStore)
+			cout << "ROM image store" << "\n";
+		else if(aType==ECompressedRomStore)
+			cout << "Compressed ROM image store" << "\n";
+		if(aDestfile!=NULL)
+			cout << "Epoc file: " << aDestfile << "\n\n";
+		for(int count=0;count<aNumFiles;count++)
+			{
+			cout << "Bitmap file " << count+1 << "	: ";
+			aBitmapFiles[count].WriteCompileInfo(cout);
+			cout << endl;
+			}
+		cout << ErrorMessage(aError, aDestfile, aDestCreated) << "\n";
+		}
+	}
+	
+void DecompilationReport(int aError,char* aDestfile,char** aBitmapFiles,int aNumFiles)
+	{	
+	Header();
+	cout << "Decompiling...\n";
+	if(aDestfile!=NULL)
+		cout << "Epoc file: " << aDestfile << "\n\n";
+	for(int count=0;count<aNumFiles;count++)
+		{
+		cout << "Bitmap file " << count+1 << "	: ";
+		cout << aBitmapFiles[count] << "\n";
+		}
+	cout << ErrorMessage(aError) << "\n";
+	}
+	
+void Usage()
+    {
+	cout << "\n";
+	cout << "BMCONV S60 version "<< version << ".\n";
+	cout << "Symbian OS multiple bitmap file/rom store conversion program.\n";
+	cout << "Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.";
+	cout << "\n";
+	cout << "\n";
+	cout << "Usage:\n";
+	cout << "BMCONV [-r|-s|-n] [-hfilename] [-q] [-pfilename] epocfile [OPT]bmp_1 ... [OPT]bmp_n\n";
+	cout << "BMCONV [-r|-s|-n] [-q] [-pfilename] epocfile -mepocfile2\n";
+	cout << "BMCONV -u epocfile bmp_1 [... bmp_n]\n";
+	cout << "BMCONV -v epocfile\n";
+	cout << "BMCONV commandfile\n";
+	cout << "\n";
+	cout << " -r specifies a ROM image destination file,\n";
+	cout << " -s specifies a compressed ROM image file,\n";
+	cout << " -n disables bitmap File Store compression,\n";
+	cout << " the default is a compressed File Store file.\n\n";
+	cout << " -q specifies quiet mode - only errors are reported.\n\n";
+	cout << " -hfilename specifies the filename for the automatic\n";
+	cout << " generation of a header file for inclusion into code.\n\n";
+	cout << " -pfilename gives the filename of a palette file containing 256 hex\n";
+	cout << " numbers (0x00BBGGRR) specifying the palette for 8bpp colour bitmaps.\n";
+	cout << " (Omission results in the use of a default palette.)\n\n";
+	cout << " OPT may be one of -1, -2, -4, -8, -c4, -c8, -c12, -c16, -c24 -c32 -c32a\n";
+	cout << " specifying bits per pixel and grey-scale-colour, or -mepocfile2\n";
+	cout << " to specify an existing multiple bitmap file. default is -2.\n\n";
+	cout << " To avoid ambiguity when specifying -c32 with a bitmap file whose name\n";
+	cout << " begins with an 'a', use a relative or direct directory reference\n";
+	cout << " e.g. -c32.\\abitmap.bmp or -c32c:\\abitmap.bmp\n";
+	cout << " Directory names must not include spaces.\n\n";
+	cout << " -c32a specifies use of an alpha channel in a 32bpp bitmap. Alpha data\n";
+	cout << " is supplied in a separate 8bpp bmp file with identical dimensions to\n";
+	cout << " the pixel data. This file must be named as bmp_n with the suffix '-alpha'\n";
+	cout << " e.g. if bmp_1 is 'my.bmp' then the file 'my-alpha.bmp' is required in the\n";
+	cout << " same directory.  The alpha file does not need to be specified.\n\n";
+	cout << " epocfile specifies the epoc multi-bitmap file name.\n";
+	cout << " bmp_n specifies the nth bitmap file name.\n\n";
+	cout << " -u decompiles epocfile to bmp_1,...,bmp_n.\n";
+	cout << " If an alpha channel is present then a further, 8bpp file is output for \n";
+	cout << " the alpha data, named with an '-alpha' suffix as described above.\n\n";
+	cout << " -v displays a summary of the bitmaps in epocfile\n";
+	cout << " otherwise bmp_1,...,bmp_n are compiled to epocfile\n\n";
+	cout << " commandfile specifies a file containing the commandline\n";
+	cout << " with commands separated by spaces or newlines.\n\n";
+	cout << " When bmconv is used on Windows, options may start with '/' or '-'\n";
+	}
+
+int IsWhiteSpace(char aCharacter)
+	{
+	return(aCharacter==' ' || aCharacter=='\n' || aCharacter=='\r' || aCharacter==0x1a);
+	}
+
+int ProcessCommandFile(char* aCommandFileName,char** aArgPtrs,int& aNumArgs)
+    {
+	struct stat fileinfo;
+	if (stat(aCommandFileName,&fileinfo)==-1)
+		return CommandFile;
+
+	int filesize=fileinfo.st_size;
+	if (filesize==0)
+		return NoError;
+#if defined(__MSVCDOTNET__) || defined(__TOOLS2__) || defined(__CW32__)
+	fstream commandfile(aCommandFileName, ios::in | ios::binary);
+#else //!__MSVCDOTNET__
+	fstream commandfile(aCommandFileName, ios::in | ios::binary | ios::nocreate);
+#endif //__MSVCDOTNET__
+	if(!commandfile.is_open())
+		return CommandFile;
+
+	char* commandData=new char[filesize+1];
+	if(commandData==NULL)
+		return NoMemory;
+
+	memset(commandData,0,filesize+1);
+	commandfile.read(commandData,filesize);
+	commandData[filesize]='\0';
+
+	char* commandptr = (char*)commandData;
+	char* commandptrLimit = (char*)(commandData + filesize);
+	while (commandptr < commandptrLimit)
+		{
+		if(*commandptr=='/' && *(commandptr+1)=='/')
+			while(*commandptr!='\n' && *commandptr!='\r' && commandptr < commandptrLimit)
+				*commandptr++=' ';
+		else if (*commandptr==0x1a)
+			*commandptr++=' ';
+		commandptr++;
+		}
+
+	commandptr = (char*)commandData;
+	while (commandptr < commandptrLimit)
+		{
+		while(IsWhiteSpace(*commandptr) && commandptr < commandptrLimit)
+			*commandptr++='\0';
+		if (commandptr == commandptrLimit)
+			break;
+		aArgPtrs[aNumArgs]=commandptr;
+        if ( (*commandptr == '/') && (*(commandptr+1) == 'p'||*(commandptr+1) == 'P') && (*(commandptr+2) == '"') )
+            {
+            commandptr+=3;
+            while(*commandptr != '"')
+                commandptr++;
+            *commandptr=' ';
+            
+            }
+		while(!IsWhiteSpace(*commandptr) && commandptr < commandptrLimit)
+			commandptr++;
+		if (commandptr == commandptrLimit)
+			break;
+		aNumArgs++;
+		}
+
+	commandfile.close();
+	return NoError;
+    }
+
+int Decompile(int aArgc,int aNumArgs,char** aArgPtrs)
+	{
+	int ret=OutOfRange;
+	char* destfilename=aArgPtrs[1];
+
+	if(aArgc>=4 || aArgc==2)
+		{
+		for(int count=2;count<aNumArgs;count++)
+			{
+			EpocLoader pl;
+			ret=pl.LoadEpocBitmap(destfilename,count-2);
+			if(!ret) ret=pl.SaveBitmap(aArgPtrs[count]);
+			if(ret) break;
+			}
+		DecompilationReport(ret,destfilename,&aArgPtrs[2],aNumArgs-2);
+		}
+	else
+		DecompilationReport(ret,NULL,NULL,0);
+
+	return ret;
+	}
+
+const char* AddEpocRootTo(std::string& aBuf, const std::string& aName)
+	{ 
+	int nameLen = aName.length();
+	int rootLen = 0;
+	aBuf = ""; // Clear old contents
+	char* epocroot = getenv("EPOCROOT");
+	if (epocroot)
+		{
+		rootLen = strlen(epocroot);
+		if (nameLen+rootLen < KMaxPaletteFileLen)
+			{
+			if( rootLen > 0 && epocroot[rootLen-1] == '\\')
+			    {
+			    aBuf = std::string(epocroot, rootLen-1);
+			    }
+			else if( rootLen > 0 )
+			    {
+			    aBuf = std::string(epocroot);
+			    }
+			}
+		}
+	aBuf += aName;
+	return aBuf.c_str();
+	}
+
+bool FileExists( const char* aFileName )
+{
+  struct stat fileInfo;   
+  int retVal = 0; 
+
+  // Try to get file attributes to see if the file exists or not:
+  retVal = stat( aFileName, &fileInfo); 
+  return retVal == 0;
+}
+
+const char* DefaultPaletteFileName(std::string& aBuf)
+    {
+    const char* palettefilename = NULL;    
+    int numOfSearchLocations = sizeof(DefaultPaletteFileSearchLocations)/sizeof(char*);
+    
+    for( int i = 0; i < numOfSearchLocations; ++i )
+        {
+        palettefilename = AddEpocRootTo(aBuf, DefaultPaletteFileSearchLocations[i]);
+        if( FileExists( palettefilename))
+            {
+            return palettefilename;
+            }
+        }
+    
+    return NULL;
+    }
+
+int Compile(int aNumArgs,int aArgArraySize, char** aArgPtrs)
+	{
+	TStoreType storeType = EFileStore;
+	int compression = 1;
+	int quiet = 0;
+	char* headerfilename = NULL;
+	char paletteBuf[KMaxPaletteFileLen];
+	memset(paletteBuf, 0, KMaxPaletteFileLen);
+	std::string paletteStr;	
+	const char* defaultPalettefile = DefaultPaletteFileName(paletteStr);
+	char* palettefilename = NULL;
+	char* destfilename = NULL;
+	int ret = OutOfRange;
+	bool aDestCreated = false;
+
+	for(int argnum=0;argnum<aNumArgs;argnum++)
+		{
+		if(aArgPtrs[argnum] && (aArgPtrs[argnum][0] == OPTCHAR || aArgPtrs[argnum][0]==ALTERNATE_OPTCHAR))
+			{
+			if(aArgPtrs[argnum][1]=='r' || aArgPtrs[argnum][1]=='R')
+				{
+				if(storeType==ECompressedRomStore)
+					{
+					ret=TooManyArgs;
+					CompilationReport(quiet,ret,storeType,NULL,NULL,0,aDestCreated);
+					return ret;
+					}
+				storeType=ERomStore;
+				aArgPtrs[argnum] = NULL;
+				}
+			else if(aArgPtrs[argnum][1]=='s' || aArgPtrs[argnum][1]=='S')
+				{
+				if(storeType==ERomStore)
+					{
+					ret=TooManyArgs;
+					CompilationReport(quiet,ret,storeType,NULL,NULL,0,aDestCreated);
+					return ret;
+					}
+				storeType=ECompressedRomStore;
+				aArgPtrs[argnum] = NULL;
+				}
+			else if(aArgPtrs[argnum][1]=='n' || aArgPtrs[argnum][1]=='N')
+				{
+				compression=0;
+				aArgPtrs[argnum] = NULL;
+				}
+			else if(aArgPtrs[argnum][1]=='h' || aArgPtrs[argnum][1]=='H')
+				{
+				headerfilename = &aArgPtrs[argnum][2];
+				aArgPtrs[argnum] = NULL;
+				}
+			else if(aArgPtrs[argnum][1]=='q' || aArgPtrs[argnum][1]=='Q')
+				{
+				if (getenv("BMCONV_NOT_QUIET") == 0)
+					quiet=1;
+				aArgPtrs[argnum] = NULL;
+				}
+			else if(aArgPtrs[argnum][1]=='p' || aArgPtrs[argnum][1]=='P')
+				{
+				palettefilename = &aArgPtrs[argnum][2];
+                if (*palettefilename=='"')
+                    {
+                    palettefilename+=1;
+                    }
+				aArgPtrs[argnum] = NULL;
+				}
+			}
+		else
+			break;		// the RNHQP arguments must precede the output filename
+		}
+
+	if( palettefilename == NULL )
+	    {
+	    // Palette file not given in arguments. If the default palette file
+	    // was found, use it, otherwise return error.
+	    if( defaultPalettefile != NULL )
+	        {
+	        memcpy(paletteBuf, defaultPalettefile, strlen(defaultPalettefile));
+	        palettefilename = paletteBuf;
+	        }
+	    else
+	        {
+	        // Palettefile not given in arguments nor found from default locations:
+	        ret = PaletteFile;
+	        CompilationReport(quiet,ret,storeType,NULL,NULL,0,aDestCreated);
+	        return ret;
+	        }
+	    }
+	int firstsource=0;
+	while(firstsource<aArgArraySize && aArgPtrs[firstsource]==NULL)
+		firstsource++;
+	if(firstsource==aArgArraySize) firstsource=0;
+	destfilename=aArgPtrs[firstsource];
+	firstsource++;
+	int numsources=firstsource;
+	while(numsources<aArgArraySize && aArgPtrs[numsources]!=NULL)
+		numsources++;
+	if(numsources==aArgArraySize) numsources=0;
+	numsources-=firstsource;
+
+	TSourceFile* sources = 0;
+
+	if (numsources > 0)
+		{
+		sources = new TSourceFile[numsources];
+		for (int ii=0; ii<numsources; ii++)
+			sources[ii].FileName() = aArgPtrs[firstsource + ii];
+		BitmapCompiler mp(sources,numsources);
+		ret = mp.Compile(storeType,compression,destfilename,headerfilename,palettefilename);
+		aDestCreated = true;		// The multiple bitmap store has been created/modified
+		}
+
+	CompilationReport(quiet,ret,storeType,destfilename,sources,aNumArgs-firstsource,aDestCreated);
+	delete [] sources;
+
+	return ret;
+	}
+
+void GetInfo(char* aSourceFile)
+	{
+	Header();
+
+	EpocLoader pl;
+	int numSources=-1;
+	int romFormat=0;
+	int ret = pl.EpocBitmapCount(aSourceFile, numSources, romFormat);
+	if (ret)
+		{
+		cout << "Problem reading number of bitmaps \n";
+		cout << ErrorMessage(ret) << "\n";
+		return;
+		}
+
+	cout << aSourceFile << " is a " << (romFormat? "ROM image":"File store") 
+		<< " containing " << numSources << ((numSources==1)? " bitmap\n":" bitmaps\n");
+
+	for (int count = 0;count<numSources;count++)
+		{
+		ret = pl.LoadEpocBitmap(aSourceFile,count);
+		if (ret == OutOfRange)
+			break;
+		cout << "\n";
+		if (ret)
+			{
+			cout << "Problem loading bitmap number " << count << "\n";
+			cout << ErrorMessage(ret) << "\n";
+			break;
+			}
+		else
+			{
+			SEpocBitmapHeader h = pl.Header();
+			cout << "Bitmap " << count + 1 << " information:\n";
+			cout << "Pixel size " << h.iWidthInPixels << " x " << h.iHeightInPixels << "\n";
+			cout << "Twips size " << h.iWidthInTwips << " x " << h.iHeightInTwips << "\n";
+			cout << h.iBitsPerPixel << " Bpp ";
+			if (h.iColor == EColorBitmap)
+				cout << "Colour";
+			else if (h.iColor == EColorBitmapAlpha)
+				cout << "Colour with alpha channel";
+			else if(h.iColor == EMonochromeBitmap)
+				cout << "Monochrome";
+			else
+				cout << "Unknown colour format";
+			cout << "\n";
+			if (h.iPaletteEntries > 0)
+				cout << "Palette entries " << h.iPaletteEntries;
+
+			int byteSize = BitmapUtils::ByteWidth(h.iWidthInPixels,h.iBitsPerPixel) * h.iHeightInPixels;
+			int compressionRatio = 0;
+			if (byteSize > 0)
+				compressionRatio = (h.iBitmapSize - sizeof(SEpocBitmapHeader)) * 100 / byteSize;
+
+			switch (h.iCompression)
+				{
+			case ENoBitmapCompression:
+				cout << "No compression\n";
+				break;
+			case EByteRLECompression:
+				cout << "Bytewise RLE compression " << compressionRatio << "%\n";
+				break;
+			case ETwelveBitRLECompression:
+				cout << "12 bit RLE compression " << compressionRatio << "%\n";
+				break;
+			case ESixteenBitRLECompression:
+				cout << "16 bit RLE compression " << compressionRatio << "%\n";
+				break;
+			case ETwentyFourBitRLECompression:
+				cout << "24 bit RLE compression " << compressionRatio << "%\n";
+				break;
+			case EThirtyTwoUBitRLECompression:
+				cout << "unsigned 32 bit RLE compression (no alpha channel) " << compressionRatio << "%\n";
+				break;
+			case EThirtyTwoABitRLECompression:
+				cout << "unsigned 32 bit RLE compression (with alpha channel) " << compressionRatio << "%\n";
+				break;
+		//	case ERLECompressionLast: // Added to supress unhandled switch warning
+			default:
+				break;
+				}
+			}
+		}
+
+	cout << "\n";
+	}
+
+class TAutoPtr
+	{
+public:
+	TAutoPtr(char** aPtr) :
+		iPtr(aPtr)
+		{
+		}
+	~TAutoPtr()
+		{
+		delete iPtr;
+		}
+private:
+	char** iPtr;
+	};
+
+int main(int argc,char* argv[],char* [])
+    {
+	if (argc <= 1)
+		{
+		Usage();
+		return 0;
+		}
+
+	int optMaxCnt = argc;
+
+	if(argc==2) // The single argument must be a command file name
+		{
+		struct stat fileinfo;
+		if (stat(argv[1],&fileinfo)==-1)
+			{
+			Report(CommandFile);
+			return 0;
+			}
+		optMaxCnt = fileinfo.st_size;
+		}
+
+	char** argptrs = new char*[optMaxCnt];
+	if(!argptrs)
+		{
+		Report(NoMemory);
+		return 0;
+		}
+	TAutoPtr autoPtr(argptrs);
+	memset(argptrs, 0, optMaxCnt * sizeof(char*));
+
+	int numargs = 0;
+	if(argc>2) // Explicit arguments are present
+		{
+		for(int count=0;count<argc-1;count++)
+			argptrs[count]=argv[count+1];
+		numargs = argc-1;
+		}
+	else // The single argument must be a command file name
+		{
+		int ret = ProcessCommandFile(argv[1],argptrs,numargs);
+		if (ret)
+			{
+			Report(ret);
+			return 0;
+			}
+		}
+
+	if ((argptrs[0]!=NULL && (argptrs[0][0]==OPTCHAR || argptrs[0][0]==ALTERNATE_OPTCHAR)) && (argptrs[0][1]=='u' || argptrs[0][1]=='U')) {
+		return Decompile(argc,numargs,argptrs); }
+
+	if ((argptrs[0]!=NULL && (argptrs[0][0]==OPTCHAR || argptrs[0][0]==ALTERNATE_OPTCHAR)) && (argptrs[0][1]=='v' || argptrs[0][1]=='V'))
+		{
+		GetInfo(argptrs[1]);
+		return 0;
+		}
+
+	return Compile(numargs,optMaxCnt,argptrs);
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/bmconv_s60/src/PBMCOMP.CPP	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,1307 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include "BMCONV.H"
+#include <stdlib.h>
+#include <ctype.h>
+#include <sys/stat.h>
+
+extern TRgb* color256Palette;
+extern char* color256InversePalette;
+
+static inline bool CanCopy16bppData(const char* aDest, const char* aDestEnd, int aDataSize)
+	{
+	const char* aDestNew = 	aDest + (aDataSize / 128) * (256 + 1) + //(2 * 128) bytes data + 1 leading byte
+		                            (aDataSize % 128 ? (aDataSize % 128) * 2 + 1 : 0);
+	return aDestNew <= aDestEnd;
+	}
+
+static inline bool CanWrite16bppValue(const char* aDest, const char* aDestEnd, int aDataSize)
+	{
+	const char* aDestNew = 	aDest + (aDataSize / 128) * (2 + 1) + //2 bytes data + 1 leading byte
+		                            (aDataSize % 128 ? 2 + 1 : 0);
+	return aDestNew <= aDestEnd;
+	}
+
+static inline bool CanCopy8bppData(const char* aDest, const char* aDestEnd, int aDataSize)
+	{
+	const char* aDestNew = 	aDest + (aDataSize / 128) * (128 + 1) + //128 bytes data + 1 leading byte
+		                            (aDataSize % 128 ? (aDataSize % 128) + 1 : 0);
+	return aDestNew <= aDestEnd;
+	}
+
+static inline bool CanWrite8bppValue(const char* aDest, const char* aDestEnd, int aDataSize)
+	{
+	const char* aDestNew = 	aDest + (aDataSize / 128) * (1 + 1) + //1 byte data + 1 leading byte
+		                            (aDataSize % 128 ? 1 + 1 : 0);
+	return aDestNew <= aDestEnd;
+	}
+
+static inline bool CanCopy24bppData(const char* aDest, const char* aDestEnd, int aDataSize)
+	{
+	const char* aDestNew = 	aDest + (aDataSize / 128) * (384 + 1) + //(128 * 3) bytes data + 1 leading byte
+		                            (aDataSize % 128 ? (aDataSize % 128) * 3 + 1 : 0);
+	return aDestNew <= aDestEnd;
+	}
+
+static inline bool CanWrite24bppValue(const char* aDest, const char* aDestEnd, int aDataSize)
+	{
+	const char* aDestNew = 	aDest + (aDataSize / 128) * (3 + 1) + //3 bytes data + 1 leading byte
+		                            (aDataSize % 128 ? 3 + 1 : 0);
+	return aDestNew <= aDestEnd;
+	}
+
+static inline bool CanCopy32bppData(const char* aDest, const char* aDestEnd, int aDataSize)
+	{
+	const char* aDestNew = 	aDest + (aDataSize / 128) * (512 + 1) + //(128 * 4) bytes data + 1 leading byte
+		                            (aDataSize % 128 ? (aDataSize % 128) * 4 + 1 : 0);
+	return aDestNew <= aDestEnd;
+	}
+
+static inline bool CanWrite32bppValue(const char* aDest, const char* aDestEnd, int aDataSize)
+	{
+	const char* aDestNew = 	aDest + (aDataSize / 128) * (4 + 1) + //4 bytes data + 1 leading byte
+		                            (aDataSize % 128 ? 4 + 1 : 0);
+	return aDestNew <= aDestEnd;
+	}
+BitmapCompiler::BitmapCompiler(TSourceFile* aSourcefilenames,int aNumSources):
+	iSourcefilenames(aSourcefilenames),
+	iPbmSources(NULL),
+	iNumSources(aNumSources)
+	{}
+
+BitmapCompiler::~BitmapCompiler()
+	{
+	iDestFile.close();
+	if(iPbmSources)
+		for(int count=0;count<iNumSources;count++)
+			delete iPbmSources[count];
+	delete [] iPbmSources;
+	iPbmSources = NULL;
+	}
+
+int BitmapCompiler::Compile(TStoreType aSt,int aCompress,char* aDestfilename,char* aHeaderFilename,char* aPaletteFilename)
+	{
+	int ret = LoadPalette(aPaletteFilename);
+	if (ret)
+		return ret;
+
+	iDestFile.open(aDestfilename, ios::out | ios::binary);
+	if(iDestFile.is_open()==0)
+		return DestFile;
+	if (iNumSources < 1)
+		return SourceFile;
+
+	if (iNumSources==1 && (iSourcefilenames[0].FileName()[0]==OPTCHAR || iSourcefilenames[0].FileName()[0]==ALTERNATE_OPTCHAR) && iSourcefilenames[0].FileName()[1]=='m')
+		{
+		// Source is an existing MBM file, presumably because we want to convert
+		// a filestore into a ROM image.
+		if (aHeaderFilename)
+			{
+			cout << "Header file generation is not permitted with /m or -m\n";
+			aHeaderFilename = NULL;
+			}
+		iSourcefilenames[0].FileName()+=2;
+		EpocLoader pl;
+		int romFormat;
+		ret = pl.EpocBitmapCount(iSourcefilenames[0].FileName(), iNumSources, romFormat);
+		if (!ret)
+			ret = LoadPbmFile(iSourcefilenames[0].FileName());
+		}
+	else
+		{
+		// Read the usual list of [OPT]bmp_n source bitmaps.
+		ret = LoadSourcefiles();
+		}
+	if (ret)
+		return ret;
+
+	ret = CreateHeader(aHeaderFilename);
+	if (ret)
+		return ret;
+
+	if (aSt == ERomStore || aSt == ECompressedRomStore)
+		ret = RomImage(aSt == ECompressedRomStore);
+	else
+		ret = FileImage(aCompress);
+	return ret;
+	};
+
+int BitmapCompiler::AllocatePbmSourcesArray()
+	{
+	iPbmSources = new SEpocBitmapHeader*[iNumSources];
+	if(iPbmSources == NULL)
+		return NoMemory;
+
+	memset(iPbmSources,0xff,sizeof(SEpocBitmapHeader*)*iNumSources);
+	int count;
+	for(count=0;count<iNumSources;count++)
+		iPbmSources[count]=NULL;
+	return NoError;
+	}
+
+int BitmapCompiler::LoadSourcefiles()
+	{
+	int ret = AllocatePbmSourcesArray();
+	if (ret)
+		return ret;
+	for(int count=0;count<iNumSources;count++)
+		{
+		bool useAlpha = false;
+		int bpp = 2;
+		TBitmapColor color = EMonochromeBitmap;
+		BitmapLoader bmpload;
+		if(iSourcefilenames[count].FileName()[0]==OPTCHAR || iSourcefilenames[count].FileName()[0]==ALTERNATE_OPTCHAR)
+			{
+			iSourcefilenames[count].FileName()++;
+			if(iSourcefilenames[count].FileName()[0]=='c')
+				{
+				color = EColorBitmap;
+				iSourcefilenames[count].FileName()++;
+				}
+			bpp=iSourcefilenames[count].FileName()[0]-'0';
+			iSourcefilenames[count].FileName()++;
+			int next=iSourcefilenames[count].FileName()[0]-'0';
+			if(next==2 || next==6 || next==4)
+				{
+				bpp=bpp*10+next;
+				iSourcefilenames[count].FileName()++;
+				}
+			if(iSourcefilenames[count].FileName()[0]=='a')
+				{
+				useAlpha = true;
+				iSourcefilenames[count].FileName()++;
+				if (color!=EColorBitmap || bpp!=32)
+					return Bpp;
+				}
+			if (color == EColorBitmap && bpp!=4 && bpp!=8 && bpp!=12 && bpp!=16 && bpp!=24 && bpp!=32)
+				return Bpp;
+			if (color == EMonochromeBitmap && bpp!=1 && bpp!=2 && bpp!=4 && bpp!=8)
+				return Bpp;
+			}
+		if (color == EColorBitmap && useAlpha)
+			color = EColorBitmapAlpha;
+		ret = bmpload.LoadBitmap(iSourcefilenames[count],bpp,color,iPbmSources[count]);
+		if (ret)
+			return ret;
+		}
+	return NoError;
+	}
+
+int BitmapCompiler::LoadPbmFile(char* aPbmFilename)
+	{
+	int ret = AllocatePbmSourcesArray();
+	if (ret)
+		return ret;
+	for(int count=0;count<iNumSources;count++)
+		{
+		EpocLoader pl;
+		ret = pl.LoadEpocBitmap(aPbmFilename,count);
+		if (!ret)
+			ret = pl.DupBitmap(iPbmSources[count]);
+		if (ret)
+			return ret;
+		}
+	return NoError;
+	}
+
+int BitmapCompiler::RomImage(bool aCompress)
+	{
+	int count=0;
+
+	if (aCompress)
+		{
+		for(; count<iNumSources; count++)
+			{
+			int ret = CompressBitmap(iPbmSources[count]);
+			if (ret)
+				return ret;
+			}
+		}
+
+	int ret = WriteRomheader();
+	if (ret)
+		return ret;
+
+	for(count=0;count<iNumSources;count++)
+		{
+		ret = WriteRombitmap(iPbmSources[count]);
+		if (ret)
+			return ret;
+		}
+	return NoError;
+	}
+
+int BitmapCompiler::FileImage(int aCompress)
+	{
+	int count = 0;
+	if(aCompress)
+		{
+		for(;count<iNumSources;count++)
+			{
+			int ret = CompressBitmap(iPbmSources[count]);
+			if(ret)
+				return ret;
+			}
+		}
+	int ret = WriteFileheader();
+	if (ret)
+		return ret;
+	for (count=0;count<iNumSources;count++)
+		{
+		ret = WriteFilebitmap(iPbmSources[count]);
+		if (ret)
+			return ret;
+		}
+	ret = WriteHeadStream();
+	return ret;
+	}
+
+int BitmapCompiler::WriteRomheader()
+	{
+	iDestFile.write((char*)&KMultiBitmapRomImageUid,4);
+	iDestFile.write((char*)&iNumSources,4);
+	int byteswritten=8+(iNumSources*4);
+	for (int count=0;count<iNumSources;count++)
+		{
+		iDestFile.write((char*)&byteswritten,4);
+		byteswritten+=(((iPbmSources[count]->iBitmapSize)+3)/4*4)-sizeof(SEpocBitmapHeader)+sizeof(Bitmap);
+		}
+	return NoError;
+	}
+
+int BitmapCompiler::WriteRombitmap(SEpocBitmapHeader* aPbm)
+	{
+	if (aPbm->iPaletteEntries != 0)
+	    return PaletteSupportNotImplemented;
+
+	int bitmapsize = aPbm->iBitmapSize-sizeof(SEpocBitmapHeader)+sizeof(Bitmap);
+	bitmapsize = ((bitmapsize+3)/4)*4;
+
+	char* buffer = new char[bitmapsize];
+	if (buffer == NULL)
+		return NoMemory;
+	memset(buffer,0xff,bitmapsize);
+
+	Bitmap* bmp = (Bitmap*)buffer;
+	bmp->iUid=KCBitwiseBitmapUid;
+	TBitmapColor color = aPbm->iColor;
+
+	switch(aPbm->iBitsPerPixel)
+		{ // for corresponding enums, see TDisplayMode in <gdi.h>
+	case 1:
+		bmp->iDispMode=1;
+		break;
+	case 2:
+		bmp->iDispMode=2;
+		break;
+	case 4:
+		if (color == EMonochromeBitmap)
+			bmp->iDispMode=3;
+		else
+			bmp->iDispMode=5;
+		break;
+	case 8:
+		if (color == EMonochromeBitmap)
+			bmp->iDispMode=4;
+		else
+			bmp->iDispMode=6;
+		break;
+	case 12:
+		bmp->iDispMode=10;
+		break;
+	case 16:
+		bmp->iDispMode=7;
+		break;
+	case 24:
+		bmp->iDispMode=8;
+		break;
+	case 32:
+		if (color == EColorBitmapAlpha)
+			bmp->iDispMode=12; // Color16MA
+		else
+			bmp->iDispMode=11; // Color16MU
+		break;
+	default:
+		delete [] buffer;
+		return SourceFile;
+		}
+
+	bmp->iHeap = NULL;
+	bmp->iPile = NULL;
+	bmp->iHeader = *aPbm;
+	bmp->iByteWidth = BitmapUtils::ByteWidth(bmp->iHeader.iWidthInPixels,bmp->iHeader.iBitsPerPixel);
+	bmp->iDataOffset = sizeof(Bitmap);
+
+	CopyTail(buffer + sizeof(Bitmap), aPbm, aPbm->iBitmapSize, sizeof(SEpocBitmapHeader));
+	iDestFile.write(buffer,bitmapsize);
+
+	delete [] buffer;
+
+	return NoError;
+	}
+
+int BitmapCompiler::WriteFileheader()
+	{
+	int zero=0;
+	iDestFile.write((char*)&KWriteOnceFileStoreUid,4);
+	iDestFile.write((char*)&KMultiBitmapFileImageUid,4);
+	iDestFile.write((char*)&zero,4);
+	iDestFile.write((char*)&KMultiBitmapFileImageChecksum,4);
+	int byteswritten=16;
+	for(int count=0;count<iNumSources;count++)
+		{
+		byteswritten+=iPbmSources[count]->iBitmapSize;
+		}
+	byteswritten+=4;
+	iDestFile.write((char*)&byteswritten,4);
+	return NoError;
+	}
+
+int BitmapCompiler::WriteHeadStream()
+	{
+	iDestFile.write((char*)&iNumSources,4);
+	int byteswritten=20;
+	for(int count=0;count<iNumSources;count++)
+		{
+		iDestFile.write((char*)&byteswritten,4);
+		byteswritten+=iPbmSources[count]->iBitmapSize;
+		}
+	return NoError;
+	}
+
+int BitmapCompiler::WriteFilebitmap(SEpocBitmapHeader* aPbm)
+	{
+	if (aPbm->iPaletteEntries != 0)
+		return PaletteSupportNotImplemented;
+
+	int dataSize = aPbm->iBitmapSize - sizeof(SEpocBitmapHeader);
+
+	iDestFile.write((char*)(aPbm),sizeof(SEpocBitmapHeader));
+	// WritePalette()
+	iDestFile.write(((char*)(aPbm)) + sizeof(SEpocBitmapHeader),dataSize);
+
+	return NoError;
+	}
+
+void BitmapCompiler::WritePalette()
+	{
+	for (int index = 0; index < 256; index++)
+		{
+		iDestFile.write((char*)(&iPalette[index]),3);
+		}
+	}
+
+int BitmapCompiler::LoadPalette(char* aPaletteFilename)
+	{
+	if (!aPaletteFilename)
+		{
+		iDefaultPalette = 1;
+		return NoError;
+		}
+
+	iDefaultPalette = 0;
+	color256Palette = iPalette;
+	color256InversePalette = iInversePalette;
+
+	struct stat fileinfo;
+	if (stat(aPaletteFilename,&fileinfo)==-1)
+		return CommandFile;
+
+	int filesize = fileinfo.st_size;
+	if (filesize == 0)
+		return PaletteFile;
+
+#if defined(__MSVCDOTNET__) || defined(__TOOLS2__) || defined(__CW32__)
+	fstream paletteFile(aPaletteFilename, ios::in | ios::binary);
+#else
+	fstream paletteFile(aPaletteFilename, ios::in | ios::binary | ios::nocreate);
+#endif
+
+	if(!paletteFile.is_open())
+		return PaletteFile;
+
+	char* paletteData = new char[filesize];
+	if (!paletteData)
+		return NoMemory;
+
+	memset(paletteData,0,filesize);
+	paletteFile.read(paletteData,filesize);
+	paletteFile.close();
+
+	char* dataPtr = (char*)paletteData;
+	char* dataPtrLimit = dataPtr + filesize;
+
+	for (int index = 0; index < 256; index++)
+		{
+		char hexBuf[10];
+		int ret = ReadHexString(hexBuf,dataPtr,dataPtrLimit);
+		if (ret)
+			{
+			delete paletteData;
+			return ret;
+			}
+
+		int red = HexToInt(hexBuf[8],hexBuf[9]);
+		int green = HexToInt(hexBuf[6],hexBuf[7]);
+		int blue = HexToInt(hexBuf[4],hexBuf[5]);
+
+		iPalette[index] = TRgb(red,green,blue);
+		}
+
+	delete paletteData;
+	CalculateInversePalette();
+	return NoError;
+	}
+
+void BitmapCompiler::CalculateInversePalette()
+	{
+	for (int index = 0; index < 4096; index++)
+		{
+		TRgb color = TRgb((index & 0x00f) * 17,((index & 0x0f0) >> 4) * 17,((index & 0xf00) >> 8) * 17);
+
+		int nearest = 0;
+		int distance = iPalette[0].Difference(color);
+
+		for (int paletteIndex = 0; paletteIndex < 256; paletteIndex++)
+			{
+			TRgb paletteColor = iPalette[paletteIndex];
+
+			if (paletteColor == color)
+				{
+				nearest = paletteIndex;
+				break;
+				}
+
+			int paletteDistance = paletteColor.Difference(color);
+			if (paletteDistance < distance)
+				{
+				nearest = paletteIndex;
+				distance = paletteDistance;
+				}
+			}
+
+		iInversePalette[index] = (char)nearest;
+		TRgb palColor = iPalette[nearest];
+		color = palColor;
+		}
+	}
+
+int BitmapCompiler::CreateHeader(char* aHeaderFilename)
+	{
+	if (!aHeaderFilename)
+		return NoError;
+
+	fstream hf(aHeaderFilename,ios::out);
+	if(!hf.is_open())
+		return DestFile;
+
+	char* basename = strrchr(aHeaderFilename,'\\');
+	if (basename==0)
+		basename = aHeaderFilename;
+	else
+		basename++;	// skip directory separator
+
+	char unadornedFile[256];
+	strcpy(unadornedFile, UnadornedName(aHeaderFilename));
+
+	hf << "// " << basename << "\n";
+	hf << "// Generated by BitmapCompiler\n";
+	hf << "// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.\n";
+	hf << "//\n\n";
+	hf << "enum TMbm" << unadornedFile << "\n";
+	hf << "\t{\n";
+
+	for (int count=0;count<iNumSources;count++)
+		{
+        char* unadornedSourceFileName = UnadornedName(iSourcefilenames[count].FileName());
+        // Strip "_mask_soft" suffix to plain "_mask"
+        if( (strlen(unadornedSourceFileName)>10) && 
+            (strcmp( unadornedSourceFileName + strlen(unadornedSourceFileName) - 10,
+            "_mask_soft" ) == 0) )
+            {
+            unadornedSourceFileName[ strlen(unadornedSourceFileName) - 5 ] = '\0';
+            }
+		hf << "\tEMbm" << unadornedFile << unadornedSourceFileName;
+		if(count<iNumSources-1)
+			hf << ',';
+		hf << '\n';
+		}
+	hf << "\t};\n";
+	hf.close();
+	return NoError;
+	}
+
+char* BitmapCompiler::UnadornedName(char* aName)
+	{
+	int len = strlen(aName);
+
+	char* foundDir = strrchr(aName,'\\');
+	char* foundUrl = strrchr(aName,'/');
+	char* foundExt = strrchr(aName,'.');
+
+	char* foundPath = (foundDir > foundUrl) ? foundDir : foundUrl;
+	char* firstchar = (foundPath > (char*)0) ? (char*)(foundPath + 1) : aName;
+	char* lastchar = (foundExt > firstchar) ? foundExt : aName+len;
+
+	static char result[256];
+	if (lastchar-firstchar > 255)
+		{
+		strcpy(result,"NameTooLong");
+		return result;
+		}
+	int i=0;
+	result[0] = (char)toupper(*firstchar);
+	firstchar+=1;
+	for (i=1; firstchar<lastchar; i++,firstchar++)
+		{
+		result[i] = (char)tolower(*firstchar);
+		}
+	result[i] = '\0';
+	return result;
+	}
+
+int BitmapCompiler::CompressBitmap(SEpocBitmapHeader*& aPbm)
+	{
+	int originalsize = aPbm->iBitmapSize-sizeof(SEpocBitmapHeader);
+	char* newbits=new char[originalsize+sizeof(SEpocBitmapHeader)];
+	if(!newbits)
+		return NoMemory;
+
+	memset(newbits,0xff,sizeof(SEpocBitmapHeader)+originalsize);
+	memcpy(newbits,aPbm,sizeof(SEpocBitmapHeader));
+	char* newbitsptr=newbits+sizeof(SEpocBitmapHeader);
+	char* oldbits=((char*)(aPbm))+sizeof(SEpocBitmapHeader);
+
+	TBitmapfileCompression compression = ENoBitmapCompression;
+	int ret = NoCompression;
+
+	if (aPbm->iBitsPerPixel <= 8)
+		{
+		compression = EByteRLECompression;
+		ret = CompressByteData(newbitsptr,oldbits,originalsize);
+		}
+	else if (aPbm->iBitsPerPixel == 12)
+		{
+		compression = ETwelveBitRLECompression;
+		ret = CompressTwelveBitData(newbitsptr,oldbits,originalsize);
+		}
+	else if (aPbm->iBitsPerPixel == 16)
+		{
+		compression = ESixteenBitRLECompression;
+		ret = CompressSixteenBitData(newbitsptr,oldbits,originalsize);
+		}
+	else if (aPbm->iBitsPerPixel == 24)
+		{
+		compression = ETwentyFourBitRLECompression;
+		ret = CompressTwentyFourBitData(newbitsptr,oldbits,originalsize);
+		}
+	else if (aPbm->iBitsPerPixel == 32 && (aPbm->iColor == EColorBitmap))
+		{
+		compression = EThirtyTwoUBitRLECompression;
+		ret = CompressThirtyTwoUBitData(newbitsptr,oldbits,originalsize);
+		}
+	else if (aPbm->iBitsPerPixel == 32 && (aPbm->iColor == EColorBitmapAlpha))
+		{
+		compression = EThirtyTwoABitRLECompression;
+		ret = CompressThirtyTwoABitData(newbitsptr,oldbits,originalsize);
+		}
+
+	if(ret)
+		{
+		delete [] newbits;
+		if(ret>0)
+			return ret;
+		return NoError;
+		}
+
+	delete aPbm;
+	aPbm = (SEpocBitmapHeader*)newbits;
+	aPbm->iBitmapSize = newbitsptr-(newbits+sizeof(SEpocBitmapHeader))+sizeof(SEpocBitmapHeader);
+	aPbm->iCompression = compression;
+	return NoError;
+	}
+
+int BitmapCompiler::CompressByteData(char*& aDest,char* aSrce,int aSize)
+	{
+	const char* destEnd = aDest + aSize;
+	char* bytepointer=aSrce;
+	char* limitpointer=bytepointer+aSize;
+	int margin = (aSize>>6);
+	char* limitmargin = limitpointer - ((margin > 4) ? margin : 4);
+	char* cutoffpointer=aDest+(aSize>>1)+(aSize>>2);
+	int ret=NoError;
+	char* oldbytepointer=NULL;
+	while(bytepointer<limitmargin)
+		{
+		char value=*bytepointer;
+		if(*(bytepointer+1)==value && *(bytepointer+2)==value)
+			{
+			oldbytepointer=bytepointer;
+			bytepointer+=3;
+			while ( ( bytepointer < limitmargin ) && ( *bytepointer == value ) )
+				bytepointer++;
+			ret = WriteCompressedByteValues(aDest,value,bytepointer-oldbytepointer, destEnd);
+			if(ret) return ret;
+			}
+		else
+			{
+			oldbytepointer=bytepointer;
+			while((bytepointer<limitmargin) && (*(bytepointer+1)!=value || *(bytepointer+2)!=value))
+				{
+				bytepointer++;
+				value=*bytepointer;
+				}
+			ret = WriteCompressedByteData(aDest,oldbytepointer,bytepointer-oldbytepointer, destEnd);
+			if(ret) return ret;
+			}
+		if(aDest>cutoffpointer)
+			return NoCompression;
+		}
+
+	int remaining = limitpointer-bytepointer;
+	if(remaining > 0)
+		{
+		if (aDest + remaining > cutoffpointer)
+			return NoCompression;
+		ret=WriteCompressedByteData(aDest,bytepointer,remaining, destEnd);
+		if(ret) return ret;
+		}
+	return NoError;
+	}
+
+int BitmapCompiler::WriteCompressedByteData(char*& aDest,char* aData,int aLength, const char* aDestEnd)
+	{
+	if(!CanCopy8bppData(aDest, aDestEnd, aLength))
+		return NoCompression;
+	while(aLength>128)
+		{
+		*aDest++=-128;
+		for(int count=0;count<128;count++)
+			*aDest++=*aData++;
+		aLength-=128;
+		}
+	if(aLength>128 || aLength<1) return CompressionError;
+	*aDest++=char(-aLength);
+	for(int count=0;count<aLength;count++)
+		*aDest++=*aData++;
+	return NoError;
+	}
+
+int BitmapCompiler::WriteCompressedByteValues(char*& aDest,char aValue,int aLength, const char* aDestEnd)
+	{
+	if (aLength < 1)
+		return CompressionError;
+
+	if(!CanWrite8bppValue(aDest, aDestEnd, aLength))
+		return NoCompression;
+
+	while (aLength > 128)
+		{
+		*aDest++ = 127;
+		*aDest++ = aValue;
+		aLength -= 128;
+		}
+
+	*aDest++ = char(aLength-1);
+	*aDest++ = aValue;
+
+	return NoError;
+	}
+
+int BitmapCompiler::CompressTwelveBitData(char*& aDest,char* aSrce,int aSizeInBytes)
+	{
+	unsigned short* srcePtr = (unsigned short*)aSrce;
+	unsigned short* srceLimitPtr = srcePtr + (aSizeInBytes / 2);
+	unsigned short* dest = (unsigned short*)aDest;
+
+	while (srcePtr < srceLimitPtr)
+		{
+		unsigned short* runStartPtr = srcePtr;
+		unsigned short value = *srcePtr;
+		do
+			srcePtr++;
+		while (srcePtr < srceLimitPtr && *srcePtr == value);
+		WriteCompressedTwelveBitData(dest,*runStartPtr,srcePtr - runStartPtr); // Ignore error return as 12bpp compression never fails
+		}
+
+	aDest = (char*)dest;
+	return NoError;
+	}
+
+int BitmapCompiler::WriteCompressedTwelveBitData(unsigned short*& aDest,unsigned short aData,int aLength)
+	{
+	// The run length l is stored as l-1 in the top 4 bits of each 16-bit word (between 1 and 16)
+	aData &= 0x0fff;
+	unsigned short maxLengthData = (unsigned short)(aData | 0xf000);
+
+	while(aLength>16)
+		{
+		*aDest++ = maxLengthData;
+		aLength -= 16;
+		}
+
+	if (aLength > 0)
+		*aDest++ = (unsigned short)(aData | ((aLength - 1) << 12));
+
+	return NoError;
+	}
+
+int BitmapCompiler::CompressSixteenBitData(char*& aDest,char* aSrce,int aSizeInBytes)
+	{
+	char* destEnd = aDest + aSizeInBytes;
+	unsigned short* srcePtr = (unsigned short*)aSrce;
+	unsigned short* srceLimitPtr = srcePtr + (aSizeInBytes / 2);
+	unsigned short* srceLimitPtrMinusOne = srceLimitPtr - 1;
+	char* destCompressedLimitPtr = aDest + (aSizeInBytes * 7 / 8);
+	int ret = NoError;
+
+	while (srcePtr < srceLimitPtrMinusOne)
+		{
+		unsigned short value = *srcePtr;
+		unsigned short* runStartPtr = srcePtr++;
+
+		if(*srcePtr == value)
+			{
+			do
+				srcePtr++;
+			while ( ( srcePtr < srceLimitPtr ) && ( *srcePtr == value ) );
+
+			ret = WriteCompressedSixteenBitValues(aDest,value,srcePtr-runStartPtr, destEnd);
+			if (ret)
+				return ret;
+			}
+		else
+			{
+			value = *srcePtr;
+			while (srcePtr < srceLimitPtrMinusOne && *(srcePtr + 1) != value)
+				{
+				srcePtr++;
+				value = *srcePtr;
+				}
+
+			ret = WriteCompressedSixteenBitData(aDest,runStartPtr,srcePtr - runStartPtr, destEnd);
+			if (ret)
+				return ret;
+			}
+		if (aDest > destCompressedLimitPtr)
+			return NoCompression;
+		}
+
+	if (srcePtr < srceLimitPtr)
+		{
+		ret = WriteCompressedSixteenBitData(aDest,srcePtr,srceLimitPtr - srcePtr, destEnd);
+		if (ret)
+			return ret;
+		}
+
+	if (aDest > destCompressedLimitPtr)
+		return NoCompression;
+	return NoError;
+	}
+
+int BitmapCompiler::WriteCompressedSixteenBitData(char*& aDest,unsigned short* aData,
+												  int aLength, const char* aDestEnd)
+	{
+	if (aLength < 1)
+		return CompressionError;
+
+	if(!CanCopy16bppData(aDest, aDestEnd, aLength))
+		return NoCompression;
+
+	char* srcePtr = (char*)aData;
+
+	while (aLength > 128)
+		{
+		*aDest++ = -128;
+		memcpy(aDest,srcePtr,256);
+		aDest += 256;
+		srcePtr += 256;
+		aLength -= 128;
+		}
+
+	*aDest++ = char(-aLength);
+
+	int remainingBytes = aLength * 2;
+	memcpy(aDest,srcePtr,remainingBytes);
+	aDest += remainingBytes;
+
+	return NoError;
+	}
+
+int BitmapCompiler::WriteCompressedSixteenBitValues(char*& aDest,unsigned short aValue,
+													int aLength, const char* aDestEnd)
+	{
+	if (aLength < 1)
+		return CompressionError;
+
+	if(!CanWrite16bppValue(aDest, aDestEnd, aLength))
+		return NoCompression;
+
+	char lowByte = char(aValue);
+	char highByte = char(aValue >> 8);
+
+	while (aLength > 128)
+		{
+		*aDest++ = 127;
+		*aDest++ = lowByte;
+		*aDest++ = highByte;
+		aLength -= 128;
+		}
+
+	*aDest++ = char(aLength-1);
+	*aDest++ = lowByte;
+	*aDest++ = highByte;
+
+	return NoError;
+	}
+
+int BitmapCompiler::CompressTwentyFourBitData(char*& aDest,char* aSrce,int aSizeInBytes)
+	{
+	const char* destEnd = aDest + aSizeInBytes; 
+	char* srceLimitPtr = aSrce + aSizeInBytes;
+	char* srceLimitPtrMinusThree = srceLimitPtr - 3; // three bytes == one pixel
+	char* destCompressedLimitPtr = aDest + (aSizeInBytes * 7 / 8);
+	int ret = NoError;
+
+	while (aSrce < srceLimitPtrMinusThree)
+		{
+		char* runStartPtr = aSrce;
+		char component1 = *aSrce++;
+		char component2 = *aSrce++;
+		char component3 = *aSrce++;
+
+		if (TrueColorPointerCompare(aSrce,component1,component2,component3))
+			{
+			do
+				aSrce += 3;
+			while (aSrce < srceLimitPtr && TrueColorPointerCompare(aSrce,component1,component2,component3));
+
+			ret = WriteCompressedTwentyFourBitValues(aDest,component1,component2,component3,(aSrce - runStartPtr) / 3, destEnd);
+			if (ret)
+				return ret;
+			}
+		else
+			{
+			bool more  = true;
+			bool eqRun = false;
+			do
+				{
+				component1 = *aSrce++;
+				component2 = *aSrce++;
+				component3 = *aSrce++;
+				more = (aSrce < srceLimitPtr);
+				eqRun = more && TrueColorPointerCompare(aSrce,component1,component2,component3);
+				}
+			while (more && !eqRun);
+			if (eqRun)
+				aSrce -= 3;
+			int pixelLength = (aSrce - runStartPtr) / 3;
+			ret = WriteCompressedTwentyFourBitData(aDest,runStartPtr,pixelLength,destEnd);
+			if (ret)
+				return ret;
+			}
+		if (aDest > destCompressedLimitPtr)
+			return NoCompression;
+		}
+
+	if (aSrce < srceLimitPtr)
+		{
+		ret = WriteCompressedTwentyFourBitData(aDest,aSrce,(srceLimitPtr - aSrce) / 3, destEnd);
+		if (ret)
+			return ret;
+		}
+
+	if (aDest > destCompressedLimitPtr)
+		return NoCompression;
+	return NoError;
+	}
+
+int BitmapCompiler::WriteCompressedTwentyFourBitData(char*& aDest,char* aData,
+													 int aLength, const char* aDestEnd)
+	{
+	if (aLength < 1)
+		return CompressionError;
+
+	if(!CanCopy24bppData(aDest, aDestEnd, aLength))
+		return NoCompression;
+
+	while (aLength > 128)
+		{
+		*aDest++ = -128;
+		memcpy(aDest,aData,384);
+		aDest += 384;
+		aData += 384;
+		aLength -= 128;
+		}
+
+	*aDest++ = char(-aLength);
+
+	int remainingBytes = aLength * 3;
+	memcpy(aDest,aData,remainingBytes);
+	aDest += remainingBytes;
+
+	return NoError;
+	}
+
+int BitmapCompiler::WriteCompressedTwentyFourBitValues(char*& aDest,char aComponent1,
+													   char aComponent2,char aComponent3,
+													   int aLength, const char* aDestEnd)
+	{
+	if (aLength < 1)
+		return CompressionError;
+
+	if(!CanWrite24bppValue(aDest, aDestEnd, aLength))
+		return NoCompression;
+
+	while (aLength > 128)
+		{
+		*aDest++ = 127;
+		*aDest++ = aComponent1;
+		*aDest++ = aComponent2;
+		*aDest++ = aComponent3;
+		aLength -= 128;
+		}
+
+	*aDest++ = char(aLength-1);
+	*aDest++ = aComponent1;
+	*aDest++ = aComponent2;
+	*aDest++ = aComponent3;
+
+	return NoError;
+	}
+
+/** The function encodes 32-bit buffer into 24-bit stream by using RLE compression algorithm*/
+int BitmapCompiler::CompressThirtyTwoUBitData(char*& aDest,char* aSrce,int aSizeInBytes)
+	{
+	const char* destEnd = aDest + aSizeInBytes; 
+	char* srceLimitPtr = aSrce + aSizeInBytes;
+	char* srceLimitPtrMinusFour = srceLimitPtr - 4; // four bytes == one pixel
+	char* destCompressedLimitPtr = aDest + (aSizeInBytes * 7 / 8);
+	int ret = NoError;
+
+	while (aSrce < srceLimitPtrMinusFour)
+		{
+		char* runStartPtr = aSrce;
+		char component1 = *aSrce++;
+		char component2 = *aSrce++;
+		char component3 = *aSrce++;
+		aSrce++;
+
+		if (TrueColorPointerCompare(aSrce,component1,component2,component3))
+			{
+			do
+				aSrce += 4;
+			while (aSrce < srceLimitPtr && TrueColorPointerCompare(aSrce,component1,component2,component3));
+
+			ret = WriteCompressedThirtyTwoUBitValues(aDest,component1,component2,component3,(aSrce - runStartPtr) / 4, destEnd);
+			if (ret)
+				return ret;
+			}
+		else //non repeating pixel buffer
+			{
+			bool more  = true;
+			bool eqRun = false;
+			do {
+				component1 = *aSrce++;
+				component2 = *aSrce++;
+				component3 = *aSrce++;
+				aSrce++; //last byte is unused (no alpha component)
+				more = (aSrce < srceLimitPtr);
+				eqRun = more && TrueColorPointerCompare(aSrce,component1,component2,component3);
+				} while (more && !eqRun);
+			if (eqRun)
+				aSrce -= 4;
+			int pixelLength = (aSrce - runStartPtr) / 4;
+			ret = WriteCompressedThirtyTwoUBitData(aDest,runStartPtr,pixelLength,destEnd);
+ 			if (ret)
+				return ret;
+			}
+		if (aDest > destCompressedLimitPtr)
+			return NoCompression;
+		}
+
+	if (aSrce < srceLimitPtr)
+		{
+		ret = WriteCompressedThirtyTwoUBitData(aDest,aSrce,(srceLimitPtr - aSrce) / 4, destEnd);
+		if (ret)
+			return ret;
+		}
+
+	if (aDest > destCompressedLimitPtr)
+		return NoCompression;
+	return NoError;
+	}
+
+/** The function copies non repeating 32-bit buffer to 24-bit compressed buffer*/
+int BitmapCompiler::WriteCompressedThirtyTwoUBitData(char*& aDest,char* aData,
+													 int aLength, const char* aDestEnd)
+	{
+	if (aLength < 1)
+		return CompressionError;
+
+	if(!CanCopy24bppData(aDest, aDestEnd, aLength))
+		return NoCompression;
+
+	while (aLength > 128)
+		{
+		*aDest++ = -128;
+		for(int ii = 0; ii < 128; ii++)
+			{
+			memcpy(aDest,aData, 3);
+			aDest += 3;
+			aData += 4;
+			}
+		aLength -= 128;
+		}
+
+	*aDest++ = char(-aLength);
+
+	while(aLength--)
+		{
+		memcpy(aDest,aData, 3);
+		aDest += 3;
+		aData += 4;
+		}
+
+	return NoError;
+	}
+
+/** The function copies repeating colour to the 24-bit compressed buffer */
+int BitmapCompiler::WriteCompressedThirtyTwoUBitValues(char*& aDest,char aComponent1,
+													   char aComponent2,char aComponent3,
+													   int aLength, const char* aDestEnd)
+	{
+	if (aLength < 1)
+		return CompressionError;
+
+	if(!CanWrite24bppValue(aDest, aDestEnd, aLength))
+		return NoCompression;
+	while (aLength > 128)
+		{
+		*aDest++ = 127;
+		*aDest++ = aComponent1;
+		*aDest++ = aComponent2;
+		*aDest++ = aComponent3;
+		aLength -= 128;
+		}
+
+	*aDest++ = char(aLength-1);
+	*aDest++ = aComponent1;
+	*aDest++ = aComponent2;
+	*aDest++ = aComponent3;
+
+	return NoError;
+	}
+
+int BitmapCompiler::TrueColorPointerCompare(char* aColorPointer,char aComponent1,char aComponent2,char aComponent3)
+	{
+	return (*aColorPointer == aComponent1 && *(aColorPointer + 1) == aComponent2 && *(aColorPointer + 2) == aComponent3);
+	}
+
+/** The function encodes 32-bit buffer into 32-bit stream by using RLE compression algorithm*/
+int BitmapCompiler::CompressThirtyTwoABitData(char*& aDest,char* aSrce,int aSizeInBytes)
+	{
+	const char* destEnd = aDest + aSizeInBytes; 
+	char* srceLimitPtr = aSrce + aSizeInBytes;
+	char* srceLimitPtrMinusFour = srceLimitPtr - 4; // four bytes == one pixel
+	char* destCompressedLimitPtr = aDest + (aSizeInBytes * 7 / 8);
+	int ret = NoError;
+
+	while (aSrce < srceLimitPtrMinusFour)
+		{
+		char* runStartPtr = aSrce;
+		char component1 = *aSrce++;
+		char component2 = *aSrce++;
+		char component3 = *aSrce++;
+		char component4 = *aSrce++;
+
+		if (ColorAlphaPointerCompare(aSrce,component1,component2,component3,component4))
+			{
+			do
+				aSrce += 4;
+			while (aSrce < srceLimitPtr && ColorAlphaPointerCompare(aSrce,component1,component2,component3,component4));
+			int eqPixelLength = (aSrce - runStartPtr) / 4;
+			ret = WriteCompressedThirtyTwoABitValues(aDest,component1,component2,component3,component4,eqPixelLength,destEnd);
+			if (ret)
+				return ret;
+			}
+		else //non repeating pixel buffer
+			{
+			bool more  = true;
+			bool eqRun = false;
+			do {
+				component1 = *aSrce++;
+				component2 = *aSrce++;
+				component3 = *aSrce++;
+				component4 = *aSrce++;
+				more = (aSrce < srceLimitPtr);
+				eqRun = more && ColorAlphaPointerCompare(aSrce,component1,component2,component3,component4);
+				} while (more && !eqRun);
+			if (eqRun)
+				aSrce -= 4;
+			int nePixelLength = (aSrce - runStartPtr) / 4;
+			ret = WriteCompressedThirtyTwoABitData(aDest,runStartPtr,nePixelLength,destEnd);
+			if (ret)
+				return ret;
+			}
+		if (aDest > destCompressedLimitPtr)
+			return NoCompression;
+		}
+
+	if (aSrce < srceLimitPtr)
+		{
+		ret = WriteCompressedThirtyTwoABitData(aDest,aSrce,(srceLimitPtr - aSrce) / 4, destEnd);
+		if (ret)
+			return ret;
+		}
+
+	if (aDest > destCompressedLimitPtr)
+		return NoCompression;
+	return NoError;
+	}
+
+/** The function copies non repeating 32-bit buffer to 32-bit compressed buffer*/
+int BitmapCompiler::WriteCompressedThirtyTwoABitData(char*& aDest,char* aData,
+													 int aLength, const char* aDestEnd)
+	{
+	if (aLength < 1)
+		return CompressionError;
+
+	if(!CanCopy32bppData(aDest, aDestEnd, aLength))
+		return NoCompression;
+
+	while (aLength > 128)
+		{
+		*aDest++ = -128;
+		memcpy(aDest,aData,512);
+		aDest += 512;
+		aData += 512;
+		aLength -= 128;
+		}
+
+	*aDest++ = char(-aLength);
+	memcpy(aDest,aData, aLength*4);
+	aDest += aLength*4;
+	return NoError;
+	}
+
+/** The function copies repeating pixels including alpha to a 32-bit compressed buffer */
+int BitmapCompiler::WriteCompressedThirtyTwoABitValues(char*& aDest,char aComponent1,
+													   char aComponent2,char aComponent3,
+													   char aComponent4,int aLength,
+													   const char* aDestEnd)
+
+	{
+	if (aLength < 1)
+		return CompressionError;
+
+	if(!CanWrite32bppValue(aDest, aDestEnd, aLength))
+		return NoCompression;
+	while (aLength > 128)
+		{
+		*aDest++ = 127;
+		*aDest++ = aComponent1;
+		*aDest++ = aComponent2;
+		*aDest++ = aComponent3;
+		*aDest++ = aComponent4;
+		aLength -= 128;
+		}
+
+	*aDest++ = char(aLength-1);
+	*aDest++ = aComponent1;
+	*aDest++ = aComponent2;
+	*aDest++ = aComponent3;
+	*aDest++ = aComponent4;
+
+	return NoError;
+	}
+
+int BitmapCompiler::ColorAlphaPointerCompare(char* aColorPointer,char aComponent1,char aComponent2,char aComponent3,char aComponent4)
+	{
+	return (*aColorPointer == aComponent1 && *(aColorPointer + 1) == aComponent2 && *(aColorPointer + 2) == aComponent3 && *(aColorPointer + 3) == aComponent4);
+	}
+
+int BitmapCompiler::ReadHexString(char aHexBuf[10],char*& aDataPtr,char* aDataPtrLimit)
+	{
+	while (aDataPtr < aDataPtrLimit)
+		{
+		if (aDataPtr[0] == '0')
+			{
+			if (aDataPtr[1] == 'x' || aDataPtr[1] == 'X')
+				{
+				memcpy(aHexBuf,aDataPtr,10);
+				aDataPtr += 10;
+				return NoError;
+				}
+			}
+		aDataPtr++;
+		}
+
+	return PaletteFile;
+	}
+
+int BitmapCompiler::HexToInt(char aHighNibble,char aLowNibble)
+	{
+	return (HexToInt(aHighNibble) << 4) + HexToInt(aLowNibble);
+	}
+
+int BitmapCompiler::HexToInt(char aNibble)
+	{
+	int value = 0;
+
+	if (aNibble >= '0' && aNibble <= '9')
+		value = aNibble - '0';
+	else if (aNibble >= 'a' && aNibble <= 'f')
+		value = aNibble - 'a' + 10;
+	else if (aNibble >= 'A' && aNibble <= 'F')
+		value = aNibble - 'A' + 10;
+
+	return value;
+	}
+
+void BitmapCompiler::CopyTail(void* aDst, void* aSrc, int aFullSize, int aSkipped)
+	{
+	memcpy(aDst, ((char*)aSrc)+aSkipped, aFullSize-aSkipped);
+	}
+
+
+
+TSourceFile::TSourceFile()
+: iFileName(0), iInfo(EFormatNotImportant)
+	{
+	}
+
+char*& TSourceFile::FileName()
+	{
+	return iFileName;
+	}
+
+void TSourceFile::SetCompileInfo(TCompileInfo aInfo)
+	{
+	iInfo = aInfo;
+	}
+
+void TSourceFile::WriteCompileInfo(ostream& aOut)
+	{
+	aOut << iFileName;
+	if (iInfo == ENokiaBitmap)
+		aOut << " (Nokia format)";
+	else if (iInfo == EThirdPartyBitmap)
+		aOut << " (Third party format)";
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/bmconv_s60/src/PBMTOBM.CPP	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,730 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include <assert.h>
+#include "BMCONV.H"
+
+EpocLoader::EpocLoader():
+	iPbmBits(NULL)
+	{}
+
+EpocLoader::~EpocLoader()
+	{
+	delete iPbmBits;
+	}
+
+int EpocLoader::EpocBitmapCount(char* aFileName, int& aCount, int& isRomFormat)
+    {
+#if defined(__MSVCDOTNET__) || defined(__TOOLS2__) || defined(__CW32__)
+	fstream file(aFileName, ios::in | ios::binary);
+#else //!__MSVCDOTNET__
+	fstream file(aFileName, ios::in | ios::binary | ios::nocreate);
+#endif //__MSVCDOTNET__
+
+	if (file.is_open()==0)
+		return Files;
+
+	long int wordbuffer;
+	file.read((char *)&wordbuffer,4);
+	if (file.gcount()!=4)
+		return SourceFile;
+	if (wordbuffer==KMultiBitmapRomImageUid)
+		{
+		// ROM format file - next 4 bytes are the number of bitmaps
+		isRomFormat=1;
+		}
+	else
+		{
+		if (wordbuffer!=KWriteOnceFileStoreUid)
+			return SourceFile;
+		isRomFormat=0;
+		file.read((char *)&wordbuffer,4);
+		if (file.gcount()!=4 || wordbuffer!=KMultiBitmapFileImageUid)
+			return SourceFile;
+		file.read((char *)&wordbuffer,4);
+		if (file.gcount()!=4 || wordbuffer!=0)
+			return SourceFile;
+		file.read((char *)&wordbuffer,4);
+		if (file.gcount()!=4 || wordbuffer!=KMultiBitmapFileImageChecksum)
+			return SourceFile;
+		file.read((char *)&wordbuffer,4);
+		if (file.gcount()!=4)
+			return SourceFile;
+		file.seekg(wordbuffer,ios::beg);
+		}
+	file.read((char *)&wordbuffer,4);
+	if (file.gcount()!=4)
+		return SourceFile;
+	aCount=wordbuffer;
+	return NoError;
+    }
+
+int EpocLoader::LoadEpocBitmap(char* aFileName,int aIndex)
+	{
+#if defined(__MSVCDOTNET__) || defined(__TOOLS2__) || defined(__CW32__)
+	fstream file(aFileName, ios::in | ios::binary);
+#else //!__MSVCDOTNET__
+	fstream file(aFileName, ios::in | ios::binary | ios::nocreate);
+#endif //__MSVCDOTNET__
+
+	if (file.is_open()==0)
+		return Files;
+
+	long int wordbuffer;
+	file.read((char *)&wordbuffer,4);
+	if (file.gcount()!=4)
+		return SourceFile;
+	file.close();
+
+	if (wordbuffer==KMultiBitmapRomImageUid)
+		return LoadRom(aFileName,aIndex);
+
+	return LoadFile(aFileName,aIndex);
+	}
+
+int EpocLoader::LoadFile(char* aFileName,int aIndex)
+	{
+#if defined(__MSVCDOTNET__) || defined(__TOOLS2__) || defined(__CW32__)
+	fstream file(aFileName, ios::in | ios::binary);
+#else //!__MSVCDOTNET__
+	fstream file(aFileName, ios::in | ios::binary | ios::nocreate);
+#endif //__MSVCDOTNET__
+
+	if (file.is_open()==0)
+		return Files;
+
+	long int wordbuffer;
+	file.read((char *)&wordbuffer,4);
+	if (file.gcount()!=4 || wordbuffer!=KWriteOnceFileStoreUid)
+		return SourceFile;
+	file.read((char *)&wordbuffer,4);
+	if (file.gcount()!=4 || wordbuffer!=KMultiBitmapFileImageUid)
+		return SourceFile;
+	file.read((char *)&wordbuffer,4);
+	if (file.gcount()!=4 || wordbuffer!=0)
+		return SourceFile;
+	file.read((char *)&wordbuffer,4);
+	if (file.gcount()!=4 || wordbuffer!=KMultiBitmapFileImageChecksum)
+		return SourceFile;
+	file.read((char *)&wordbuffer,4);
+	if (file.gcount()!=4)
+		return SourceFile;
+	file.seekg(wordbuffer,ios::beg);
+	file.read((char *)&wordbuffer,4);
+	if (file.gcount()!=4)
+		return SourceFile;
+
+	int numsources=wordbuffer;
+	if (aIndex >= numsources)
+		return OutOfRange;
+	file.seekg(aIndex*4,ios::cur);
+	file.read((char *)&wordbuffer,4);
+	if (file.gcount()!=4)
+		return SourceFile;
+	file.seekg(wordbuffer,ios::beg);
+	int ret = DoLoadFile(file);
+	file.close();
+	return ret;
+	}
+
+int EpocLoader::LoadRom(char* aFileName,int aIndex)
+	{
+#if defined(__MSVCDOTNET__) || defined(__TOOLS2__) || defined(__CW32__)
+	fstream file(aFileName, ios::in | ios::binary);
+#else //!__MSVCDOTNET__
+	fstream file(aFileName, ios::in | ios::binary | ios::nocreate);
+#endif //__MSVCDOTNET__
+
+	if (file.is_open()==0)
+		return Files;
+
+	long int wordbuffer;
+	file.read((char *)&wordbuffer,4);
+	if (file.gcount()!=4)
+		return SourceFile;
+	if (wordbuffer!=KMultiBitmapRomImageUid)
+		return SourceFile;
+	file.read((char *)&wordbuffer,4);
+	if (file.gcount()!=4)
+		return SourceFile;
+	if (aIndex>=wordbuffer)
+		return OutOfRange;
+	file.seekg(aIndex*4,ios::cur);
+	file.read((char *)&wordbuffer,4);
+	if (file.gcount()!=4)
+		return SourceFile;
+	file.seekg(wordbuffer,ios::beg);
+	int ret=DoLoadRom(file);
+	file.close();
+	return ret;
+	}
+
+int EpocLoader::DoLoadFile(fstream& aFile)
+	{
+	long size = sizeof(SEpocBitmapHeader);
+	aFile.read((char *)&iPbmHeader,size);
+	if (aFile.gcount()!=size)
+		return SourceFile;
+	iOriginalPbmHeader = iPbmHeader;
+	size=iPbmHeader.iBitmapSize-iPbmHeader.iStructSize;
+
+	iPbmBits=new char[size];
+	if (iPbmBits==NULL)
+		return NoMemory;
+	memset(iPbmBits,0xff,size);
+	aFile.read(iPbmBits,size);
+	aFile.close();
+	if (aFile.gcount() != size)
+		return SourceFile;
+
+	if (iPbmHeader.iCompression != ENoBitmapCompression)
+		{
+		return Decompress(size);
+		}
+
+	return NoError;
+	}
+
+int EpocLoader::DoLoadRom(fstream& aFile)
+	{
+	Bitmap bmp;
+	long size=sizeof(Bitmap);
+	aFile.read((char*)&bmp,size);
+	if (aFile.gcount() != size)
+		return SourceFile;
+
+	size = bmp.iHeader.iBitmapSize - sizeof(SEpocBitmapHeader);
+	iPbmBits = new char[size];
+	if (iPbmBits == NULL)
+		return NoMemory;
+	memset(iPbmBits,0xff,size);
+
+	aFile.read(iPbmBits,size);
+	if (aFile.gcount() != size)
+		return SourceFile;
+	iPbmHeader = bmp.iHeader;
+	iOriginalPbmHeader = iPbmHeader;
+
+	if (iPbmHeader.iCompression != ENoBitmapCompression)
+		{
+		return Decompress(size);
+		}
+
+	return NoError;
+	}
+
+int EpocLoader::Decompress(int aSize)
+	{
+	int byteWidth = BitmapUtils::ByteWidth(iPbmHeader.iWidthInPixels,iPbmHeader.iBitsPerPixel);
+	int expandedsize = byteWidth * iPbmHeader.iHeightInPixels;
+	char* newbits = new char[expandedsize];
+	if (newbits == NULL)
+		return NoMemory;
+	memset(newbits,0xff,expandedsize);
+	int ret = NoError;
+	switch (iPbmHeader.iCompression)
+		{
+	case EByteRLECompression:
+		ret = ExpandByteRLEData(newbits,expandedsize,iPbmBits,aSize);
+		break;
+	case ETwelveBitRLECompression:
+		ret = ExpandTwelveBitRLEData(newbits,expandedsize,iPbmBits,aSize);
+		break;
+	case ESixteenBitRLECompression:
+		ret = ExpandSixteenBitRLEData(newbits,expandedsize,iPbmBits,aSize);
+		break;
+	case ETwentyFourBitRLECompression:
+		ret = ExpandTwentyFourBitRLEData(newbits,expandedsize,iPbmBits,aSize);
+		break;
+	case EThirtyTwoUBitRLECompression:
+		ret = ExpandThirtyTwoUBitRLEData(newbits,expandedsize,iPbmBits,aSize);
+		break;
+	case EThirtyTwoABitRLECompression:
+		ret = ExpandThirtyTwoABitRLEData(newbits,expandedsize,iPbmBits,aSize);
+		break;
+	default:
+		ret = UnknownCompression;
+		break;
+		}
+	delete iPbmBits;
+	iPbmBits = newbits;
+	iPbmHeader.iCompression = ENoBitmapCompression;
+	iPbmHeader.iBitmapSize += expandedsize-aSize;
+	return ret;
+	}
+
+int EpocLoader::ExpandByteRLEData(char* aDest,int aDestSize,char* aSrce,int aSrceSize)
+	{
+	char* srcelimit=aSrce+aSrceSize;
+	char* destlimit=aDest+aDestSize;
+	while(aSrce<srcelimit && aDest<destlimit)
+		{
+		char count=*aSrce++;
+		if (count<0)
+			{
+			int runLength=-count;
+			memcpy(aDest,aSrce,runLength);
+			aSrce+=runLength;
+			aDest+=runLength;
+			}
+		else
+			{
+			char value=*aSrce++;
+			while(count>=0)
+				{
+				*aDest++=value;
+				count--;
+				}
+			}
+		}
+	if (aSrce!=srcelimit || aDest!=destlimit)
+		return DecompressionError;
+	return NoError;
+	}
+
+int EpocLoader::ExpandTwelveBitRLEData(char* aDest,int aDestSizeInBytes,char* aSrce,int aSrceSizeInBytes)
+	{
+	unsigned short* srcePtr = (unsigned short*)aSrce;
+	unsigned short* destPtr = (unsigned short*)aDest;
+	unsigned short* srcePtrLimit = srcePtr + (aSrceSizeInBytes / 2);
+	unsigned short* destPtrLimit = destPtr + (aDestSizeInBytes / 2);
+
+	while (srcePtr < srcePtrLimit && destPtr < destPtrLimit)
+		{
+		unsigned short value = *srcePtr++;
+		int runLength = (value >> 12) + 1;
+		value &= 0x0fff;
+
+		for (;runLength > 0;runLength--)
+			*destPtr++ = value;
+		}
+
+	if (srcePtr != srcePtrLimit || destPtr != destPtrLimit)
+		return DecompressionError;
+
+	return NoError;
+	}
+
+int EpocLoader::ExpandSixteenBitRLEData(char* aDest,int aDestSizeInBytes,char* aSrce,int aSrceSizeInBytes)
+	{
+	char* srcePtrLimit = aSrce + aSrceSizeInBytes;
+	unsigned short* destPtr = (unsigned short*)aDest;
+	unsigned short* destPtrLimit = destPtr + (aDestSizeInBytes / 2);
+
+	while (aSrce < srcePtrLimit && destPtr < destPtrLimit)
+		{
+		int runLength = *aSrce++;
+
+		if (runLength >= 0)
+			{
+			unsigned short value = *((unsigned short*)(aSrce));
+			aSrce += 2;
+			for (runLength++; runLength > 0; runLength--)
+				*destPtr++ = value;
+			}
+		else
+			{
+			runLength = -runLength;
+			int byteLength = runLength * 2;
+			memcpy(destPtr,aSrce,byteLength);
+			aSrce += byteLength;
+			destPtr += runLength;
+			}
+		}
+
+	if (aSrce != srcePtrLimit || destPtr != destPtrLimit)
+		return DecompressionError;
+
+	return NoError;
+	}
+
+int EpocLoader::ExpandTwentyFourBitRLEData(char* aDest,int aDestSizeInBytes,char* aSrce,int aSrceSizeInBytes)
+	{
+	char* srcePtrLimit = aSrce + aSrceSizeInBytes;
+	char* destPtrLimit = aDest + aDestSizeInBytes;
+
+	while (aSrce < srcePtrLimit && aDest < destPtrLimit)
+		{
+		int runLength = *aSrce++;
+
+		if (runLength >= 0)
+			{
+			char component1 = *aSrce++;
+			char component2 = *aSrce++;
+			char component3 = *aSrce++;
+			for (runLength++; runLength > 0; runLength--)
+				{
+				*aDest++ = component1;
+				*aDest++ = component2;
+				*aDest++ = component3;
+				}
+			}
+		else
+			{
+			runLength = -runLength;
+			int byteLength = runLength * 3;
+			memcpy(aDest,aSrce,byteLength);
+			aSrce += byteLength;
+			aDest += byteLength;
+			}
+		}
+
+	if (aSrce != srcePtrLimit || aDest != destPtrLimit)
+		return DecompressionError;
+
+	return NoError;
+	}
+
+/** The function decodes 24-bit compressed pixel buffer into the 32-bit buffer, where top bytes are unused*/
+int EpocLoader::ExpandThirtyTwoUBitRLEData(char* aDest,int aDestSizeInBytes,char* aSrce,int aSrceSizeInBytes)
+	{
+	char* srcePtrLimit = aSrce + aSrceSizeInBytes;
+	char* destPtrLimit = aDest + aDestSizeInBytes;
+
+	while (aSrce < srcePtrLimit && aDest < destPtrLimit)
+		{
+		int runLength = *aSrce++;
+
+		if (runLength >= 0)
+			{
+			char component1 = *aSrce++;
+			char component2 = *aSrce++;
+			char component3 = *aSrce++;
+			for (runLength++; runLength > 0; runLength--)
+				{
+				*aDest++ = component1;
+				*aDest++ = component2;
+				*aDest++ = component3;
+				aDest++;
+				}
+			}
+		else 
+			{
+			runLength = -runLength;
+			for(int ii = 0; ii < runLength; ii++)
+				{
+				memcpy(aDest,aSrce,3);
+				aSrce += 3;
+				aDest += 4;
+				}
+			}
+		}
+
+	if (aSrce != srcePtrLimit || aDest != destPtrLimit)
+		return DecompressionError;
+
+	return NoError;
+	}
+
+/** The function decodes 32-bit compressed pixel buffer into the 32-bit buffer, where top bytes are alpha channel*/
+int EpocLoader::ExpandThirtyTwoABitRLEData(char* aDest,int aDestSizeInBytes,char* aSrce,int aSrceSizeInBytes)
+	{
+	char* srcePtrLimit = aSrce + aSrceSizeInBytes;
+	char* destPtrLimit = aDest + aDestSizeInBytes;
+
+	while (aSrce < srcePtrLimit && aDest < destPtrLimit)
+		{
+		int runLength = *aSrce++;
+
+		if (runLength >= 0)
+			{
+			char component1 = *aSrce++;
+			char component2 = *aSrce++;
+			char component3 = *aSrce++;
+			char component4 = *aSrce++;
+			for (runLength++; runLength > 0; runLength--)
+				{
+				*aDest++ = component1;
+				*aDest++ = component2;
+				*aDest++ = component3;
+				*aDest++ = component4;
+				}
+			}
+		else 
+			{
+			runLength = -runLength;
+			memcpy(aDest,aSrce,4*runLength);
+			aSrce += 4*runLength;
+			aDest += 4*runLength;
+			}
+		}
+
+	if (aSrce != srcePtrLimit || aDest != destPtrLimit)
+		return DecompressionError;
+
+	return NoError;
+	}
+
+TRgb EpocLoader::GetPixel(int aXCoord,int aYCoord)
+	{
+	unsigned char col;
+	aXCoord%=iPbmHeader.iWidthInPixels;
+	aYCoord%=iPbmHeader.iHeightInPixels;
+	int byteWidth = BitmapUtils::ByteWidth(iPbmHeader.iWidthInPixels,iPbmHeader.iBitsPerPixel);
+	int yOffset = aYCoord * byteWidth;
+
+	switch(iPbmHeader.iBitsPerPixel)
+		{
+		case 1:
+			col = iPbmBits[yOffset + (aXCoord / 8)];
+			col >>= (aXCoord&7);
+			return TRgb::Gray2(col & 1);
+		case 2:
+			col = iPbmBits[yOffset + (aXCoord / 4)];
+			col = (unsigned char)(col>>(2*(aXCoord%4)));
+			return TRgb::Gray4(col & 3);
+		case 4:
+			col = iPbmBits[yOffset + (aXCoord / 2)];
+			if (aXCoord & 1)
+				col >>= 4;
+			col &= 0xf;
+			if (iPbmHeader.iColor==EColorBitmap)
+				return TRgb::Color16(col);
+			else
+				return TRgb::Gray16(col);
+		case 8:
+			col=iPbmBits[yOffset + aXCoord];
+			if (iPbmHeader.iColor==EColorBitmap)
+				return TRgb::Color256(col);
+			else
+				return TRgb::Gray256(col);
+		case 12:
+		case 16:
+			{
+			unsigned short* shortPtr = (unsigned short*)&iPbmBits[yOffset + (aXCoord * 2)];
+			if (iPbmHeader.iBitsPerPixel == 12)
+				return TRgb::Color4K(*shortPtr);
+			else
+				return TRgb::Color64K(*shortPtr);
+			}
+		case 24:
+			{
+			char* pixelPtr = iPbmBits + yOffset + (aXCoord * 3);
+			TRgb pixelColor;
+			pixelColor.iBlue = *pixelPtr++;
+			pixelColor.iGreen = *pixelPtr++;
+			pixelColor.iRed = *pixelPtr;
+			return pixelColor;
+			}
+		case 32:
+			{
+			char* pixelPtr = iPbmBits + yOffset + (aXCoord * 4);
+			TRgb pixelColor;
+			pixelColor.iBlue = *pixelPtr++;
+			pixelColor.iGreen = *pixelPtr++;
+			pixelColor.iRed = *pixelPtr++;
+			pixelColor.iSpare = *pixelPtr;
+			return pixelColor;
+			}
+		default:
+			return TRgb(0);
+		}
+	}
+
+unsigned char EpocLoader::GetAlpha(int aXCoord,int aYCoord)
+	{
+	aXCoord%=iPbmHeader.iWidthInPixels;
+	aYCoord%=iPbmHeader.iHeightInPixels;
+	int byteWidth = BitmapUtils::ByteWidth(iPbmHeader.iWidthInPixels,iPbmHeader.iBitsPerPixel);
+	int yOffset = aYCoord * byteWidth;
+
+	assert(iPbmHeader.iBitsPerPixel == 32); // this method must only be called for 32bpp bitmaps!
+
+	char* pixelPtr = iPbmBits + yOffset + (aXCoord * 4);
+	pixelPtr += 3; // skip over RGB
+	unsigned char col = *pixelPtr;
+	return col;	
+	}
+
+int EpocLoader::SaveBitmap(char* aFileName)
+	{
+	TBitmapFileHeader fileheader;
+	TBitmapInfoHeader bmpHeader;
+	char* bmpBits;
+
+	bmpHeader.biSize = sizeof(TBitmapInfoHeader);
+	bmpHeader.biWidth = iPbmHeader.iWidthInPixels;
+	bmpHeader.biHeight = iPbmHeader.iHeightInPixels;
+	bmpHeader.biPlanes = 1;
+	bmpHeader.biBitCount = 24;
+	bmpHeader.biCompression = 0;
+	bmpHeader.biSizeImage = 0;
+	bmpHeader.biXPelsPerMeter = 0;
+	bmpHeader.biYPelsPerMeter = 0;
+	bmpHeader.biClrUsed = 0;
+	bmpHeader.biClrImportant = 0;
+
+	long byteWidth = ((bmpHeader.biWidth * 3) + 3) & ~3;
+	long destlength = bmpHeader.biHeight * byteWidth;
+
+	fileheader.bfType = 'B'+('M'<<8);
+	fileheader.bfSize = sizeof(TBitmapFileHeader)+sizeof(TBitmapInfoHeader)+destlength;
+	fileheader.bfReserved1 = 0;
+	fileheader.bfReserved2 = 0;
+	fileheader.bfOffBits = sizeof(TBitmapFileHeader)+sizeof(TBitmapInfoHeader);
+
+	bmpBits = new char[destlength];
+	if (bmpBits == NULL)
+		return NoMemory;
+	memset(bmpBits,0xff,destlength);
+
+	for(long y=0;y<bmpHeader.biHeight;y++)
+		{
+		char* dest=&bmpBits[(bmpHeader.biHeight-y-1)*byteWidth];
+		for(long x=0;x<bmpHeader.biWidth;x++)
+			{
+			TRgb pixel=GetPixel(x,y);
+			*dest++=pixel.iBlue;
+			*dest++=pixel.iGreen;
+			*dest++=pixel.iRed;
+			}
+		}
+
+	fstream file(aFileName, ios::out | ios::binary);
+
+	if (file.is_open()==0)
+		{
+		delete bmpBits;
+		return DestFile;
+		}
+
+	file.write((char *)&fileheader,sizeof(TBitmapFileHeader));
+	file.write((char *)&bmpHeader,sizeof(TBitmapInfoHeader));
+	file.write((char *)bmpBits,destlength);
+	file.close();
+
+	delete bmpBits;
+
+	if (iPbmHeader.iColor == EColorBitmapAlpha)
+		SaveAlpha(aFileName);
+	return NoError;
+	}
+
+
+int EpocLoader::SaveAlpha(char* aFileName)
+	{
+	TBitmapFileHeader fileheader;
+	TBitmapInfoHeader alphaHeader;
+
+	alphaHeader.biSize = sizeof(TBitmapInfoHeader);
+	alphaHeader.biWidth = iPbmHeader.iWidthInPixels;
+	alphaHeader.biHeight = iPbmHeader.iHeightInPixels;
+	alphaHeader.biPlanes = 1;
+	alphaHeader.biBitCount = 8;
+	alphaHeader.biCompression = 0;
+	alphaHeader.biSizeImage = 0;
+	alphaHeader.biXPelsPerMeter = 0;
+	alphaHeader.biYPelsPerMeter = 0;
+	alphaHeader.biClrUsed = 256;
+	alphaHeader.biClrImportant = 0;
+
+	const long paletteSize = 1024;
+
+	// ensure bytes-per-scanline is a large enough multiple of 4
+	long byteWidth = (alphaHeader.biWidth + 3) & ~3; 
+	long destlength = alphaHeader.biHeight * byteWidth;
+	alphaHeader.biSizeImage = destlength;
+
+	fileheader.bfType = 'B'+('M'<<8);
+	fileheader.bfSize = sizeof(TBitmapFileHeader)+sizeof(TBitmapInfoHeader)+paletteSize+destlength;
+	fileheader.bfReserved1 = 0;
+	fileheader.bfReserved2 = 0;
+	fileheader.bfOffBits = sizeof(TBitmapFileHeader)+sizeof(TBitmapInfoHeader)+paletteSize;
+
+	// we need to output the grayscale palette before the actual alpha data as this is an 8bpp BMP
+	char* palette = new char[paletteSize]; // 256 colors x 4bytes/color (r,g,b,unused)
+	if (palette == NULL)
+		return NoMemory;
+	memset(palette,0,paletteSize);
+	char* pEnt = palette;
+	for (long p=0;p<256;++p)
+		{
+		unsigned char col = (unsigned char)p;
+		*pEnt++=col;
+		*pEnt++=col;
+		*pEnt++=col;
+		pEnt++;
+		}
+
+	char* alphaBits = new char[destlength];
+	if (alphaBits == NULL)
+		{
+		delete [] palette;
+		return NoMemory;
+		}
+	memset(alphaBits,0,destlength);
+
+	for(long y=0;y<alphaHeader.biHeight;y++)
+		{
+		char* dest=&alphaBits[(alphaHeader.biHeight-y-1)*byteWidth];
+		for(long x=0;x<alphaHeader.biWidth;x++)
+			{
+			unsigned char alphaVal=GetAlpha(x,y);
+			*dest++=alphaVal;
+			}
+		}
+
+	int fileNameLen = strlen(aFileName);
+	char* alphaFileName = new char[fileNameLen + 7];// -alpha suffix is 6 chars, plus NUL termination
+	if (alphaFileName == NULL)
+		{
+		delete [] palette;
+		delete [] alphaBits;
+		return NoMemory;
+		}
+	int dotPos = -1;
+	for (int i = 0; i < fileNameLen; ++i)
+		if (aFileName[i]=='.')
+			dotPos=i;
+	int prefixLen = (dotPos>=0?dotPos:fileNameLen);
+	memcpy(alphaFileName,aFileName,prefixLen);
+	const char* suffix = "-alpha";
+	memcpy(alphaFileName+prefixLen,suffix,6);
+	if (dotPos>=0)
+		memcpy(alphaFileName+prefixLen+6,aFileName+dotPos,fileNameLen-dotPos);
+	*(alphaFileName + fileNameLen + 6) = '\0';
+	fstream file(alphaFileName, ios::out | ios::binary);
+	if (file.is_open()==0)
+		{
+		delete [] alphaFileName;
+		delete [] alphaBits;
+		delete [] palette;
+		return DestFile;
+		}
+
+	file.write((char *)&fileheader,sizeof(TBitmapFileHeader));
+	file.write((char *)&alphaHeader,sizeof(TBitmapInfoHeader));
+	file.write((char *)palette,paletteSize);
+	file.write((char *)alphaBits,destlength);
+	file.close();
+
+	delete [] alphaFileName;
+	delete [] alphaBits;
+	delete [] palette;
+	return NoError;
+	}
+
+int EpocLoader::DupBitmap(SEpocBitmapHeader*& aPbm)
+	{
+	char* newPbm = new char[iPbmHeader.iBitmapSize];
+	if (newPbm == NULL)
+		return NoMemory;
+	memcpy(newPbm, &iPbmHeader, sizeof(SEpocBitmapHeader));
+	memcpy(newPbm+sizeof(SEpocBitmapHeader), iPbmBits, iPbmHeader.iBitmapSize - sizeof(SEpocBitmapHeader));
+	aPbm = (SEpocBitmapHeader*)newPbm;
+	return NoError;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/bmconv_s60/src/RGB.CPP	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,263 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include "BMCONV.H"
+#include "RGB.H"
+
+extern TRgb* color256Palette;
+extern char* color256InversePalette;
+
+TRgb* color256Palette = NULL;
+char* color256InversePalette = NULL;
+
+TRgb::TRgb()
+	: iRed(255),iGreen(255),iBlue(255),iSpare(0)
+/** Constructs default TRgb with all 3 colour components set to 255. */
+	{}
+
+TRgb::TRgb(long unsigned int val)
+	: iRed((unsigned char)(val&0xff)),iGreen((unsigned char)((val>>8)&0xff)),iBlue((unsigned char)((val>>16)&0xff)),iSpare(0)
+	{}
+
+TRgb::TRgb(int r,int g,int b)
+	: iRed((unsigned char)r),iGreen((unsigned char)g),iBlue((unsigned char)b),iSpare(0)
+/** Constructs a TRgb from its three component colours.
+	
+Each colour has a value between 0 and 255.
+	
+@param aRed Red component of the colour (0 - 255). 
+@param aGreen Green component of the colour (0 - 255). 
+@param aBlue Blue component of the colour (0 - 255). */
+	{}
+
+TRgb &TRgb::operator=(const TRgb &col)
+	{
+	iRed=col.iRed;
+	iGreen=col.iGreen;
+	iBlue=col.iBlue;
+	return(*this);
+	}
+
+int TRgb::operator==(const TRgb &col)
+	{
+	return(iRed==col.iRed && iGreen==col.iGreen && iBlue==col.iBlue);
+	}
+
+int TRgb::Difference(const TRgb& col) const
+	{
+	return abs(iRed-col.iRed) + abs(iGreen-col.iGreen) + abs(iBlue-col.iBlue);
+	}
+
+int TRgb::Gray2() const
+/** Gets a 2 level grayscale value from this TRgb. 
+
+@return Equivalent 2 level grayscale value. The greyscale value is 0 or 1, 
+and is calculated using c=(2*r+5*g+b)/1024. Note that the return value is 
+rounded down to the nearest integer. */
+	{
+	return Gray256() / 128;
+	}
+
+int TRgb::Gray4() const
+/** Gets a 4 level grayscale value from this TRgb.
+
+@return Equivalent 4 level grayscale value. The greyscale value is calculated 
+using c=(2*r+5*g+b)/512. Note that the return value is rounded down to the 
+nearest integer. */
+	{
+	return Gray256() / 64;
+	}
+
+int TRgb::Gray16() const
+/** Gets a 16 level grayscale value from this TRgb.
+
+@return The greyscale value is calculated using c=(2*r+5*g+b)/128. Note that 
+the return value is rounded down to the nearest integer. */
+	{
+	return Gray256() / 16;
+	}
+
+int TRgb::Gray256() const
+/** Gets a 256 level grayscale value from this TRgb.
+
+@return The greyscale value is calculated using c=(2*r+5*g+b)/8. Note that 
+the return value is rounded down to the nearest integer. */
+	{
+	return((2*iRed+5*iGreen+iBlue)/8);
+	}
+
+int TRgb::Color16() const
+/** Gets a 4 bit index into a colour palette from this TRgb.
+
+@return The EGA low colour constant closest to the TRgb. */
+	{
+	int index = (iRed >> 5) & 0x007;
+	index |= (iGreen  >> 2) & 0x038;
+	index |= (iBlue << 1) & 0x1c0;
+	return color16inverse[index];
+	}
+
+int TRgb::Color256() const
+/** Gets an 8 bit index into a colour palette from this TRgb.
+
+@return An 8 bit index. */
+	{
+	int index = (iRed >> 4) & 0x00f;
+	index |= iGreen & 0x0f0;
+	index |= (iBlue << 4) & 0xf00;
+
+	if (color256InversePalette)
+		return color256InversePalette[index];
+	else
+		return color256inverse[index];
+	}
+
+int TRgb::Color4K() const
+/** Gets a 12 bit index into a colour palette from this TRgb.
+
+@return A 12 bit index. */
+	{
+	return(((iRed&0xf0)<<4)|(iGreen&0xf0)|((iBlue&0xf0)>>4));
+	}
+
+int TRgb::Color64K() const
+/** Gets a 24 bit index into a colour palette from this TRgb.
+
+@return A 24 bit index. */
+	{
+	return(((iRed&0xf8)<<8)|((iGreen&0xfc)<<3)|((iBlue&0xf8)>>3));
+	}
+
+long int TRgb::Color16M() const
+/** Gets a 16 bit index into a colour palette from this TRgb.
+
+@return A 16 bit index. */
+	{
+	return((iRed<<16)|(iGreen<<8)|iBlue);
+	}
+
+TRgb TRgb::Gray2(int aGray2)
+/** Gets TRgb from 2 level grayscale. 
+
+The function takes a grayscale argument and return a TRgb whose red, green 
+and blue values are set to an appropriate level. 
+
+@param aGray2 Grayscale value to be converted. 
+@return Equivalent 24 bit colour. Gray2 has only 2 levels (black and white), -
+the function returns r=g=b=0 or r=g=b=255. */
+	{
+	aGray2 *= 255;
+	return TRgb(aGray2,aGray2,aGray2);
+	}
+
+TRgb TRgb::Gray4(int aGray4)
+/** Gets TRgb from 4 level grayscale. 
+
+The function takes a grayscale argument and return a TRgb whose red, green 
+and blue values are set to an appropriate level.
+
+@param aGray4 Grayscale value to be converted. 
+@return Equivalent 24 bit colour. Gray4 has 4 levels- the function returns 
+r=g=b=85*c, where c=0,1,2, or 3. */
+	{
+	aGray4 *= 85;
+	return TRgb(aGray4,aGray4,aGray4);
+	}
+
+TRgb TRgb::Gray16(int aGray16)
+/** Gets TRgb from 16 level grayscale. 
+
+The function takes a grayscale argument and return a TRgb whose red, green 
+and blue values are set to an appropriate level.
+
+@param aGray16 Grayscale value to be converted. 
+@return Equivalent 24 bit colour. Gray16 has 16 levels- the function returns 
+r=g=b=17*c, where c=0, 1, ... 15. */
+	{
+	aGray16 *= 17;
+	return TRgb(aGray16,aGray16,aGray16);
+	}
+
+TRgb TRgb::Gray256(int aGray256)
+/** Gets TRgb from 256 level grayscale. 
+
+The function takes a grayscale argument and return a TRgb whose red, green 
+and blue values are set to an appropriate level.
+
+@param aGray256 Grayscale value to be converted. 
+@return Equivalent 24 bit colour. Gray256 has 256 levels- the function 
+returns r=g=b=c, where c=0, 1, ... 255. */
+	{
+	return TRgb(aGray256,aGray256,aGray256);
+	}
+
+TRgb TRgb::Color16(int aColor16)
+/** Gets TRgb from 4 bit colour index.
+
+The function takes a 4 bit index into a colour palette and returns a TRgb 
+whose red, green and blue values are set to an appropriate level.
+
+@param aColor16 4 bit index into a colour palette 
+@return Equivalent 24 bit colour. */
+	{
+	return TRgb(color16array[aColor16&0xf]);
+	}
+
+TRgb TRgb::Color256(int aColor256)
+/** Gets TRgb from 8 bit colour index.
+
+The function takes an 8 bit index into a colour palette and returns a TRgb 
+whose red, green and blue values are set to an appropriate level.
+
+@param aColor256 8 bit index into a colour palette. 
+@return Equivalent 24 bit colour. */
+	{
+	if (color256Palette)
+		return color256Palette[aColor256&0xff];
+	else
+		return TRgb(color256array[aColor256&0xff]);
+	}
+
+TRgb TRgb::Color4K(int aColor4K)
+	{
+	return TRgb(((aColor4K>>8)&0xf)*17,((aColor4K>>4)&0xf)*17,(aColor4K&0xf)*17);
+	}
+
+TRgb TRgb::Color64K(int aColor64K)
+/** Gets TRgb from 64K colour index.
+
+The function takes a 16 bit index into a colour palette and returns a TRgb 
+whose red, green and blue values are set to an appropriate level.
+
+@param aColor64K 16 bit index into a colour palette 
+@return Equivalent 24 bit colour. */
+	{
+	return TRgb(((aColor64K>>11)&0x1f)*255/31,((aColor64K>>5)&0x3f)*255/63,(aColor64K&0x1f)*255/31);
+	}
+
+TRgb TRgb::Color16M(long int aColor16M)
+/** Gets TRgb from 16M colour index.
+
+The function takes a 24 bit index into a colour palette and returns the TRgb 
+whose red, green and blue values represent it exactly.
+
+@param aColor16M 24 bit index into a colour palette 
+@return The TRgb which represents the index exactly. */
+	{
+	return TRgb(((aColor16M>>16)&0xff),(aColor16M>>8)&0xff,aColor16M&0xff);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/bmconv_s60/src/RGB.H	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,379 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+/**
+@internalComponent
+*/
+const long unsigned int color16array[16]= {
+	0x00000000,	0x00555555,	0x00000080,	0x00008080,
+	0x00008000,	0x000000ff,	0x0000ffff,	0x0000ff00,
+	0x00ff00ff,	0x00ff0000,	0x00ffff00,	0x00800080,
+	0x00800000,	0x00808000,0x00aaaaaa,	0x00ffffff	};
+/**
+@internalComponent
+*/
+const unsigned char color16inverse[512] = {
+	0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x05, 0x05,	0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x05, 0x05,
+	0x04, 0x04, 0x01, 0x03, 0x03, 0x03, 0x05, 0x05,	0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x05,
+	0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x06,	0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x06, 0x06,
+	0x07, 0x07, 0x07, 0x03, 0x03, 0x06, 0x06, 0x06,	0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x06, 0x06,
+	0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x05, 0x05,	0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x05, 0x05,
+	0x04, 0x01, 0x01, 0x01, 0x03, 0x03, 0x05, 0x05,	0x04, 0x04, 0x01, 0x03, 0x03, 0x03, 0x03, 0x05,
+	0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x06,	0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x06, 0x06,
+	0x07, 0x07, 0x07, 0x03, 0x03, 0x06, 0x06, 0x06,	0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x06, 0x06,
+	0x0c, 0x0c, 0x01, 0x0b, 0x0b, 0x0b, 0x05, 0x05,	0x0c, 0x01, 0x01, 0x01, 0x0b, 0x0b, 0x05, 0x05,
+	0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05,	0x0d, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05,
+	0x0d, 0x0d, 0x01, 0x01, 0x03, 0x0e, 0x0e, 0x06,	0x0d, 0x0d, 0x01, 0x01, 0x0e, 0x0e, 0x0e, 0x06,
+	0x07, 0x07, 0x01, 0x01, 0x0e, 0x0e, 0x06, 0x06,	0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x06, 0x06,
+	0x0c, 0x0c, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x05,	0x0c, 0x0c, 0x01, 0x0b, 0x0b, 0x0b, 0x0b, 0x05,
+	0x0d, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05,	0x0d, 0x0d, 0x01, 0x01, 0x01, 0x0e, 0x0e, 0x0e,
+	0x0d, 0x0d, 0x01, 0x01, 0x0e, 0x0e, 0x0e, 0x0e,	0x0d, 0x0d, 0x01, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e,
+	0x0d, 0x0d, 0x01, 0x0e, 0x0e, 0x0e, 0x0e, 0x06,	0x07, 0x07, 0x07, 0x0e, 0x0e, 0x0e, 0x06, 0x06,
+	0x0c, 0x0c, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x08,	0x0c, 0x0c, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x08,
+	0x0d, 0x0d, 0x01, 0x01, 0x0b, 0x0e, 0x0e, 0x08,	0x0d, 0x0d, 0x01, 0x01, 0x0e, 0x0e, 0x0e, 0x0e,
+	0x0d, 0x0d, 0x0d, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e,	0x0d, 0x0d, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e,
+	0x0d, 0x0d, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0f,	0x0a, 0x0a, 0x0a, 0x0e, 0x0e, 0x0e, 0x0f, 0x0f,
+	0x0c, 0x0c, 0x0b, 0x0b, 0x0b, 0x0b, 0x08, 0x08,	0x0c, 0x0c, 0x0b, 0x0b, 0x0b, 0x0b, 0x08, 0x08,
+	0x0d, 0x0d, 0x01, 0x01, 0x0e, 0x0e, 0x0e, 0x08,	0x0d, 0x0d, 0x01, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e,
+	0x0d, 0x0d, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e,	0x0d, 0x0d, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e,
+	0x0a, 0x0a, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0f,	0x0a, 0x0a, 0x0a, 0x0e, 0x0e, 0x0e, 0x0f, 0x0f,
+	0x09, 0x09, 0x09, 0x0b, 0x0b, 0x08, 0x08, 0x08,	0x09, 0x09, 0x09, 0x0b, 0x0b, 0x08, 0x08, 0x08,
+	0x09, 0x09, 0x01, 0x01, 0x0e, 0x0e, 0x08, 0x08,	0x0d, 0x0d, 0x01, 0x0e, 0x0e, 0x0e, 0x0e, 0x08,
+	0x0d, 0x0d, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0f,	0x0a, 0x0a, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0f,
+	0x0a, 0x0a, 0x0a, 0x0e, 0x0e, 0x0e, 0x0f, 0x0f,	0x0a, 0x0a, 0x0a, 0x0a, 0x0f, 0x0f, 0x0f, 0x0f,
+	0x09, 0x09, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08,	0x09, 0x09, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08,
+	0x09, 0x09, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08,	0x09, 0x09, 0x09, 0x0e, 0x0e, 0x0e, 0x08, 0x08,
+	0x0a, 0x0a, 0x0a, 0x0e, 0x0e, 0x0e, 0x0f, 0x0f,	0x0a, 0x0a, 0x0a, 0x0e, 0x0e, 0x0e, 0x0f, 0x0f,
+	0x0a, 0x0a, 0x0a, 0x0a, 0x0f, 0x0f, 0x0f, 0x0f,	0x0a, 0x0a, 0x0a, 0x0a, 0x0f, 0x0f, 0x0f, 0x0f
+	};
+/**
+@internalComponent
+*/
+const long unsigned int color256array[256] = {
+	0x00000000,	0x00000033,	0x00000066,	0x00000099,	0x000000cc,	0x000000ff,
+	0x00003300,	0x00003333,	0x00003366,	0x00003399,	0x000033cc,	0x000033ff,
+	0x00006600,	0x00006633,	0x00006666,	0x00006699,	0x000066cc,	0x000066ff,
+	0x00009900,	0x00009933,	0x00009966,	0x00009999,	0x000099cc,	0x000099ff,
+	0x0000cc00,	0x0000cc33,	0x0000cc66,	0x0000cc99,	0x0000cccc,	0x0000ccff,
+	0x0000ff00,	0x0000ff33,	0x0000ff66,	0x0000ff99,	0x0000ffcc,	0x0000ffff,
+
+	0x00330000,	0x00330033,	0x00330066,	0x00330099,	0x003300cc,	0x003300ff,
+	0x00333300,	0x00333333,	0x00333366,	0x00333399,	0x003333cc,	0x003333ff,
+	0x00336600,	0x00336633,	0x00336666,	0x00336699,	0x003366cc,	0x003366ff,
+	0x00339900,	0x00339933,	0x00339966,	0x00339999,	0x003399cc,	0x003399ff,
+	0x0033cc00,	0x0033cc33,	0x0033cc66,	0x0033cc99,	0x0033cccc,	0x0033ccff,
+	0x0033ff00,	0x0033ff33,	0x0033ff66,	0x0033ff99,	0x0033ffcc,	0x0033ffff,
+
+	0x00660000,	0x00660033,	0x00660066,	0x00660099,	0x006600cc,	0x006600ff,
+	0x00663300,	0x00663333,	0x00663366,	0x00663399,	0x006633cc,	0x006633ff,
+	0x00666600,	0x00666633,	0x00666666,	0x00666699,	0x006666cc,	0x006666ff,
+	0x00669900,	0x00669933,	0x00669966,	0x00669999,	0x006699cc,	0x006699ff,
+	0x0066cc00,	0x0066cc33,	0x0066cc66,	0x0066cc99,	0x0066cccc,	0x0066ccff,
+	0x0066ff00,	0x0066ff33,	0x0066ff66,	0x0066ff99,	0x0066ffcc,	0x0066ffff,
+
+	0x00111111, 0x00222222, 0x00444444, 0x00555555, 0x00777777,
+	0x00000011, 0x00000022, 0x00000044, 0x00000055, 0x00000077,
+	0x00001100,	0x00002200,	0x00004400,	0x00005500,	0x00007700,
+	0x00110000,	0x00220000,	0x00440000,	0x00550000,	0x00770000,
+
+	0x00880000,	0x00aa0000,	0x00bb0000,	0x00dd0000,	0x00ee0000,
+	0x00008800,	0x0000aa00,	0x0000bb00,	0x0000dd00,	0x0000ee00,
+	0x00000088,	0x000000aa,	0x000000bb,	0x000000dd,	0x000000ee,
+	0x00888888, 0x00aaaaaa, 0x00bbbbbb, 0x00dddddd, 0x00eeeeee,
+
+	0x00990000,	0x00990033,	0x00990066,	0x00990099,	0x009900cc,	0x009900ff,
+	0x00993300,	0x00993333,	0x00993366,	0x00993399,	0x009933cc,	0x009933ff,
+	0x00996600,	0x00996633,	0x00996666,	0x00996699,	0x009966cc,	0x009966ff,
+	0x00999900,	0x00999933,	0x00999966,	0x00999999,	0x009999cc,	0x009999ff,
+	0x0099cc00,	0x0099cc33,	0x0099cc66,	0x0099cc99,	0x0099cccc,	0x0099ccff,
+	0x0099ff00,	0x0099ff33,	0x0099ff66,	0x0099ff99,	0x0099ffcc,	0x0099ffff,
+
+	0x00cc0000,	0x00cc0033,	0x00cc0066,	0x00cc0099,	0x00cc00cc,	0x00cc00ff,
+	0x00cc3300,	0x00cc3333,	0x00cc3366,	0x00cc3399,	0x00cc33cc,	0x00cc33ff,
+	0x00cc6600,	0x00cc6633,	0x00cc6666,	0x00cc6699,	0x00cc66cc,	0x00cc66ff,
+	0x00cc9900,	0x00cc9933,	0x00cc9966,	0x00cc9999,	0x00cc99cc,	0x00cc99ff,
+	0x00cccc00,	0x00cccc33,	0x00cccc66,	0x00cccc99,	0x00cccccc,	0x00ccccff,
+	0x00ccff00,	0x00ccff33,	0x00ccff66,	0x00ccff99,	0x00ccffcc,	0x00ccffff,
+
+	0x00ff0000,	0x00ff0033,	0x00ff0066,	0x00ff0099,	0x00ff00cc,	0x00ff00ff,
+	0x00ff3300,	0x00ff3333,	0x00ff3366,	0x00ff3399,	0x00ff33cc,	0x00ff33ff,
+	0x00ff6600,	0x00ff6633,	0x00ff6666,	0x00ff6699,	0x00ff66cc,	0x00ff66ff,
+	0x00ff9900,	0x00ff9933,	0x00ff9966,	0x00ff9999,	0x00ff99cc,	0x00ff99ff,
+	0x00ffcc00,	0x00ffcc33,	0x00ffcc66,	0x00ffcc99,	0x00ffcccc,	0x00ffccff,
+	0x00ffff00,	0x00ffff33,	0x00ffff66,	0x00ffff99,	0x00ffffcc,	0x00ffffff
+	};
+/**
+@internalComponent
+*/
+const unsigned char color256inverse[4096] = {
+	0x00, 0x71, 0x72, 0x01, 0x73, 0x74, 0x02, 0x75,	0x8a, 0x03, 0x8b, 0x8c, 0x04, 0x8d, 0x8e, 0x05,
+	0x76, 0x6c, 0x72, 0x01, 0x73, 0x74, 0x02, 0x75,	0x8a, 0x03, 0x8b, 0x8c, 0x04, 0x8d, 0x8e, 0x05,
+	0x77, 0x77, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08,	0x09, 0x09, 0x09, 0x0a, 0x0a, 0x0a, 0x0b, 0x0b,
+	0x06, 0x06, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08,	0x09, 0x09, 0x09, 0x0a, 0x0a, 0x0a, 0x0b, 0x0b,
+	0x78, 0x78, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08,	0x09, 0x09, 0x09, 0x0a, 0x0a, 0x0a, 0x0b, 0x0b,
+	0x79, 0x79, 0x0d, 0x0d, 0x0d, 0x0e, 0x0e, 0x0e,	0x0f, 0x0f, 0x0f, 0x10, 0x10, 0x10, 0x11, 0x11,
+	0x0c, 0x0c, 0x0d, 0x0d, 0x0d, 0x0e, 0x0e, 0x0e,	0x0f, 0x0f, 0x0f, 0x10, 0x10, 0x10, 0x11, 0x11,
+	0x7a, 0x7a, 0x0d, 0x0d, 0x0d, 0x0e, 0x0e, 0x0e,	0x0f, 0x0f, 0x0f, 0x10, 0x10, 0x10, 0x11, 0x11,
+	0x85, 0x85, 0x13, 0x13, 0x13, 0x14, 0x14, 0x14,	0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x17, 0x17,
+	0x12, 0x12, 0x13, 0x13, 0x13, 0x14, 0x14, 0x14,	0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x17, 0x17,
+	0x86, 0x86, 0x13, 0x13, 0x13, 0x14, 0x14, 0x14,	0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x17, 0x17,
+	0x87, 0x87, 0x19, 0x19, 0x19, 0x1a, 0x1a, 0x1a,	0x1b, 0x1b, 0x1b, 0x1c, 0x1c, 0x1c, 0x1d, 0x1d,
+	0x18, 0x18, 0x19, 0x19, 0x19, 0x1a, 0x1a, 0x1a,	0x1b, 0x1b, 0x1b, 0x1c, 0x1c, 0x1c, 0x1d, 0x1d,
+	0x88, 0x88, 0x19, 0x19, 0x19, 0x1a, 0x1a, 0x1a,	0x1b, 0x1b, 0x1b, 0x1c, 0x1c, 0x1c, 0x1d, 0x1d,
+	0x89, 0x89, 0x1f, 0x1f, 0x1f, 0x20, 0x20, 0x20,	0x21, 0x21, 0x21, 0x22, 0x22, 0x22, 0x23, 0x23,
+	0x1e, 0x1e, 0x1f, 0x1f, 0x1f, 0x20, 0x20, 0x20,	0x21, 0x21, 0x21, 0x22, 0x22, 0x22, 0x23, 0x23,
+	0x7b, 0x6c, 0x72, 0x01, 0x73, 0x74, 0x02, 0x75,	0x8a, 0x03, 0x8b, 0x8c, 0x04, 0x8d, 0x8e, 0x05,
+	0x6c, 0x6c, 0x6c, 0x01, 0x73, 0x74, 0x02, 0x75,	0x8a, 0x03, 0x8b, 0x8c, 0x04, 0x8d, 0x8e, 0x05,
+	0x77, 0x6c, 0x6d, 0x07, 0x07, 0x08, 0x08, 0x08,	0x09, 0x09, 0x09, 0x0a, 0x0a, 0x0a, 0x0b, 0x0b,
+	0x06, 0x06, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08,	0x09, 0x09, 0x09, 0x0a, 0x0a, 0x0a, 0x0b, 0x0b,
+	0x78, 0x78, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08,	0x09, 0x09, 0x09, 0x0a, 0x0a, 0x0a, 0x0b, 0x0b,
+	0x79, 0x79, 0x0d, 0x0d, 0x0d, 0x0e, 0x0e, 0x0e,	0x0f, 0x0f, 0x0f, 0x10, 0x10, 0x10, 0x11, 0x11,
+	0x0c, 0x0c, 0x0d, 0x0d, 0x0d, 0x0e, 0x0e, 0x0e,	0x0f, 0x0f, 0x0f, 0x10, 0x10, 0x10, 0x11, 0x11,
+	0x7a, 0x7a, 0x0d, 0x0d, 0x0d, 0x0e, 0x0e, 0x0e,	0x0f, 0x0f, 0x0f, 0x10, 0x10, 0x10, 0x11, 0x11,
+	0x85, 0x85, 0x13, 0x13, 0x13, 0x14, 0x14, 0x14,	0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x17, 0x17,
+	0x12, 0x12, 0x13, 0x13, 0x13, 0x14, 0x14, 0x14,	0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x17, 0x17,
+	0x86, 0x86, 0x13, 0x13, 0x13, 0x14, 0x14, 0x14,	0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x17, 0x17,
+	0x87, 0x87, 0x19, 0x19, 0x19, 0x1a, 0x1a, 0x1a,	0x1b, 0x1b, 0x1b, 0x1c, 0x1c, 0x1c, 0x1d, 0x1d,
+	0x18, 0x18, 0x19, 0x19, 0x19, 0x1a, 0x1a, 0x1a,	0x1b, 0x1b, 0x1b, 0x1c, 0x1c, 0x1c, 0x1d, 0x1d,
+	0x88, 0x88, 0x19, 0x19, 0x19, 0x1a, 0x1a, 0x1a,	0x1b, 0x1b, 0x1b, 0x1c, 0x1c, 0x1c, 0x1d, 0x1d,
+	0x89, 0x89, 0x1f, 0x1f, 0x1f, 0x20, 0x20, 0x20,	0x21, 0x21, 0x21, 0x22, 0x22, 0x22, 0x23, 0x23,
+	0x1e, 0x1e, 0x1f, 0x1f, 0x1f, 0x20, 0x20, 0x20,	0x21, 0x21, 0x21, 0x22, 0x22, 0x22, 0x23, 0x23,
+	0x7c, 0x7c, 0x25, 0x25, 0x25, 0x26, 0x26, 0x26,	0x27, 0x27, 0x27, 0x28, 0x28, 0x28, 0x29, 0x29,
+	0x7c, 0x6c, 0x6d, 0x25, 0x25, 0x26, 0x26, 0x26,	0x27, 0x27, 0x27, 0x28, 0x28, 0x28, 0x29, 0x29,
+	0x2a, 0x6d, 0x6d, 0x6d, 0x6d, 0x2c, 0x2c, 0x2c,	0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f,
+	0x2a, 0x2a, 0x6d, 0x2b, 0x2b, 0x2c, 0x2c, 0x2c,	0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f,
+	0x2a, 0x2a, 0x6d, 0x2b, 0x6e, 0x2c, 0x2c, 0x2c,	0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f,
+	0x30, 0x30, 0x31, 0x31, 0x31, 0x32, 0x32, 0x32,	0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x35, 0x35,
+	0x30, 0x30, 0x31, 0x31, 0x31, 0x32, 0x32, 0x32,	0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x35, 0x35,
+	0x30, 0x30, 0x31, 0x31, 0x31, 0x32, 0x32, 0x32,	0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x35, 0x35,
+	0x36, 0x36, 0x37, 0x37, 0x37, 0x38, 0x38, 0x38,	0x39, 0x39, 0x39, 0x3a, 0x3a, 0x3a, 0x3b, 0x3b,
+	0x36, 0x36, 0x37, 0x37, 0x37, 0x38, 0x38, 0x38,	0x39, 0x39, 0x39, 0x3a, 0x3a, 0x3a, 0x3b, 0x3b,
+	0x36, 0x36, 0x37, 0x37, 0x37, 0x38, 0x38, 0x38,	0x39, 0x39, 0x39, 0x3a, 0x3a, 0x3a, 0x3b, 0x3b,
+	0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3e, 0x3e, 0x3e,	0x3f, 0x3f, 0x3f, 0x40, 0x40, 0x40, 0x41, 0x41,
+	0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3e, 0x3e, 0x3e,	0x3f, 0x3f, 0x3f, 0x40, 0x40, 0x40, 0x41, 0x41,
+	0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3e, 0x3e, 0x3e,	0x3f, 0x3f, 0x3f, 0x40, 0x40, 0x40, 0x41, 0x41,
+	0x42, 0x42, 0x43, 0x43, 0x43, 0x44, 0x44, 0x44,	0x45, 0x45, 0x45, 0x46, 0x46, 0x46, 0x47, 0x47,
+	0x42, 0x42, 0x43, 0x43, 0x43, 0x44, 0x44, 0x44,	0x45, 0x45, 0x45, 0x46, 0x46, 0x46, 0x47, 0x47,
+	0x24, 0x24, 0x25, 0x25, 0x25, 0x26, 0x26, 0x26,	0x27, 0x27, 0x27, 0x28, 0x28, 0x28, 0x29, 0x29,
+	0x24, 0x24, 0x25, 0x25, 0x25, 0x26, 0x26, 0x26,	0x27, 0x27, 0x27, 0x28, 0x28, 0x28, 0x29, 0x29,
+	0x2a, 0x2a, 0x6d, 0x2b, 0x2b, 0x2c, 0x2c, 0x2c,	0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f,
+	0x2a, 0x2a, 0x2b, 0x2b, 0x2b, 0x2c, 0x2c, 0x2c,	0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f,
+	0x2a, 0x2a, 0x2b, 0x2b, 0x6e, 0x2c, 0x2c, 0x2c,	0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f,
+	0x30, 0x30, 0x31, 0x31, 0x31, 0x32, 0x32, 0x32,	0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x35, 0x35,
+	0x30, 0x30, 0x31, 0x31, 0x31, 0x32, 0x32, 0x32,	0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x35, 0x35,
+	0x30, 0x30, 0x31, 0x31, 0x31, 0x32, 0x32, 0x32,	0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x35, 0x35,
+	0x36, 0x36, 0x37, 0x37, 0x37, 0x38, 0x38, 0x38,	0x39, 0x39, 0x39, 0x3a, 0x3a, 0x3a, 0x3b, 0x3b,
+	0x36, 0x36, 0x37, 0x37, 0x37, 0x38, 0x38, 0x38,	0x39, 0x39, 0x39, 0x3a, 0x3a, 0x3a, 0x3b, 0x3b,
+	0x36, 0x36, 0x37, 0x37, 0x37, 0x38, 0x38, 0x38,	0x39, 0x39, 0x39, 0x3a, 0x3a, 0x3a, 0x3b, 0x3b,
+	0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3e, 0x3e, 0x3e,	0x3f, 0x3f, 0x3f, 0x40, 0x40, 0x40, 0x41, 0x41,
+	0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3e, 0x3e, 0x3e,	0x3f, 0x3f, 0x3f, 0x40, 0x40, 0x40, 0x41, 0x41,
+	0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3e, 0x3e, 0x3e,	0x3f, 0x3f, 0x3f, 0x40, 0x40, 0x40, 0x41, 0x41,
+	0x42, 0x42, 0x43, 0x43, 0x43, 0x44, 0x44, 0x44,	0x45, 0x45, 0x45, 0x46, 0x46, 0x46, 0x47, 0x47,
+	0x42, 0x42, 0x43, 0x43, 0x43, 0x44, 0x44, 0x44,	0x45, 0x45, 0x45, 0x46, 0x46, 0x46, 0x47, 0x47,
+	0x7d, 0x7d, 0x25, 0x25, 0x25, 0x26, 0x26, 0x26,	0x27, 0x27, 0x27, 0x28, 0x28, 0x28, 0x29, 0x29,
+	0x7d, 0x7d, 0x25, 0x25, 0x25, 0x26, 0x26, 0x26,	0x27, 0x27, 0x27, 0x28, 0x28, 0x28, 0x29, 0x29,
+	0x2a, 0x2a, 0x6d, 0x2b, 0x6e, 0x2c, 0x2c, 0x2c,	0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f,
+	0x2a, 0x2a, 0x2b, 0x2b, 0x6e, 0x2c, 0x2c, 0x2c,	0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f,
+	0x2a, 0x2a, 0x6e, 0x6e, 0x6e, 0x6e, 0x2c, 0x2c,	0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f,
+	0x30, 0x30, 0x31, 0x31, 0x6e, 0x6f, 0x32, 0x32,	0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x35, 0x35,
+	0x30, 0x30, 0x31, 0x31, 0x31, 0x32, 0x32, 0x32,	0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x35, 0x35,
+	0x30, 0x30, 0x31, 0x31, 0x31, 0x32, 0x32, 0x32,	0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x35, 0x35,
+	0x36, 0x36, 0x37, 0x37, 0x37, 0x38, 0x38, 0x38,	0x39, 0x39, 0x39, 0x3a, 0x3a, 0x3a, 0x3b, 0x3b,
+	0x36, 0x36, 0x37, 0x37, 0x37, 0x38, 0x38, 0x38,	0x39, 0x39, 0x39, 0x3a, 0x3a, 0x3a, 0x3b, 0x3b,
+	0x36, 0x36, 0x37, 0x37, 0x37, 0x38, 0x38, 0x38,	0x39, 0x39, 0x39, 0x3a, 0x3a, 0x3a, 0x3b, 0x3b,
+	0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3e, 0x3e, 0x3e,	0x3f, 0x3f, 0x3f, 0x40, 0x40, 0x40, 0x41, 0x41,
+	0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3e, 0x3e, 0x3e,	0x3f, 0x3f, 0x3f, 0x40, 0x40, 0x40, 0x41, 0x41,
+	0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3e, 0x3e, 0x3e,	0x3f, 0x3f, 0x3f, 0x40, 0x40, 0x40, 0x41, 0x41,
+	0x42, 0x42, 0x43, 0x43, 0x43, 0x44, 0x44, 0x44,	0x45, 0x45, 0x45, 0x46, 0x46, 0x46, 0x47, 0x47,
+	0x42, 0x42, 0x43, 0x43, 0x43, 0x44, 0x44, 0x44,	0x45, 0x45, 0x45, 0x46, 0x46, 0x46, 0x47, 0x47,
+	0x7e, 0x7e, 0x49, 0x49, 0x49, 0x4a, 0x4a, 0x4a,	0x4b, 0x4b, 0x4b, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d,
+	0x7e, 0x7e, 0x49, 0x49, 0x49, 0x4a, 0x4a, 0x4a,	0x4b, 0x4b, 0x4b, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d,
+	0x4e, 0x4e, 0x4f, 0x4f, 0x4f, 0x50, 0x50, 0x50,	0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x53, 0x53,
+	0x4e, 0x4e, 0x4f, 0x4f, 0x4f, 0x50, 0x50, 0x50,	0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x53, 0x53,
+	0x4e, 0x4e, 0x4f, 0x4f, 0x6e, 0x6f, 0x50, 0x50,	0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x53, 0x53,
+	0x54, 0x54, 0x55, 0x55, 0x6f, 0x6f, 0x6f, 0x6f,	0x57, 0x57, 0x57, 0x58, 0x58, 0x58, 0x59, 0x59,
+	0x54, 0x54, 0x55, 0x55, 0x55, 0x6f, 0x56, 0x56,	0x57, 0x57, 0x57, 0x58, 0x58, 0x58, 0x59, 0x59,
+	0x54, 0x54, 0x55, 0x55, 0x55, 0x6f, 0x56, 0x70,	0x57, 0x57, 0x57, 0x58, 0x58, 0x58, 0x59, 0x59,
+	0x5a, 0x5a, 0x5b, 0x5b, 0x5b, 0x5c, 0x5c, 0x5c,	0x5d, 0x5d, 0x5d, 0x5e, 0x5e, 0x5e, 0x5f, 0x5f,
+	0x5a, 0x5a, 0x5b, 0x5b, 0x5b, 0x5c, 0x5c, 0x5c,	0x5d, 0x5d, 0x5d, 0x5e, 0x5e, 0x5e, 0x5f, 0x5f,
+	0x5a, 0x5a, 0x5b, 0x5b, 0x5b, 0x5c, 0x5c, 0x5c,	0x5d, 0x5d, 0x5d, 0x5e, 0x5e, 0x5e, 0x5f, 0x5f,
+	0x60, 0x60, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62,	0x63, 0x63, 0x63, 0x64, 0x64, 0x64, 0x65, 0x65,
+	0x60, 0x60, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62,	0x63, 0x63, 0x63, 0x64, 0x64, 0x64, 0x65, 0x65,
+	0x60, 0x60, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62,	0x63, 0x63, 0x63, 0x64, 0x64, 0x64, 0x65, 0x65,
+	0x66, 0x66, 0x67, 0x67, 0x67, 0x68, 0x68, 0x68,	0x69, 0x69, 0x69, 0x6a, 0x6a, 0x6a, 0x6b, 0x6b,
+	0x66, 0x66, 0x67, 0x67, 0x67, 0x68, 0x68, 0x68,	0x69, 0x69, 0x69, 0x6a, 0x6a, 0x6a, 0x6b, 0x6b,
+	0x48, 0x48, 0x49, 0x49, 0x49, 0x4a, 0x4a, 0x4a,	0x4b, 0x4b, 0x4b, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d,
+	0x48, 0x48, 0x49, 0x49, 0x49, 0x4a, 0x4a, 0x4a,	0x4b, 0x4b, 0x4b, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d,
+	0x4e, 0x4e, 0x4f, 0x4f, 0x4f, 0x50, 0x50, 0x50,	0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x53, 0x53,
+	0x4e, 0x4e, 0x4f, 0x4f, 0x4f, 0x50, 0x50, 0x50,	0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x53, 0x53,
+	0x4e, 0x4e, 0x4f, 0x4f, 0x4f, 0x50, 0x50, 0x50,	0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x53, 0x53,
+	0x54, 0x54, 0x55, 0x55, 0x55, 0x6f, 0x56, 0x56,	0x57, 0x57, 0x57, 0x58, 0x58, 0x58, 0x59, 0x59,
+	0x54, 0x54, 0x55, 0x55, 0x55, 0x56, 0x56, 0x56,	0x57, 0x57, 0x57, 0x58, 0x58, 0x58, 0x59, 0x59,
+	0x54, 0x54, 0x55, 0x55, 0x55, 0x56, 0x56, 0x70,	0x57, 0x57, 0x57, 0x58, 0x58, 0x58, 0x59, 0x59,
+	0x5a, 0x5a, 0x5b, 0x5b, 0x5b, 0x5c, 0x5c, 0x5c,	0x5d, 0x5d, 0x5d, 0x5e, 0x5e, 0x5e, 0x5f, 0x5f,
+	0x5a, 0x5a, 0x5b, 0x5b, 0x5b, 0x5c, 0x5c, 0x5c,	0x5d, 0x5d, 0x5d, 0x5e, 0x5e, 0x5e, 0x5f, 0x5f,
+	0x5a, 0x5a, 0x5b, 0x5b, 0x5b, 0x5c, 0x5c, 0x5c,	0x5d, 0x5d, 0x5d, 0x5e, 0x5e, 0x5e, 0x5f, 0x5f,
+	0x60, 0x60, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62,	0x63, 0x63, 0x63, 0x64, 0x64, 0x64, 0x65, 0x65,
+	0x60, 0x60, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62,	0x63, 0x63, 0x63, 0x64, 0x64, 0x64, 0x65, 0x65,
+	0x60, 0x60, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62,	0x63, 0x63, 0x63, 0x64, 0x64, 0x64, 0x65, 0x65,
+	0x66, 0x66, 0x67, 0x67, 0x67, 0x68, 0x68, 0x68,	0x69, 0x69, 0x69, 0x6a, 0x6a, 0x6a, 0x6b, 0x6b,
+	0x66, 0x66, 0x67, 0x67, 0x67, 0x68, 0x68, 0x68,	0x69, 0x69, 0x69, 0x6a, 0x6a, 0x6a, 0x6b, 0x6b,
+	0x7f, 0x7f, 0x49, 0x49, 0x49, 0x4a, 0x4a, 0x4a,	0x4b, 0x4b, 0x4b, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d,
+	0x7f, 0x7f, 0x49, 0x49, 0x49, 0x4a, 0x4a, 0x4a,	0x4b, 0x4b, 0x4b, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d,
+	0x4e, 0x4e, 0x4f, 0x4f, 0x4f, 0x50, 0x50, 0x50,	0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x53, 0x53,
+	0x4e, 0x4e, 0x4f, 0x4f, 0x4f, 0x50, 0x50, 0x50,	0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x53, 0x53,
+	0x4e, 0x4e, 0x4f, 0x4f, 0x4f, 0x50, 0x50, 0x50,	0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x53, 0x53,
+	0x54, 0x54, 0x55, 0x55, 0x55, 0x6f, 0x56, 0x70,	0x57, 0x57, 0x57, 0x58, 0x58, 0x58, 0x59, 0x59,
+	0x54, 0x54, 0x55, 0x55, 0x55, 0x56, 0x56, 0x70,	0x57, 0x57, 0x57, 0x58, 0x58, 0x58, 0x59, 0x59,
+	0x54, 0x54, 0x55, 0x55, 0x55, 0x70, 0x70, 0x70,	0x70, 0x57, 0x57, 0x58, 0x58, 0x58, 0x59, 0x59,
+	0x5a, 0x5a, 0x5b, 0x5b, 0x5b, 0x5c, 0x5c, 0x70,	0x8f, 0x5d, 0x5d, 0x5e, 0x5e, 0x5e, 0x5f, 0x5f,
+	0x5a, 0x5a, 0x5b, 0x5b, 0x5b, 0x5c, 0x5c, 0x5c,	0x5d, 0x5d, 0x5d, 0x5e, 0x5e, 0x5e, 0x5f, 0x5f,
+	0x5a, 0x5a, 0x5b, 0x5b, 0x5b, 0x5c, 0x5c, 0x5c,	0x5d, 0x5d, 0x5d, 0x5e, 0x5e, 0x5e, 0x5f, 0x5f,
+	0x60, 0x60, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62,	0x63, 0x63, 0x63, 0x64, 0x64, 0x64, 0x65, 0x65,
+	0x60, 0x60, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62,	0x63, 0x63, 0x63, 0x64, 0x64, 0x64, 0x65, 0x65,
+	0x60, 0x60, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62,	0x63, 0x63, 0x63, 0x64, 0x64, 0x64, 0x65, 0x65,
+	0x66, 0x66, 0x67, 0x67, 0x67, 0x68, 0x68, 0x68,	0x69, 0x69, 0x69, 0x6a, 0x6a, 0x6a, 0x6b, 0x6b,
+	0x66, 0x66, 0x67, 0x67, 0x67, 0x68, 0x68, 0x68,	0x69, 0x69, 0x69, 0x6a, 0x6a, 0x6a, 0x6b, 0x6b,
+	0x80, 0x80, 0x80, 0x95, 0x95, 0x96, 0x96, 0x96,	0x97, 0x97, 0x97, 0x98, 0x98, 0x98, 0x99, 0x99,
+	0x80, 0x80, 0x80, 0x95, 0x95, 0x96, 0x96, 0x96,	0x97, 0x97, 0x97, 0x98, 0x98, 0x98, 0x99, 0x99,
+	0x80, 0x80, 0x9b, 0x9b, 0x9b, 0x9c, 0x9c, 0x9c,	0x9d, 0x9d, 0x9d, 0x9e, 0x9e, 0x9e, 0x9f, 0x9f,
+	0x9a, 0x9a, 0x9b, 0x9b, 0x9b, 0x9c, 0x9c, 0x9c,	0x9d, 0x9d, 0x9d, 0x9e, 0x9e, 0x9e, 0x9f, 0x9f,
+	0x9a, 0x9a, 0x9b, 0x9b, 0x9b, 0x9c, 0x9c, 0x9c,	0x9d, 0x9d, 0x9d, 0x9e, 0x9e, 0x9e, 0x9f, 0x9f,
+	0xa0, 0xa0, 0xa1, 0xa1, 0xa1, 0x6f, 0xa2, 0x70,	0x8f, 0xa3, 0xa3, 0xa4, 0xa4, 0xa4, 0xa5, 0xa5,
+	0xa0, 0xa0, 0xa1, 0xa1, 0xa1, 0xa2, 0xa2, 0x70,	0x8f, 0xa3, 0xa3, 0xa4, 0xa4, 0xa4, 0xa5, 0xa5,
+	0xa0, 0xa0, 0xa1, 0xa1, 0xa1, 0x70, 0x70, 0x70,	0x8f, 0x8f, 0x8f, 0xa4, 0xa4, 0xa4, 0xa5, 0xa5,
+	0xa6, 0xa6, 0xa7, 0xa7, 0xa7, 0x8f, 0x8f, 0x8f,	0x8f, 0x8f, 0x8f, 0x8f, 0xaa, 0xaa, 0xab, 0xab,
+	0xa6, 0xa6, 0xa7, 0xa7, 0xa7, 0xa8, 0xa8, 0x8f,	0x8f, 0xa9, 0xa9, 0xaa, 0xaa, 0xaa, 0xab, 0xab,
+	0xa6, 0xa6, 0xa7, 0xa7, 0xa7, 0xa8, 0xa8, 0x8f,	0x8f, 0xa9, 0x90, 0x90, 0xaa, 0xaa, 0xab, 0xab,
+	0xac, 0xac, 0xad, 0xad, 0xad, 0xae, 0xae, 0xae,	0x8f, 0xaf, 0x90, 0x91, 0xb0, 0xb0, 0xb1, 0xb1,
+	0xac, 0xac, 0xad, 0xad, 0xad, 0xae, 0xae, 0xae,	0xaf, 0xaf, 0xaf, 0xb0, 0xb0, 0xb0, 0xb1, 0xb1,
+	0xac, 0xac, 0xad, 0xad, 0xad, 0xae, 0xae, 0xae,	0xaf, 0xaf, 0xaf, 0xb0, 0xb0, 0xb0, 0xb1, 0xb1,
+	0xb2, 0xb2, 0xb3, 0xb3, 0xb3, 0xb4, 0xb4, 0xb4,	0xb5, 0xb5, 0xb5, 0xb6, 0xb6, 0xb6, 0xb7, 0xb7,
+	0xb2, 0xb2, 0xb3, 0xb3, 0xb3, 0xb4, 0xb4, 0xb4,	0xb5, 0xb5, 0xb5, 0xb6, 0xb6, 0xb6, 0xb7, 0xb7,
+	0x94, 0x94, 0x95, 0x95, 0x95, 0x96, 0x96, 0x96,	0x97, 0x97, 0x97, 0x98, 0x98, 0x98, 0x99, 0x99,
+	0x94, 0x94, 0x95, 0x95, 0x95, 0x96, 0x96, 0x96,	0x97, 0x97, 0x97, 0x98, 0x98, 0x98, 0x99, 0x99,
+	0x9a, 0x9a, 0x9b, 0x9b, 0x9b, 0x9c, 0x9c, 0x9c,	0x9d, 0x9d, 0x9d, 0x9e, 0x9e, 0x9e, 0x9f, 0x9f,
+	0x9a, 0x9a, 0x9b, 0x9b, 0x9b, 0x9c, 0x9c, 0x9c,	0x9d, 0x9d, 0x9d, 0x9e, 0x9e, 0x9e, 0x9f, 0x9f,
+	0x9a, 0x9a, 0x9b, 0x9b, 0x9b, 0x9c, 0x9c, 0x9c,	0x9d, 0x9d, 0x9d, 0x9e, 0x9e, 0x9e, 0x9f, 0x9f,
+	0xa0, 0xa0, 0xa1, 0xa1, 0xa1, 0xa2, 0xa2, 0xa2,	0xa3, 0xa3, 0xa3, 0xa4, 0xa4, 0xa4, 0xa5, 0xa5,
+	0xa0, 0xa0, 0xa1, 0xa1, 0xa1, 0xa2, 0xa2, 0xa2,	0xa3, 0xa3, 0xa3, 0xa4, 0xa4, 0xa4, 0xa5, 0xa5,
+	0xa0, 0xa0, 0xa1, 0xa1, 0xa1, 0xa2, 0xa2, 0x70,	0x8f, 0xa3, 0xa3, 0xa4, 0xa4, 0xa4, 0xa5, 0xa5,
+	0xa6, 0xa6, 0xa7, 0xa7, 0xa7, 0xa8, 0xa8, 0x8f,	0x8f, 0xa9, 0xa9, 0xaa, 0xaa, 0xaa, 0xab, 0xab,
+	0xa6, 0xa6, 0xa7, 0xa7, 0xa7, 0xa8, 0xa8, 0xa8,	0xa9, 0xa9, 0xa9, 0xaa, 0xaa, 0xaa, 0xab, 0xab,
+	0xa6, 0xa6, 0xa7, 0xa7, 0xa7, 0xa8, 0xa8, 0xa8,	0xa9, 0xa9, 0x90, 0x90, 0xaa, 0xaa, 0xab, 0xab,
+	0xac, 0xac, 0xad, 0xad, 0xad, 0xae, 0xae, 0xae,	0xaf, 0xaf, 0x90, 0x91, 0xb0, 0xb0, 0xb1, 0xb1,
+	0xac, 0xac, 0xad, 0xad, 0xad, 0xae, 0xae, 0xae,	0xaf, 0xaf, 0xaf, 0xb0, 0xb0, 0xb0, 0xb1, 0xb1,
+	0xac, 0xac, 0xad, 0xad, 0xad, 0xae, 0xae, 0xae,	0xaf, 0xaf, 0xaf, 0xb0, 0xb0, 0xb0, 0xb1, 0xb1,
+	0xb2, 0xb2, 0xb3, 0xb3, 0xb3, 0xb4, 0xb4, 0xb4,	0xb5, 0xb5, 0xb5, 0xb6, 0xb6, 0xb6, 0xb7, 0xb7,
+	0xb2, 0xb2, 0xb3, 0xb3, 0xb3, 0xb4, 0xb4, 0xb4,	0xb5, 0xb5, 0xb5, 0xb6, 0xb6, 0xb6, 0xb7, 0xb7,
+	0x81, 0x81, 0x81, 0x95, 0x95, 0x96, 0x96, 0x96,	0x97, 0x97, 0x97, 0x98, 0x98, 0x98, 0x99, 0x99,
+	0x81, 0x81, 0x81, 0x95, 0x95, 0x96, 0x96, 0x96,	0x97, 0x97, 0x97, 0x98, 0x98, 0x98, 0x99, 0x99,
+	0x81, 0x81, 0x9b, 0x9b, 0x9b, 0x9c, 0x9c, 0x9c,	0x9d, 0x9d, 0x9d, 0x9e, 0x9e, 0x9e, 0x9f, 0x9f,
+	0x9a, 0x9a, 0x9b, 0x9b, 0x9b, 0x9c, 0x9c, 0x9c,	0x9d, 0x9d, 0x9d, 0x9e, 0x9e, 0x9e, 0x9f, 0x9f,
+	0x9a, 0x9a, 0x9b, 0x9b, 0x9b, 0x9c, 0x9c, 0x9c,	0x9d, 0x9d, 0x9d, 0x9e, 0x9e, 0x9e, 0x9f, 0x9f,
+	0xa0, 0xa0, 0xa1, 0xa1, 0xa1, 0xa2, 0xa2, 0xa2,	0xa3, 0xa3, 0xa3, 0xa4, 0xa4, 0xa4, 0xa5, 0xa5,
+	0xa0, 0xa0, 0xa1, 0xa1, 0xa1, 0xa2, 0xa2, 0xa2,	0xa3, 0xa3, 0xa3, 0xa4, 0xa4, 0xa4, 0xa5, 0xa5,
+	0xa0, 0xa0, 0xa1, 0xa1, 0xa1, 0xa2, 0xa2, 0x70,	0x8f, 0xa3, 0x90, 0xa4, 0xa4, 0xa4, 0xa5, 0xa5,
+	0xa6, 0xa6, 0xa7, 0xa7, 0xa7, 0xa8, 0xa8, 0x8f,	0x8f, 0xa9, 0x90, 0x90, 0xaa, 0xaa, 0xab, 0xab,
+	0xa6, 0xa6, 0xa7, 0xa7, 0xa7, 0xa8, 0xa8, 0xa8,	0xa9, 0xa9, 0x90, 0x90, 0xaa, 0xaa, 0xab, 0xab,
+	0xa6, 0xa6, 0xa7, 0xa7, 0xa7, 0xa8, 0xa8, 0x90,	0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0xab, 0xab,
+	0xac, 0xac, 0xad, 0xad, 0xad, 0xae, 0xae, 0xae,	0x90, 0x90, 0x90, 0x91, 0x91, 0x91, 0xb1, 0xb1,
+	0xac, 0xac, 0xad, 0xad, 0xad, 0xae, 0xae, 0xae,	0xaf, 0xaf, 0x90, 0x91, 0xb0, 0xb0, 0xb1, 0xb1,
+	0xac, 0xac, 0xad, 0xad, 0xad, 0xae, 0xae, 0xae,	0xaf, 0xaf, 0x90, 0x91, 0xb0, 0x92, 0xb1, 0xb1,
+	0xb2, 0xb2, 0xb3, 0xb3, 0xb3, 0xb4, 0xb4, 0xb4,	0xb5, 0xb5, 0xb5, 0xb6, 0xb6, 0xb6, 0xb7, 0xb7,
+	0xb2, 0xb2, 0xb3, 0xb3, 0xb3, 0xb4, 0xb4, 0xb4,	0xb5, 0xb5, 0xb5, 0xb6, 0xb6, 0xb6, 0xb7, 0xb7,
+	0x82, 0x82, 0x82, 0xb9, 0xb9, 0xba, 0xba, 0xba,	0xbb, 0xbb, 0xbb, 0xbc, 0xbc, 0xbc, 0xbd, 0xbd,
+	0x82, 0x82, 0x82, 0xb9, 0xb9, 0xba, 0xba, 0xba,	0xbb, 0xbb, 0xbb, 0xbc, 0xbc, 0xbc, 0xbd, 0xbd,
+	0x82, 0x82, 0xbf, 0xbf, 0xbf, 0xc0, 0xc0, 0xc0,	0xc1, 0xc1, 0xc1, 0xc2, 0xc2, 0xc2, 0xc3, 0xc3,
+	0xbe, 0xbe, 0xbf, 0xbf, 0xbf, 0xc0, 0xc0, 0xc0,	0xc1, 0xc1, 0xc1, 0xc2, 0xc2, 0xc2, 0xc3, 0xc3,
+	0xbe, 0xbe, 0xbf, 0xbf, 0xbf, 0xc0, 0xc0, 0xc0,	0xc1, 0xc1, 0xc1, 0xc2, 0xc2, 0xc2, 0xc3, 0xc3,
+	0xc4, 0xc4, 0xc5, 0xc5, 0xc5, 0xc6, 0xc6, 0xc6,	0xc7, 0xc7, 0xc7, 0xc8, 0xc8, 0xc8, 0xc9, 0xc9,
+	0xc4, 0xc4, 0xc5, 0xc5, 0xc5, 0xc6, 0xc6, 0xc6,	0xc7, 0xc7, 0xc7, 0xc8, 0xc8, 0xc8, 0xc9, 0xc9,
+	0xc4, 0xc4, 0xc5, 0xc5, 0xc5, 0xc6, 0xc6, 0xc6,	0xc7, 0xc7, 0xc7, 0xc8, 0xc8, 0xc8, 0xc9, 0xc9,
+	0xca, 0xca, 0xcb, 0xcb, 0xcb, 0xcc, 0xcc, 0xcc,	0x8f, 0xcd, 0x90, 0x91, 0xce, 0xce, 0xcf, 0xcf,
+	0xca, 0xca, 0xcb, 0xcb, 0xcb, 0xcc, 0xcc, 0xcc,	0xcd, 0xcd, 0x90, 0x91, 0xce, 0xce, 0xcf, 0xcf,
+	0xca, 0xca, 0xcb, 0xcb, 0xcb, 0xcc, 0xcc, 0xcc,	0x90, 0x90, 0x90, 0x91, 0x91, 0x91, 0xcf, 0xcf,
+	0xd0, 0xd0, 0xd1, 0xd1, 0xd1, 0xd2, 0xd2, 0xd2,	0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0xd5,
+	0xd0, 0xd0, 0xd1, 0xd1, 0xd1, 0xd2, 0xd2, 0xd2,	0xd3, 0xd3, 0x91, 0x91, 0xd4, 0xd4, 0xd5, 0xd5,
+	0xd0, 0xd0, 0xd1, 0xd1, 0xd1, 0xd2, 0xd2, 0xd2,	0xd3, 0xd3, 0x91, 0x91, 0xd4, 0x92, 0x92, 0xd5,
+	0xd6, 0xd6, 0xd7, 0xd7, 0xd7, 0xd8, 0xd8, 0xd8,	0xd9, 0xd9, 0xd9, 0x91, 0xda, 0x92, 0x93, 0xdb,
+	0xd6, 0xd6, 0xd7, 0xd7, 0xd7, 0xd8, 0xd8, 0xd8,	0xd9, 0xd9, 0xd9, 0xda, 0xda, 0xda, 0xdb, 0xdb,
+	0xb8, 0xb8, 0xb9, 0xb9, 0xb9, 0xba, 0xba, 0xba,	0xbb, 0xbb, 0xbb, 0xbc, 0xbc, 0xbc, 0xbd, 0xbd,
+	0xb8, 0xb8, 0xb9, 0xb9, 0xb9, 0xba, 0xba, 0xba,	0xbb, 0xbb, 0xbb, 0xbc, 0xbc, 0xbc, 0xbd, 0xbd,
+	0xbe, 0xbe, 0xbf, 0xbf, 0xbf, 0xc0, 0xc0, 0xc0,	0xc1, 0xc1, 0xc1, 0xc2, 0xc2, 0xc2, 0xc3, 0xc3,
+	0xbe, 0xbe, 0xbf, 0xbf, 0xbf, 0xc0, 0xc0, 0xc0,	0xc1, 0xc1, 0xc1, 0xc2, 0xc2, 0xc2, 0xc3, 0xc3,
+	0xbe, 0xbe, 0xbf, 0xbf, 0xbf, 0xc0, 0xc0, 0xc0,	0xc1, 0xc1, 0xc1, 0xc2, 0xc2, 0xc2, 0xc3, 0xc3,
+	0xc4, 0xc4, 0xc5, 0xc5, 0xc5, 0xc6, 0xc6, 0xc6,	0xc7, 0xc7, 0xc7, 0xc8, 0xc8, 0xc8, 0xc9, 0xc9,
+	0xc4, 0xc4, 0xc5, 0xc5, 0xc5, 0xc6, 0xc6, 0xc6,	0xc7, 0xc7, 0xc7, 0xc8, 0xc8, 0xc8, 0xc9, 0xc9,
+	0xc4, 0xc4, 0xc5, 0xc5, 0xc5, 0xc6, 0xc6, 0xc6,	0xc7, 0xc7, 0xc7, 0xc8, 0xc8, 0xc8, 0xc9, 0xc9,
+	0xca, 0xca, 0xcb, 0xcb, 0xcb, 0xcc, 0xcc, 0xcc,	0xcd, 0xcd, 0xcd, 0xce, 0xce, 0xce, 0xcf, 0xcf,
+	0xca, 0xca, 0xcb, 0xcb, 0xcb, 0xcc, 0xcc, 0xcc,	0xcd, 0xcd, 0xcd, 0xce, 0xce, 0xce, 0xcf, 0xcf,
+	0xca, 0xca, 0xcb, 0xcb, 0xcb, 0xcc, 0xcc, 0xcc,	0xcd, 0xcd, 0x90, 0x91, 0xce, 0xce, 0xcf, 0xcf,
+	0xd0, 0xd0, 0xd1, 0xd1, 0xd1, 0xd2, 0xd2, 0xd2,	0xd3, 0xd3, 0x91, 0x91, 0xd4, 0xd4, 0xd5, 0xd5,
+	0xd0, 0xd0, 0xd1, 0xd1, 0xd1, 0xd2, 0xd2, 0xd2,	0xd3, 0xd3, 0xd3, 0xd4, 0xd4, 0xd4, 0xd5, 0xd5,
+	0xd0, 0xd0, 0xd1, 0xd1, 0xd1, 0xd2, 0xd2, 0xd2,	0xd3, 0xd3, 0xd3, 0xd4, 0xd4, 0x92, 0x92, 0xd5,
+	0xd6, 0xd6, 0xd7, 0xd7, 0xd7, 0xd8, 0xd8, 0xd8,	0xd9, 0xd9, 0xd9, 0xda, 0xda, 0x92, 0x93, 0xdb,
+	0xd6, 0xd6, 0xd7, 0xd7, 0xd7, 0xd8, 0xd8, 0xd8,	0xd9, 0xd9, 0xd9, 0xda, 0xda, 0xda, 0xdb, 0xdb,
+	0x83, 0x83, 0x83, 0xb9, 0xb9, 0xba, 0xba, 0xba,	0xbb, 0xbb, 0xbb, 0xbc, 0xbc, 0xbc, 0xbd, 0xbd,
+	0x83, 0x83, 0x83, 0xb9, 0xb9, 0xba, 0xba, 0xba,	0xbb, 0xbb, 0xbb, 0xbc, 0xbc, 0xbc, 0xbd, 0xbd,
+	0x83, 0x83, 0xbf, 0xbf, 0xbf, 0xc0, 0xc0, 0xc0,	0xc1, 0xc1, 0xc1, 0xc2, 0xc2, 0xc2, 0xc3, 0xc3,
+	0xbe, 0xbe, 0xbf, 0xbf, 0xbf, 0xc0, 0xc0, 0xc0,	0xc1, 0xc1, 0xc1, 0xc2, 0xc2, 0xc2, 0xc3, 0xc3,
+	0xbe, 0xbe, 0xbf, 0xbf, 0xbf, 0xc0, 0xc0, 0xc0,	0xc1, 0xc1, 0xc1, 0xc2, 0xc2, 0xc2, 0xc3, 0xc3,
+	0xc4, 0xc4, 0xc5, 0xc5, 0xc5, 0xc6, 0xc6, 0xc6,	0xc7, 0xc7, 0xc7, 0xc8, 0xc8, 0xc8, 0xc9, 0xc9,
+	0xc4, 0xc4, 0xc5, 0xc5, 0xc5, 0xc6, 0xc6, 0xc6,	0xc7, 0xc7, 0xc7, 0xc8, 0xc8, 0xc8, 0xc9, 0xc9,
+	0xc4, 0xc4, 0xc5, 0xc5, 0xc5, 0xc6, 0xc6, 0xc6,	0xc7, 0xc7, 0xc7, 0xc8, 0xc8, 0xc8, 0xc9, 0xc9,
+	0xca, 0xca, 0xcb, 0xcb, 0xcb, 0xcc, 0xcc, 0xcc,	0xcd, 0xcd, 0xcd, 0xce, 0xce, 0xce, 0xcf, 0xcf,
+	0xca, 0xca, 0xcb, 0xcb, 0xcb, 0xcc, 0xcc, 0xcc,	0xcd, 0xcd, 0xcd, 0xce, 0xce, 0xce, 0xcf, 0xcf,
+	0xca, 0xca, 0xcb, 0xcb, 0xcb, 0xcc, 0xcc, 0xcc,	0xcd, 0xcd, 0x90, 0x91, 0xce, 0x92, 0xcf, 0xcf,
+	0xd0, 0xd0, 0xd1, 0xd1, 0xd1, 0xd2, 0xd2, 0xd2,	0xd3, 0xd3, 0x91, 0x91, 0xd4, 0x92, 0x92, 0xd5,
+	0xd0, 0xd0, 0xd1, 0xd1, 0xd1, 0xd2, 0xd2, 0xd2,	0xd3, 0xd3, 0xd3, 0xd4, 0xd4, 0x92, 0x92, 0xd5,
+	0xd0, 0xd0, 0xd1, 0xd1, 0xd1, 0xd2, 0xd2, 0xd2,	0xd3, 0xd3, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92,
+	0xd6, 0xd6, 0xd7, 0xd7, 0xd7, 0xd8, 0xd8, 0xd8,	0xd9, 0xd9, 0xd9, 0x92, 0x92, 0x92, 0x93, 0x93,
+	0xd6, 0xd6, 0xd7, 0xd7, 0xd7, 0xd8, 0xd8, 0xd8,	0xd9, 0xd9, 0xd9, 0xda, 0xda, 0x92, 0x93, 0xdb,
+	0x84, 0x84, 0x84, 0xdd, 0xdd, 0xde, 0xde, 0xde,	0xdf, 0xdf, 0xdf, 0xe0, 0xe0, 0xe0, 0xe1, 0xe1,
+	0x84, 0x84, 0x84, 0xdd, 0xdd, 0xde, 0xde, 0xde,	0xdf, 0xdf, 0xdf, 0xe0, 0xe0, 0xe0, 0xe1, 0xe1,
+	0x84, 0x84, 0xe3, 0xe3, 0xe3, 0xe4, 0xe4, 0xe4,	0xe5, 0xe5, 0xe5, 0xe6, 0xe6, 0xe6, 0xe7, 0xe7,
+	0xe2, 0xe2, 0xe3, 0xe3, 0xe3, 0xe4, 0xe4, 0xe4,	0xe5, 0xe5, 0xe5, 0xe6, 0xe6, 0xe6, 0xe7, 0xe7,
+	0xe2, 0xe2, 0xe3, 0xe3, 0xe3, 0xe4, 0xe4, 0xe4,	0xe5, 0xe5, 0xe5, 0xe6, 0xe6, 0xe6, 0xe7, 0xe7,
+	0xe8, 0xe8, 0xe9, 0xe9, 0xe9, 0xea, 0xea, 0xea,	0xeb, 0xeb, 0xeb, 0xec, 0xec, 0xec, 0xed, 0xed,
+	0xe8, 0xe8, 0xe9, 0xe9, 0xe9, 0xea, 0xea, 0xea,	0xeb, 0xeb, 0xeb, 0xec, 0xec, 0xec, 0xed, 0xed,
+	0xe8, 0xe8, 0xe9, 0xe9, 0xe9, 0xea, 0xea, 0xea,	0xeb, 0xeb, 0xeb, 0xec, 0xec, 0xec, 0xed, 0xed,
+	0xee, 0xee, 0xef, 0xef, 0xef, 0xf0, 0xf0, 0xf0,	0xf1, 0xf1, 0xf1, 0xf2, 0xf2, 0xf2, 0xf3, 0xf3,
+	0xee, 0xee, 0xef, 0xef, 0xef, 0xf0, 0xf0, 0xf0,	0xf1, 0xf1, 0xf1, 0xf2, 0xf2, 0xf2, 0xf3, 0xf3,
+	0xee, 0xee, 0xef, 0xef, 0xef, 0xf0, 0xf0, 0xf0,	0xf1, 0xf1, 0xf1, 0xf2, 0xf2, 0xf2, 0xf3, 0xf3,
+	0xf4, 0xf4, 0xf5, 0xf5, 0xf5, 0xf6, 0xf6, 0xf6,	0xf7, 0xf7, 0xf7, 0x91, 0xf8, 0x92, 0x93, 0xf9,
+	0xf4, 0xf4, 0xf5, 0xf5, 0xf5, 0xf6, 0xf6, 0xf6,	0xf7, 0xf7, 0xf7, 0xf8, 0xf8, 0x92, 0x93, 0xf9,
+	0xf4, 0xf4, 0xf5, 0xf5, 0xf5, 0xf6, 0xf6, 0xf6,	0xf7, 0xf7, 0xf7, 0x92, 0x92, 0x92, 0x93, 0x93,
+	0xfa, 0xfa, 0xfb, 0xfb, 0xfb, 0xfc, 0xfc, 0xfc,	0xfd, 0xfd, 0xfd, 0x93, 0x93, 0x93, 0x93, 0x93,
+	0xfa, 0xfa, 0xfb, 0xfb, 0xfb, 0xfc, 0xfc, 0xfc,	0xfd, 0xfd, 0xfd, 0xfe, 0xfe, 0x93, 0x93, 0xff,
+	0xdc, 0xdc, 0xdd, 0xdd, 0xdd, 0xde, 0xde, 0xde,	0xdf, 0xdf, 0xdf, 0xe0, 0xe0, 0xe0, 0xe1, 0xe1,
+	0xdc, 0xdc, 0xdd, 0xdd, 0xdd, 0xde, 0xde, 0xde,	0xdf, 0xdf, 0xdf, 0xe0, 0xe0, 0xe0, 0xe1, 0xe1,
+	0xe2, 0xe2, 0xe3, 0xe3, 0xe3, 0xe4, 0xe4, 0xe4,	0xe5, 0xe5, 0xe5, 0xe6, 0xe6, 0xe6, 0xe7, 0xe7,
+	0xe2, 0xe2, 0xe3, 0xe3, 0xe3, 0xe4, 0xe4, 0xe4,	0xe5, 0xe5, 0xe5, 0xe6, 0xe6, 0xe6, 0xe7, 0xe7,
+	0xe2, 0xe2, 0xe3, 0xe3, 0xe3, 0xe4, 0xe4, 0xe4,	0xe5, 0xe5, 0xe5, 0xe6, 0xe6, 0xe6, 0xe7, 0xe7,
+	0xe8, 0xe8, 0xe9, 0xe9, 0xe9, 0xea, 0xea, 0xea,	0xeb, 0xeb, 0xeb, 0xec, 0xec, 0xec, 0xed, 0xed,
+	0xe8, 0xe8, 0xe9, 0xe9, 0xe9, 0xea, 0xea, 0xea,	0xeb, 0xeb, 0xeb, 0xec, 0xec, 0xec, 0xed, 0xed,
+	0xe8, 0xe8, 0xe9, 0xe9, 0xe9, 0xea, 0xea, 0xea,	0xeb, 0xeb, 0xeb, 0xec, 0xec, 0xec, 0xed, 0xed,
+	0xee, 0xee, 0xef, 0xef, 0xef, 0xf0, 0xf0, 0xf0,	0xf1, 0xf1, 0xf1, 0xf2, 0xf2, 0xf2, 0xf3, 0xf3,
+	0xee, 0xee, 0xef, 0xef, 0xef, 0xf0, 0xf0, 0xf0,	0xf1, 0xf1, 0xf1, 0xf2, 0xf2, 0xf2, 0xf3, 0xf3,
+	0xee, 0xee, 0xef, 0xef, 0xef, 0xf0, 0xf0, 0xf0,	0xf1, 0xf1, 0xf1, 0xf2, 0xf2, 0xf2, 0xf3, 0xf3,
+	0xf4, 0xf4, 0xf5, 0xf5, 0xf5, 0xf6, 0xf6, 0xf6,	0xf7, 0xf7, 0xf7, 0xf8, 0xf8, 0xf8, 0xf9, 0xf9,
+	0xf4, 0xf4, 0xf5, 0xf5, 0xf5, 0xf6, 0xf6, 0xf6,	0xf7, 0xf7, 0xf7, 0xf8, 0xf8, 0xf8, 0xf9, 0xf9,
+	0xf4, 0xf4, 0xf5, 0xf5, 0xf5, 0xf6, 0xf6, 0xf6,	0xf7, 0xf7, 0xf7, 0xf8, 0xf8, 0x92, 0x93, 0xf9,
+	0xfa, 0xfa, 0xfb, 0xfb, 0xfb, 0xfc, 0xfc, 0xfc,	0xfd, 0xfd, 0xfd, 0xfe, 0xfe, 0x93, 0x93, 0xff,
+	0xfa, 0xfa, 0xfb, 0xfb, 0xfb, 0xfc, 0xfc, 0xfc,	0xfd, 0xfd, 0xfd, 0xfe, 0xfe, 0xfe, 0xff, 0xff
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/bmconv_s60/src/TOOLSVER.H	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef __TOOLSVER_H__
+#define __TOOLSVER_H__
+/**
+@internalComponent
+*/
+const int version=116;
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/bmconv_s60/src/UTILS.CPP	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include "BMCONV.H"
+
+
+int BitmapUtils::ByteWidth(int aPixelWidth,int aBitsPerPixel)
+	{
+	int wordWidth = 0;
+
+	switch (aBitsPerPixel)
+		{
+	case 1:
+		wordWidth = (aPixelWidth + 31) / 32;
+		break;
+	case 2:
+		wordWidth = (aPixelWidth + 15) / 16;
+		break;
+	case 4:
+		wordWidth = (aPixelWidth + 7) / 8;
+		break;
+	case 8:
+		wordWidth = (aPixelWidth + 3) / 4;
+		break;
+	case 12:
+	case 16:
+		wordWidth = (aPixelWidth + 1) / 2;
+		break;
+	case 24:
+		wordWidth = (((aPixelWidth * 3) + 11) / 12) * 3;
+		break;
+	case 32:
+		wordWidth = aPixelWidth;
+		break;
+	default:
+		break;
+		};
+
+	return wordWidth * 4;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/group/bld.inf	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+
+    bld.inf Top-level build information for gfxconversion
+
+-----------------------------------------------------------------------------
+*/
+
+#include "../bmconv_s60/group/bld.inf"
+#include "../mifconv/group/bld.inf"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/group/ReleaseNotes_Mifconv.txt	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,145 @@
+===============================================================================
+
+RELEASE NOTES - MIFCONV v3.1.7
+RELEASED 10th July 2009 
+
+SUPPORTS S60 3.2+
+
+===============================================================================
+
+Product Description:
+====================
+Mifconv is a Multi-Icon File (MIF) converter tool for generating MIF, MBM and 
+MBG header files from SVGB, SVG and BMP sources. It can be called directly 
+from the command line or from the PRJ_EXTENSIONS block in a component's 
+bld.inf file, utilizing makefile templates during the build process.
+
+Main Features:
+==============
+- Command line interface for calling Mifconv from custom makefiles
+- Makefile templates for incremental building, supporting GNU make syntax for
+  ABLD build system and FLM syntax for SBSv2 build system
+- Generating MIF files from SVG/SVGB icon sources and BMP file ids
+- Converting SVG to SVGB with the Svgtbinencode utility
+- Generating MBM files with the Bmconv utility
+- Generating icon id enumeration MBG header files from the given source files
+
+===============================================================================
+
+What's New in v3.1.7
+====================
+- Fix: MIF-file is created also when no input files are given.
+- Fix: Correct build directory used with mifconv.flm.
+- Fix: MBM-file is included in RELEASABLES macro in mifconv.flm.
+- Fix: '/' is not a valid option prefix in Linux. Only '-' is allowed.
+- Change: If SBS_BUILD_DIR environment variable is defined, it is used as 
+  a base of temporary icon folder.
+
+===============================================================================
+
+Installation Notes:
+===================
+Mifconv is pre-installed in an SDK environment and does not contain any 
+Symbian software counterparts. 
+
+===============================================================================
+
+System Requirements:
+====================
+Basic Requirements:
+- Any S60 3.2 or higher RnD environment
+
+===============================================================================
+
+Compatibility Issues:
+=====================
+N/A
+
+===============================================================================
+
+Known Issues:
+=============
+- Depth parameter must always be given for each bitmap
+- Heavier components, such as avkon2.mif, are not supported in ABLD build
+  system due to restrictions in GNU make in the SDK
+- If you don't specify TARGETFILE in the bld.inf at all but only a HEADERFILE,
+  the MBM file will be generated to the header file directory 
+
+===============================================================================
+
+Version History:
+================
+
+Version 3.1.6 - 22nd June 2009
+------------------------------
+- Fix: Mifconv.xml updated to schema version 2.0
+
+Version 3.1.5 - 30th April 2009
+-------------------------------
+- Fix: Supressed most of the "overriding commands for target..." warnings 
+  when using mifconv.flm and parallel building.
+- Fix: When using mifconv.flm, svg conversion fails because of unsufficient
+  file access rights after copying the svg files to intermediate directory.
+
+Version 3.1.4 - 17th April 2009 
+-------------------------------
+- Fix: Directory separators in EPOCROOT environment variable and source-
+  directories fixed in mifconv.exe. In some cases there were mixed '/' and '\'
+  characters in a path.
+- Change: Intermediate directory for SVGB files is unique for target component.
+  For example: For target myicons.mif, intermediate directory would be:
+  <EPOCROOT>/epoc32/build/s60/icons/myicons/
+- Fix: No error returned if mifconv.exe cannot remove mif- or mbm-files. Only
+  a warning is printed to debug log.
+- Fix: Info statements were not well-formed in mifconv.flm.
+
+Version 3.1.3 - 9th March 2009
+------------------------------
+- Fix: Removed comments corrupting SBS build log in mifconv.flm
+- Change: Mifconv.flm uses GNURM tool instead of RM.
+
+Version 3.1.2 - 20th February 2009
+----------------------------------
+- Fix: Dependency on mask files added to mifconv.flm. 
+- Fix: Parameter file given to mifconv.exe was generated wrongly when header 
+file parameter was not used with makefile templates.
+- Fix: Mifconv crashed if the file was locked in error situation. 
+- Fix: Mifconv svg conversion failed when EPOCROOT environment variable did
+not end with directory separator.
+
+Version 3.1.1 - 6th February 2009
+---------------------------------
+- Fix: If the header file to be generated is already in use, no error is returned
+  anymore. Instead a warning shown. 
+- Fix: mifconv and svgtbinencode executable name resolution fixed in mifconv.flm.
+- Change: MIFCONVDEBUG parameter added to mifconv.xml
+- Change: TOOLCAT, TOOLCOPY and TOOLMKDIR parameters added to mifconv.xml
+- Change: MIFCONVDEBUG parameter taken into use in mifconv.flm
+- Change: ABLD -what target handling added in mifconv.flm
+
+Version 3.1.0 - 23rd January 2009
+---------------------------------
+- Change: Mifconv makefile templates are included in the project.
+
+Version 3.0.1 - 28th November 2008
+----------------------------------
+- Feature: Support for NVG file format generated by SVGTBinEncode
+
+Version 3.0.0 - 14th November 2008
+----------------------------------
+- Change: Mifconv Extension templates are now a part of normal Mifconv package 
+- Feature: Custom input directories can be given with -i parameter
+- Feature: SVGB binary files can be given as input
+- Feature: Mifconv can be compiled and used in Linux environment
+- Fix: Bmconv is no longer executed from makefile templates, but always from
+  the main executable to avoid problems in the build process
+
+===============================================================================
+
+Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+All rights reserved.
+
+This component and the accompanying materials are made available
+under the terms of "Eclipse Public License v1.0"
+which accompanies this distribution, and is available
+at the URL "http://www.eclipse.org/legal/epl-v10.html".
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/group/bld.inf	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  build file
+*
+*/
+
+
+PRJ_PLATFORMS
+#ifdef SBSV2
+  TOOLS2
+#else
+  TOOLS
+#endif
+
+
+PRJ_MMPFILES
+#if defined(TOOLS) || defined(TOOLS2)
+  mifconv.mmp
+#endif
+
+PRJ_EXPORTS
+#ifdef SBSV2
+  ../makefile_templates/mifconv_global_options.make           +/tools/makefile_templates/s60/mifconv_global_options.make
+  ../makefile_templates/mifconv_option_reader_recursive.make  +/tools/makefile_templates/s60/mifconv_option_reader_recursive.make
+  ../makefile_templates/mifconv_option_reader.make            +/tools/makefile_templates/s60/mifconv_option_reader.make
+  ../makefile_templates/mifconv_step1.make                    +/tools/makefile_templates/s60/mifconv_step1.make
+  ../makefile_templates/mifconv_step2.make                    +/tools/makefile_templates/s60/mifconv_step2.make
+  ../makefile_templates/mifconv_step3.make                    +/tools/makefile_templates/s60/mifconv_step3.make
+  ../makefile_templates/mifconv_step4.make                    +/tools/makefile_templates/s60/mifconv_step4.make
+  ../makefile_templates/mifconv.flm                           +/tools/makefile_templates/s60/mifconv.flm
+  ../makefile_templates/mifconv.meta                          +/tools/makefile_templates/s60/mifconv.meta
+  ../makefile_templates/mifconv.mk                            +/tools/makefile_templates/s60/mifconv.mk
+  ../makefile_templates/mifconv.xml                           +/tools/makefile_templates/s60/mifconv.xml
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/group/mifconv.mmp	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  project definition file
+*
+*/
+
+#include <platform_paths.hrh>
+
+TARGET                      mifconv.exe
+TARGETTYPE                  exe
+
+USERINCLUDE                 ../inc
+MW_LAYER_SYSTEMINCLUDE
+SOURCEPATH                  ../src
+
+SOURCE                      mifconv.cpp 
+SOURCE                      mifconv_argument.cpp 
+SOURCE                      mifconv_argumentmanager.cpp 
+SOURCE                      mifconv_bitmapconverter.cpp 
+SOURCE                      mifconv_bitmapheaderconverter.cpp 
+SOURCE                      mifconv_convertermanager.cpp
+SOURCE                      mifconv_exception.cpp
+SOURCE                      mifconv_iconbinaryconverter.cpp
+SOURCE                      mifconv_mifconverter.cpp
+SOURCE                      mifconv_sourcefile.cpp
+SOURCE                      mifconv_util.cpp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/inc/mifconv.h	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,128 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mifconv definitions.
+*
+*/
+
+
+#ifndef __MIFCONV_H__
+#define __MIFCONV_H__
+
+#if (defined( _MSC_VER ) && _MSC_VER <= 1200 ) //1200 == VC++ 6.0    
+        #pragma warning(disable: 4100)
+        #pragma warning(disable: 4511)
+        #pragma warning(disable: 4512)
+        #pragma warning(disable: 4530)
+        #pragma warning(disable: 4663)
+        #pragma warning(disable: 4710)
+        #pragma warning(disable: 4786)
+        #pragma warning(disable: 4800)
+#endif
+
+#include <iostream>
+#include <fstream>
+using namespace std;
+
+#include "mifconv_types.h"
+using namespace MifConvDefs;
+
+// Mifconv version
+static const MifConvString MifConvVersion("3.1.7");
+static const MifConvString MifConvDate("10th July 2009");
+static const MifConvString MifConvYears("2009");
+
+// Mifconv return values:
+#define MIFCONV_ERROR       1
+#define MIFCONV_NO_ERROR    0
+
+#define MIFCONV_WILDCARD "*"
+#define BMP_FILE_EXTENSION "bmp"
+#define SVG_FILE_EXTENSION "svg"
+#define SVGB_BINARY_FILE_EXTENSION "svgb"
+#define HEADER_FILE_EXTENSION "mbg"
+#define MBM_FILE_EXTENSION "mbm"
+#define MIF_FILE_EXTENSION "mif"
+
+#define FILE_EXTENSION_SEPARATOR "."
+#define STRING_LIST_ARGUMENT_SEPARATOR ";"
+
+#ifdef MSVC7
+    #define FILE_IN_BINARY_NOCREATE_FLAGS (ios::in | ios::binary | ios::nocreate)
+#else
+    #define FILE_IN_BINARY_NOCREATE_FLAGS (ios::in | ios::binary) 
+#endif
+
+#ifdef WIN32
+    #define DIR_SEPARATOR "\\"
+    #define DIR_SEPARATOR2 '\\'
+    #define INCORRECT_DIR_SEPARATOR "/"
+    #define INCORRECT_DIR_SEPARATOR2 '/'
+    #define OPTION_PREFIX1_STR "/"
+    #define OPTION_PREFIX1_CHAR '/'
+    #define OPTION_PREFIX2_STR "-"
+    #define OPTION_PREFIX2_CHAR '-'    
+#else
+    #define DIR_SEPARATOR "/"
+    #define DIR_SEPARATOR2 '/'    
+    #define INCORRECT_DIR_SEPARATOR "\\"
+    #define INCORRECT_DIR_SEPARATOR2 '\\'
+    #define OPTION_PREFIX1_STR "-"
+    #define OPTION_PREFIX1_CHAR '-'
+    #define OPTION_PREFIX2_STR "-"
+    #define OPTION_PREFIX2_CHAR '-' 
+#endif
+
+// BMCONV defines
+#define BMCONV_EXECUTABLE_NAME "bmconv"
+#define BMCONV_TEMP_FILE_POSTFIX "_###_bmconv_tmp_cmd_file"
+
+#if defined (__SERIES60_30__) || defined (__SERIES60_31__) || defined (__S60_32__)
+#define BMCONV_OPTION_PREFIX "/"
+#else
+#define BMCONV_OPTION_PREFIX "-"
+#endif
+
+#define BMCONV_QUIET_PARAMETER "q"
+#define BMCONV_PALETTE_PARAMETER "p"
+
+// SVGTBINENCODE defines
+#define SVGTBINENCODE_EXECUTABLE_NAME "svgtbinencode"
+#define SVGTBINENCODE_OPTION_PREFIX "-"
+#define SVGTBINENCODE_VERSION_PARAMETER "v"
+
+// Bitmap searching directories
+static const MifConvString S60_PATH = "epoc32" + MifConvString(DIR_SEPARATOR) + "s60";
+static const MifConvString S60_ICONS_PATH   = S60_PATH + MifConvString(DIR_SEPARATOR) + "icons";
+static const MifConvString S60_BITMAPS_PATH = S60_PATH + MifConvString(DIR_SEPARATOR) + "bitmaps";
+
+// Environment variable names
+static const MifConvString EPOCROOT_ENV = MifConvString("EPOCROOT");
+static const MifConvString SBS_BUILD_DIR_ENV = MifConvString("SBS_BUILD_DIR");
+
+// EPOC paths
+static const MifConvString EPOC32_PATH = "epoc32";
+static const MifConvString DEFAULT_EPOCROOT = MifConvString("");
+static const MifConvString EPOC_TOOLS_PATH = "epoc32" + MifConvString(DIR_SEPARATOR) + "tools";
+
+static const MifConvString EPOC_BUILD_PATH = "epoc32" + MifConvString(DIR_SEPARATOR) + "build";
+static const MifConvString EPOC_ICON_BUILD_PATH_POSTFIX = "s60" + MifConvString(DIR_SEPARATOR) + "icons";
+
+
+// Debug logging file environment variable
+static const MifConvString MIFCONV_DEBUG_FILE_ENV("MIFCONV_DEBUG_FILE");
+
+// Maximum amount of target file removal tries
+#define MIFCONV_MAX_REMOVE_TRIES    10
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/inc/mifconv_argument.h	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,239 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mifconv tool argument definitions.
+*
+*/
+
+
+#ifndef __MIFCONVARGUMENT_H__
+#define __MIFCONVARGUMENT_H__
+
+#include "mifconv.h"
+#include "mifconv_sourcefile.h"
+#include <vector>
+
+// Argument constants
+static const MifConvString MifConvUseExtensionArg("e");
+static const MifConvString MifConvHeaderArg("h");
+static const MifConvString MifConvHelpHArg("h"); // Duplicate name
+static const MifConvString MifConvHelpQArg("?");
+static const MifConvString MifConvHelpHelpArg("-help");
+static const MifConvString MifConvPaletteFileArg("p");
+static const MifConvString MifConvTempPathArg("t");
+static const MifConvString MifConvBmconvPathArg("b");
+static const MifConvString MifConvSvgencodePathArg("s");
+static const MifConvString MifConvSvgtVersionArg("v");
+static const MifConvString MifConvParameterFileArg("f");
+static const MifConvString MifConvAnimatedIconArg("a"); // This is part of source file argument
+static const MifConvString MifConvDisableSvgCompression("x");
+static const MifConvString MifConvIconSourceDirectory("i");
+static const MifConvString MifConvDepth_1("1");
+static const MifConvString MifConvDepth_2("2");
+static const MifConvString MifConvDepth_4("4");
+static const MifConvString MifConvDepth_8("8");
+static const MifConvString MifConvDepth_c4("c4");
+static const MifConvString MifConvDepth_c8("c8");
+static const MifConvString MifConvDepth_c12("c12");
+static const MifConvString MifConvDepth_c16("c16");
+static const MifConvString MifConvDepth_c24("c24");
+static const MifConvString MifConvDepth_c32("c32");
+static const MifConvString MifConvMaskDepth_1("1");
+static const MifConvString MifConvMaskDepth_8("8");
+
+// Array of help arguments:
+const MifConvString MifConvHelpArguments[] = {
+	MifConvHelpHArg,
+    MifConvHelpQArg,
+    MifConvHelpHelpArg
+	};
+
+// Array of boolean arguments:
+const MifConvString MifConvBooleanArguments[] = {
+	MifConvUseExtensionArg,
+    MifConvDisableSvgCompression
+	};
+
+// Array of string arguments:
+const MifConvString MifConvStringArguments[] = {	
+	MifConvHeaderArg,
+	MifConvPaletteFileArg,
+	MifConvTempPathArg,
+	MifConvBmconvPathArg,
+	MifConvSvgencodePathArg,
+	MifConvSvgtVersionArg,
+	MifConvParameterFileArg    
+};
+
+// Array of string list arguments:
+const MifConvString MifConvStringListArguments[] = {
+    MifConvIconSourceDirectory
+};
+
+// Array of depth values:
+const MifConvString MifConvDepthArguments[] = {
+	MifConvDepth_1,
+	MifConvDepth_2,
+	MifConvDepth_4,
+	MifConvDepth_8,
+	MifConvDepth_c4,
+	MifConvDepth_c8,
+	MifConvDepth_c12,
+	MifConvDepth_c16,
+	MifConvDepth_c24,
+	MifConvDepth_c32
+};
+
+// Argument class template
+template <typename T>
+class MifConvArgument
+{
+public:
+    /**
+     * Constructor
+     * @param argName Argument name
+     * @param argVal Argument value
+     */
+	MifConvArgument( const MifConvString& argName, const T& argVal );
+
+    /**
+     * Copy constructor
+     * @param arg Argument object to be copied
+     */
+	MifConvArgument( const MifConvArgument& arg );
+
+    /**
+     * Destructor
+     */
+	virtual ~MifConvArgument();
+
+    /**
+     * Returns the argument name
+     * @return Argument name
+     */
+	const MifConvString& Name() const;
+
+    /** 
+     * Returns the argument value
+     * @return Argument value
+     */
+	const T& Value() const;
+
+    /**
+     * Sets the argument name
+     * @param argName Argument name
+     */
+	void SetName( const MifConvString& argName );
+
+    /**
+     * Sets the argument value
+     * @param argVal Argument value
+     */
+	void SetValue( const T& argVal );
+
+    /**
+     * Comparison argument for sorting
+     */
+	bool operator< (const MifConvArgument& arg );
+
+protected:
+	MifConvString iName;
+	T iValue;
+};
+
+/**
+ *
+ */
+template <typename T>
+MifConvArgument<T>::MifConvArgument(const MifConvString& argName, const T& argVal )
+: 
+iName( argName ),
+iValue( argVal )  
+{
+}
+
+/**
+ *
+ */
+template <typename T>
+MifConvArgument<T>::MifConvArgument(const MifConvArgument& arg )
+:
+iName(arg.iName),
+iValue(arg.iValue)
+{}
+
+/**
+ *
+ */
+template <typename T>
+MifConvArgument<T>::~MifConvArgument()
+{}
+
+/**
+ *
+ */
+template <typename T>
+const MifConvString& MifConvArgument<T>::Name() const
+{
+	return iName;
+}
+
+/**
+ *
+ */
+template <typename T>
+const T& MifConvArgument<T>::Value() const
+{
+	return iValue;
+}
+
+/**
+ *
+ */
+template <typename T>
+void MifConvArgument<T>::SetName( const MifConvString& argName )
+{
+	iName = argName;
+}
+
+/**
+ *
+ */
+template <typename T>
+void MifConvArgument<T>::SetValue( const T& argVal )
+{
+	iValue = argVal;
+}
+
+/**
+ *
+ */
+template <typename T>
+bool MifConvArgument<T>::operator< ( const MifConvArgument& arg )
+{
+	return iName < arg.iName;
+}
+
+/**
+ * Type definitions
+ */
+typedef MifConvArgument<bool> MifConvBooleanArgument;
+typedef MifConvArgument<MifConvString> MifConvStringArgument;
+typedef MifConvArgument<MifConvStringList> MifConvStringListArgument;
+typedef MifConvArgument<MifConvSourceFile> MifConvSourceFileArgument;
+
+typedef std::vector<MifConvBooleanArgument> MifConvBooleanArgumentList;
+typedef std::vector<MifConvStringArgument> MifConvStringArgumentList;
+typedef std::vector<MifConvSourceFileArgument> MifConvSourceFileArgumentList;
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/inc/mifconv_argumentmanager.h	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,379 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mifconv argument manager class.
+*
+*/
+
+
+#ifndef __MIFCONVARGUMENTMANAGER_H__
+#define __MIFCONVARGUMENTMANAGER_H__
+
+#include <map>
+#include "mifconv.h"
+#include "mifconv_sourcefile.h"
+#include "mifconv_argument.h"
+
+
+/**
+ * This helper class is used to specify rules that will be used when
+ * mifconv is searching source icons from the predefined folders.
+ * Currently it supports rules that specify what kind of files can be
+ * located in the folders.
+ */
+class MifConvSourceSearchRule
+{
+public:
+    /**
+     * Constructor
+     * @param path Path to the folder, which the rule affects on.
+     * @param types Allowed file types that can be located in the given 
+     * <code>path</code>
+     */
+    MifConvSourceSearchRule(const MifConvString& path, const MifConvStringList& types);
+
+    /**
+     * Destructor
+     */
+    virtual ~MifConvSourceSearchRule();
+
+    /**
+     * Returns the path to the folder
+     * @return Path to the folder from which the files are searched.
+     */
+    const MifConvString& SearchPath() const;
+    MifConvString& SearchPath();
+
+    /**
+     * Returns a list of allowed file types (extensions). 
+     * <code>MIFCONV_WILDCARD</code> can be used as a wildcard, meaning that
+     * there are no restrictions for the filetype in the specific folder.
+     * @return List of allowed file extensions.
+     */
+    const MifConvStringList& AllowedFileTypes() const;
+private:
+    MifConvString iSearchPath;
+    MifConvStringList iAllowedFileTypes;
+};
+
+class MifConvArgumentManager
+{
+public:
+
+    /**
+     * Returns a pointer to the singleton instance.
+     * @return Pointer to the singleton instance.
+     */
+    static MifConvArgumentManager* Instance();
+        
+    /** 
+     * Destructor
+     */
+	virtual ~MifConvArgumentManager();
+
+	/** 
+	 * Initializes the argument list.
+	 * @param argList List of strings from which the arguments are parsed.
+	 */
+	void Init( const MifConvStringList& argList );
+
+    /**
+     * Deallocates the allocated memory.
+     */
+    static void Reset();
+
+	/**
+	 * Set target filename (i.e. mif-filename)
+	 * @param arg target filename
+	 */
+	void SetTargetFile( const MifConvString& arg );
+
+	/**
+	 * Returns target filename
+	 * @return target filename
+	 */
+	const MifConvString& TargetFile() const;
+
+	/**
+	 * Returns argument value
+	 * @param argName Argument name
+	 * @return Argument value
+	 */
+	const MifConvString& StringValue(const MifConvString& argName) const;
+
+    /**
+     * Returns argument value list
+     * @param argName Argument name
+     * @return List of argument values
+     */
+    const MifConvStringList& StringListValue(const MifConvString& argName) const;
+
+	/**
+	 * Returns value of an boolean argument. Returns false, if argument is not 
+	 * found from the boolean argument list.
+	 * @param argName Argument name
+	 * @return Argument value
+	 */
+	bool BooleanValue( const MifConvString& argName ) const;
+
+	/**
+	 * Returns source file list given in command line parameters
+	 * @return List of source files
+	 */
+	const MifConvSourceFileList& SourceFiles() const;
+
+	/**
+	 * Adds argument value to the argument map
+	 * @param argName Name of the argument
+	 * @param argValue Value of the argument
+	 */
+	void AddArgumentValue( const MifConvString& argName, const MifConvString& argValue );
+
+	/**
+	 * Add source file to the source file list
+	 * @param sourceFile Source file object to be added to the list
+	 */
+	void AddSourceFile( const MifConvSourceFile& sourceFile );
+    
+    /**
+     * Returns value of EPOCROOT environment variable. If the EPOCROOT 
+     * environment variable is defined (i.e. length > 0), directory separator
+     * is added to returned string if it is missing from the EPOCROOT.
+     * @return EPOCROOT environment variable value
+     */
+    const MifConvString& EpocRoot() const;
+
+    /**
+     * Converts depth value to display mode value
+     * @return IconDisplayMode enumeration value 
+     * @param depth IconDepth enumeration value
+     */
+    IconDisplayMode ConvertToDisplayMode(IconDepth depth) const;
+
+    /**
+     * Converts mask depth value to display mode value
+     * @return IconDisplayMode enumeration value 
+     * @param mask IconMaskDepth enumeration value
+     */
+    IconDisplayMode ConvertToMaskDisplayMode(IconMaskDepth mask) const;
+
+    /**
+     * Converts depth string value to depth enumeration value
+     * @return IconDepth enumeration value
+     * @param depthStr depth string      
+     */
+    IconDepth ConvertToDepth( const MifConvString& depthStr ) const;
+
+    /**
+     * Converts mask depth string value to mask depth enumeration value
+     * @return IconMaskDepth enumeration value 
+     * @param depthStr mask depth string
+     */
+    IconMaskDepth ConvertToMaskDepth( const MifConvString depthStr ) const;
+
+protected:
+
+    /**
+     * Tells whether the given string is a valid argument name
+     * @return True if the given string is valid argument
+     * @param argName String representing the argument name
+     */
+	bool IsArgument( const MifConvString& argName ) const;
+
+    /**
+     * Tells whether the given argument is of string type and returns the 
+     * length of the argument name. For example: If given string 
+     * "/HMyHeader.mbg" this function returns 1, which is the length of the
+     * argument name "H".
+     * @return Length of the string if the given argument is string type, zero 
+     * otherwise
+     * @param argName Argument name
+     */
+	size_t IsStringArgument( const MifConvString& argName ) const;
+
+    /**
+     * Tells whether the given argument is of string list type and returns the 
+     * length of the argument name. For example: If given string 
+     * "/iInputDir;TempDir" this function returns 1, which is the length of the
+     * argument name "i".
+     * @return Length of the string if the given argument is string list type, zero 
+     * otherwise
+     * @param argName Argument name
+     */
+	size_t IsStringListArgument( const MifConvString& argName ) const;
+
+    /**
+     * Tells whether the given argument is of boolean type and returns the 
+     * length of the argument name. For example: If given string "/E" this 
+     * function returns 1, which is the length of the argument name "E".
+     * @return Length of the argument name if the given argument is boolean 
+     * type, zero otherwise
+     * @param argName Argument name
+     */
+	size_t IsBooleanArgument( const MifConvString& argName ) const;
+
+    /**
+     * Tells whether the given argument is a help argument and returns the 
+     * length of the argument name. For example: If given string "--help" this
+     * function returns 5, which is the length of the argument name "-help".
+     * @return Length of the argument name if the given argument is a help 
+     * argument, zero otherwise
+     * @param argName Argument name
+     */
+    size_t IsHelpArgument( const MifConvString& argName ) const;
+
+    /**
+     * Tells whether the given argument is a valid depth value
+     * @return True if the given argument is a valid depth value, false 
+     * otherwise
+     * @param argName Argument string
+     */
+	bool IsDepthArgument( const MifConvString& argName ) const;
+
+    /**
+     * Tells whether the given argument is an "animated" -flag
+     * @return True if the given argument is an "animated" -flag, false 
+     * otherwise
+     * @param argName Argument string
+     */
+	bool IsAnimatedFlag( const MifConvString& argName ) const;
+
+    /**
+     * Finalizes the command line arguments for internal use.
+     */
+	void FinalizeArguments();
+
+    /**
+     * Processes and fix the directory paths given in command line arguments.
+     */
+	void ProcessArgumentPaths();
+
+    /**
+     * Resolves the actual source file types by searching them in user defined
+     * or pre-defined locations.
+     */
+	void ResolveSourceFileTypes();
+
+    /**
+     * Sets usage instructions in the given string
+     * @param usageStr Usage instuctions are copied in this string object.
+     */
+	void SetUsageString( MifConvString& usageStr ) const;
+
+    /**
+     * Gets needed environment variables.
+     */
+    void GetMifEnv();
+
+    /**
+     * Completes the given path to full directory path without the drive letter.
+     * @param sourcePath Directory path to be completed to full path.
+     * @param targetPath Full directory path is copied here.
+     */
+    void MifFullPath( const MifConvString& sourcePath, MifConvString& targetPath);
+
+    /**
+     * Completes the given drive and path to full absolute directory path.
+     * @param sourceDrive Drive of the absolute path. If empty, epocroot 
+     * environment variable is used.
+     * @param sourcePath Directory path to be completed to absolute path.
+     * @param targetPath Absolute directory path is copied here.
+     */     
+    void MifAbsolutePath( const MifConvString& sourceDrive, const MifConvString& sourcePath, MifConvString& targetPath);
+
+    /**
+     * Checks wheter the given file-extension is the correct one for the source 
+     * file. Sets also the source filename to complete one.
+     * @return true if the given source file with given extension is found and 
+     * to be used.
+     * @param srcFile Source file object
+     * @param extension Extension of the source file
+     */
+    bool FindAndSetPathAndType( MifConvSourceFile& srcFile, const MifConvString& extension );
+
+    /**
+     * Fills up the depth and mask depth maps used to map different enumeration 
+     * values internally.
+     */
+    void PopulateDepthAndMaskMaps();
+
+    /**
+     * Reads the parameter file containing commandline parameters and source 
+     * icon files
+     * @param paramFilename Filename for the parameter file.
+     * @param paramList Parameters are inserted to this list.
+     */
+    void ReadParameterFile(const MifConvString& paramFilename, MifConvStringList& paramList);
+
+    /**
+     * Adds arguments to internal data structures
+     * @param argList List containing arguments
+     * @param paramsFromFile Tells if the parameters are read from the 
+     * parameter file or not.
+     * Applied usage rules depend sligthly on this.
+     */
+    void AddArguments( const MifConvStringList& argList, bool paramsFromFile = false );
+
+    /**
+     * Reads string argument from the list to internal data structure
+     */
+    MifConvString ReadStringArgument(const MifConvStringList& argList, MifConvStringList::const_iterator& i, unsigned int argNameLen);
+
+    /**
+     * Reads string list argument from the list to internal data structure
+     */
+    void ReadStringListArgument(MifConvStringList::const_iterator& i, unsigned int argNameLen, MifConvStringList& StringValueList);
+
+    // Internal data structure for boolean type arguments
+	typedef std::map<MifConvString, MifConvBooleanArgument> BooleanArgMap;
+    BooleanArgMap iBooleanArguments;
+
+    // Internal data structure for string type arguments
+	typedef std::map<MifConvString, MifConvStringArgument> StringArgMap;
+    StringArgMap iStringArguments;
+
+    // Internal data structure for string list type arguments
+    typedef std::map<MifConvString, MifConvStringListArgument> StringListArgMap;
+    StringListArgMap iStringListArguments;
+
+	inline void THROW_USAGE_EXCEPTION() const;
+    inline void THROW_ERROR( const MifConvString& errorMsg, const MifConvString& file = MifConvString(), int line = 0) const;
+	
+	MifConvSourceFileList iSourceFiles;
+	MifConvString iTargetFile;
+	MifConvString iDummyString;
+    MifConvStringList iDummyStringList;
+    //MifConvStringList iSearchPaths;    
+    MifConvString iEpocRoot;
+
+    // Internal data structure storing the rules used when finding source icons 
+    // from the folders
+    typedef vector<MifConvSourceSearchRule> SearchRules;
+    SearchRules iSearchRules;
+
+    private:
+
+    /**
+     * Default constructor
+     */
+	MifConvArgumentManager();
+    static MifConvArgumentManager* iInstance;
+
+    MifConvIconDepthMap iDepthMap;
+    MifConvIconMaskDepthMap iMaskDepthMap;
+    MifConvIconDisplayModeMap iDisplayModeMap;
+    MifConvMaskIconDisplayModeMap iMaskDisplayModeMap;
+};
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/inc/mifconv_bitmapconverter.h	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,93 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mifconv bitmap converters class.
+*
+*/
+
+
+#ifndef __MIFCONVBITMAPCONVERTER_H__
+#define __MIFCONVBITMAPCONVERTER_H__
+
+#include "mifconv_fileconverter.h"
+#include <fstream>
+
+/**
+ * Converter class for converting .bmp files to .mbm file.
+ */
+
+class MifConvBitmapConverter : public MifConvFileConverter
+{
+public:
+
+    /**
+     * Default constructor
+     */ 
+    MifConvBitmapConverter();
+
+    /**
+     * Destructor
+     */
+    virtual ~MifConvBitmapConverter();
+
+    // From MifConvFileConverter
+	virtual void AppendFile( const MifConvSourceFile& sourcefile );
+	virtual void Convert();
+	virtual void Cleanup(bool err = false);
+	virtual void Init();
+	virtual void CleanupTargetFiles();
+
+protected:
+
+    /**
+     * Converts files to .mbm file     
+     */
+	virtual void ConvertToMbm();
+
+    /**
+     * Removes temporary files from the file system.
+     */
+	virtual void CleanupTempFiles();
+
+    /**
+     * Runs external bmconv application, which builds the .mbm file.     
+     */
+    void RunBmconv();
+
+    /**
+     * Creates and initializes the temporary file.     
+     */
+    void InitTempFile();
+
+    /**
+     * Add bitmap file to the temporary file
+     * @param stream file stream for temporary file
+     * @param bmpFile Source file object representing the bitmap file.
+     */
+    void AppendBmpToTempFile(fstream& stream, const MifConvSourceFile& bmpFile);
+
+    /**
+     * Returns the default path for the external bmconv executable.
+     * @return Default bmconv path.
+     */
+    const MifConvString& GetDefaultBmConvPath();
+private:
+    
+    MifConvString iTempDir;
+    MifConvString iTempFilename;
+    MifConvString iDefaultBmConvPath;
+    MifConvString iTargetFilename;
+};
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/inc/mifconv_bitmapheaderconverter.h	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,72 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mifconv bitmap to header converter class.
+*
+*/
+
+
+#ifndef __MIFCONVBITMAPHEADERCONVERTER_H__
+#define __MIFCONVBITMAPHEADERCONVERTER_H__
+
+#include "mifconv_fileconverter.h"
+#include <fstream>
+
+/**
+ * Converter class for converting source files to .mbg header files
+ */
+class MifConvBitmapHeaderConverter : public MifConvFileConverter
+{
+public:
+    /**
+     * Default constructor
+     */
+    MifConvBitmapHeaderConverter();
+
+    /**
+     * Destructor
+     */
+    virtual ~MifConvBitmapHeaderConverter();
+
+    // From MifConvFileConverter
+    virtual void AppendFile( const MifConvSourceFile& sourcefile );
+    virtual void Convert();
+    virtual void Cleanup(bool err = false);
+    virtual void Init();
+    virtual void CleanupTargetFiles();
+
+protected:
+
+    /**
+     * Writes the beginning of the header
+     */ 
+    void WriteStart();
+
+    /**
+     * Writes source file information to the header file
+     * @param source Source file object representing the file to be 
+     * added to the header.
+     */
+    void WriteItemToHeader( const MifConvSourceFile& source );
+
+    /**
+     * Writes the end of the header.
+     */
+    void WriteEnd();
+
+    MifConvString iHeaderFilename;
+    fstream* iDestFile;
+    int iCurrentSourceId;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/inc/mifconv_convertermanager.h	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mifconv converter manager class.
+*
+*/
+
+
+#ifndef __MIFCONVCONVERTERMANAGER_H__
+#define __MIFCONVCONVERTERMANAGER_H__
+
+#include "mifconv_fileconverter.h"
+
+typedef std::map<MifConvString, MifConvFileConverterList> FileConverterMap;
+
+class MifConvConverterManager
+{
+public:
+	
+    static MifConvConverterManager* Instance();
+    static void Reset();
+	~MifConvConverterManager();
+
+    /**
+     * Initializes the converter manager. Note! Argument manager must be initialized
+     * before calling this.
+     */
+    void Init();
+
+	/**
+	 * This method initializes the file converter list and processes the source 
+	 * files given in arguments. It finds the correct file converter for each 
+	 * source file and lets it do the file conversion.	 
+	 */
+	void ProcessIcons();
+
+	/**
+	 * This method runs the cleanup method of each file converter in the file converter list.
+	 * @param error True if error situation
+	 */
+	void Cleanup(bool error = false);
+
+    /**
+     * Returns all the converters for the given type of file.
+     * @return List of the matching converters.
+     * @param source Source file object
+     */
+    MifConvFileConverterList& GetConverters(const MifConvSourceFile& source);
+
+    /**
+     * Returns all the converters for the given type of file.
+     * @return List of the matching converters.
+     * @param filename Source file name
+     */
+    MifConvFileConverterList& GetConverters(const MifConvString& filename);
+
+private:
+
+    MifConvConverterManager();
+	// File converter map containing all the converters needed to process the source icons.
+    // Map is ordered by file-extensions:    
+    FileConverterMap iFileConverters;
+    MifConvFileConverterList iAllConverters;
+    MifConvFileConverterList iDummyConverterList;
+
+    static MifConvConverterManager* iInstance;
+};
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/inc/mifconv_exception.h	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,105 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mifconv exception class.
+*
+*/
+
+
+#ifndef __MIFCONVEXCEPTION_H__
+#define __MIFCONVEXCEPTION_H__
+
+#include "mifconv.h"
+
+/**
+ * MifConvException class
+ */
+class MifConvException
+{
+public:
+
+    /**
+     * Default constructor
+     */
+	MifConvException();
+
+    /**
+     * Constructor
+     */
+	MifConvException(const MifConvString& str, const MifConvString& file = MifConvString(), int line = 0);
+
+    /**
+     * Copy constructor
+     */
+    MifConvException(const MifConvException& rhs);
+
+    /**
+     * Destructor
+     */
+	virtual ~MifConvException();
+
+    /**
+     * Sets the error string to be shown to user.
+     * @param str Error string
+     */
+	void SetString(const MifConvString& str);
+
+    /**
+     * Returns the error string
+     * @return Error string
+     */
+	const MifConvString& String() const;
+
+    /**
+     * Returns the error string
+     * @return Error string
+     */
+	MifConvString& String();
+
+    /**
+     * Sets the file name
+     * @param filename Source code file name
+     */
+    void SetFile(const MifConvString& filename);
+
+    /**
+     * Sets the line in the file
+     * @param line Line number in the source code file
+     */
+    void SetLine(int line);
+
+    /**
+     * Returns the filename
+     * @return Source code filename
+     */
+    const MifConvString& File() const;
+
+    /**
+     * Returns the line number
+     * @return Line number in the source code file
+     */
+    int Line() const;
+
+protected:
+
+	MifConvString iString;
+    MifConvString iFile;
+    int iLine;
+};
+
+inline void THROW_ERROR_COMMON(const MifConvString& errorMsg, const MifConvString file = MifConvString(), int line = 0 )
+{    
+    throw MifConvException( MifConvString("ERROR: " + errorMsg + "\n"), file, line );
+}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/inc/mifconv_fileconverter.h	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mifconv converter base class.
+*
+*/
+
+
+#ifndef __MIFCONVFILECONVERTER_H__
+#define __MIFCONVFILECONVERTER_H__
+
+#include <vector>
+#include "mifconv.h"
+#include "mifconv_sourcefile.h"
+
+/**
+ * Virtual base class for file converters
+ */
+class MifConvFileConverter
+{
+public:
+
+    /**
+     * Destructor
+     */
+    virtual ~MifConvFileConverter(){};
+
+    /**
+     * Appends source file to the internal file list.
+     * @param Source file object
+     */
+	virtual void AppendFile( const MifConvSourceFile& sourcefile ) = 0;
+
+    /**
+     * Converts all the files in the internal file list.     
+     */
+	virtual void Convert() = 0;
+
+    /**
+     * Cleans up the temporary files etc.
+     * @param error True in error situations
+     */
+	virtual void Cleanup(bool error = false) = 0;
+	
+	virtual void Init() = 0;
+	
+	virtual void CleanupTargetFiles() = 0;
+
+protected:
+    // Internal file list
+	MifConvSourceFileList iSourceFiles;
+};
+
+typedef std::vector<MifConvFileConverter*> MifConvFileConverterList;
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/inc/mifconv_iconbinaryconverter.h	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,87 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mifconv icon binary converters class.
+*
+*/
+
+
+#ifndef __MIFCONVICONBINARYCONVERTER_H__
+#define __MIFCONVICONBINARYCONVERTER_H__
+
+#include "mifconv_fileconverter.h"
+#include <fstream>
+
+/**
+ * Converter class for .svg to .svgb conversion:
+ */
+
+class MifConvIconBinaryConverter : public MifConvFileConverter
+{
+public:
+
+    /**
+     * Default constructor
+     */
+    MifConvIconBinaryConverter();
+
+    /**
+     * Destructor
+     */
+    virtual ~MifConvIconBinaryConverter();
+
+    // From MifConvFileConverter:
+	virtual void AppendFile( const MifConvSourceFile& sourcefile );
+	virtual void Convert();
+	virtual void Cleanup(bool err = false);
+	virtual void Init();
+	virtual void CleanupTargetFiles();
+
+protected:
+
+    /**
+     * Converts files to svgb files.     
+     */
+	virtual void ConvertToSvgb();
+
+    /**
+     * Removes temporary files from the file system.
+     */
+	virtual void CleanupTempFiles();
+
+    /**
+     * Runs the external converter.     
+     */
+    void RunExtConverter();
+
+    /**
+     * Creates and initializes the temporary file     
+     */
+    void InitTempFile();
+   
+    /**
+     * Returns default path to external converter.
+     * @return Default path to external converter.
+     */
+    const MifConvString& GetDefaultExtConverterPath();
+
+    void ConvertToBinaryFilename( MifConvString& input );
+private:
+    
+    MifConvString iTempDir;
+    MifConvStringList iTempFilenames;
+    MifConvString iDefaultExtConverterPath;    
+};
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/inc/mifconv_mifconverter.h	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,94 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mifconv MIF converters class.
+*
+*/
+
+
+#ifndef __MIFCONVMIFCONVERTER_H__
+#define __MIFCONVMIFCONVERTER_H__
+
+#include "mifconv_fileconverter.h"
+#include <fstream>
+#include <vector>
+
+/**
+ * Converter class for converting source files to .mif file.
+ */
+
+class MifConvMifConverter : public MifConvFileConverter
+{
+public:
+
+    /**
+     * Default constructor
+     */ 
+    MifConvMifConverter();
+
+    /**
+     * Destructor
+     */
+    virtual ~MifConvMifConverter();
+
+    // From MifConvFileConverter
+	virtual void AppendFile( const MifConvSourceFile& sourcefile );
+	virtual void Convert();
+	virtual void Cleanup(bool err = false);
+	virtual void Init();
+	virtual void CleanupTargetFiles();
+
+protected:
+
+    /**
+     * Converts files to .mif file
+     * @param argMgr Reference to argument manager object. 
+     */
+	virtual void ConvertToMif();
+
+    /**
+     * Removes temporary files from the file system.
+     */
+	virtual void CleanupTempFiles();
+    
+    /**
+     * Creates and initializes the temporary file.
+     * @param argMgr Reference to argument manager object.
+     */
+    void InitTempFile();
+
+    /**
+     * Add source file to the temporary file     
+     * @param srcFile Source file object
+     */
+    void AppendSourceToTempFile(const MifConvSourceFile& srcFile);
+
+    void ReadFileContents();
+    void OpenTargetFile();
+    void WriteTargetHeader();
+    void WriteIconArray();
+    void WriteIcons();
+    void WriteIconHeader(const MifConvSourceFile& src);
+    void WriteIconData(const MifConvSourceFile& src);
+    MifConvDefs::IconFormatType ReadIconBinaryType(const MifConvSourceFile& src);
+
+    
+private:
+    
+    MifConvString iTargetFilename;
+    fstream iTargetFile;
+    typedef std::vector<char*> StringPtrVector;
+    StringPtrVector iContentPointers;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/inc/mifconv_sourcefile.h	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,210 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mifconv source file class.
+*
+*/
+
+
+#ifndef __MIFCONVSOURCEFILE_H__
+#define __MIFCONVSOURCEFILE_H__
+
+#include "mifconv.h"
+
+class MifConvSourceFile
+{
+public:
+
+	/**
+	 * Default constructor
+	 */
+	MifConvSourceFile();
+
+    /**
+     * Copy constructor
+     */
+    MifConvSourceFile( const MifConvSourceFile& src );
+	
+	/**
+	 * Destructor
+	 */
+	virtual ~MifConvSourceFile();
+
+	/**
+	 * Sets filename for the icon file
+	 * @param filename Source icon filename 
+	 */
+	void SetFilename( const MifConvString& filename );
+	
+	/**
+	 * Sets icon depth for the source file
+	 * @param depth Icon depth string.
+	 */
+	void SetDepthString( const MifConvString& depth);
+
+	/**
+	 * Sets icon mask depth for the source file
+	 * @param depth Icon mask depth string.
+	 */
+	void SetMaskDepthString( const MifConvString& depth);
+
+	/**
+	 * Specifies the animated flag for icon
+	 * @param isAnimated, true if the icon is animated, false otherwise
+	 */
+	void SetAnimated( bool isAnimated );
+
+	/**
+	 * Sets icon depth and mask depth parameters for the source file. Sets both string and enumeration values of
+     * depth and mask depth parameters.
+	 * @param depthAndMask String containing the depth and mask as user has given them (e.g "/c8,8")
+	 */
+	void SetDepthAndMask( const MifConvString& depthAndMask );
+
+	/**
+	 * Returns source icon filename
+	 * @return Filename of the icon file
+	 */
+	const MifConvString& Filename() const;
+
+	/**
+	 * Returns icon depth of the source file
+	 * @return Icon depth enumeration value.
+	 */
+	IconDepth Depth() const;
+
+    /**
+	 * Sets icon depth of the source file
+	 * @param depth Icon depth enumeration value.
+	 */
+	void SetDepth(IconDepth depth);
+
+    /**
+     * Returns icon depth of the source file
+     * @return Icon depth string
+     */
+    const MifConvString& DepthString() const;
+
+	/**
+	 * Returns icon depth of the mask file
+	 * @return Icon mask depth enumeration value.
+	 */
+	IconMaskDepth MaskDepth() const;
+
+    /**
+	 * Sets icon depth of the mask file
+	 * @param depth Icon mask depth enumeration value.
+	 */
+	void SetMaskDepth(IconMaskDepth depth);
+
+    /**
+     * Returns icon depth of the mask file
+     * @return Icon mask depth string
+     */
+    const MifConvString& MaskDepthString() const;
+
+    /**
+     * Returns true if the icon is animated, otherwise false
+     * @return <code>boolean</code> value specifying if the icon is animated.
+     */
+    bool IsAnimated() const;
+
+    /**
+     * Returns the mask filename for the bmp file
+     * @return Mask file name for the bitmap file.
+     */
+    const MifConvString& BmpMaskFilename() const;
+
+    /**
+     * Sets mask filename.
+     * @param maskFilename Mask filename
+     */
+    void SetBmpMaskFilename( const MifConvString& maskFilename );
+
+    /**
+     * Sets file content.
+     * @param content Pointer to the data content array.
+     * @param len Data content lenght
+     */
+    void SetContent( char* content, unsigned int len );
+
+    /**
+     * Returns data content of the file
+     * @return Pointer to the data content array. See also ContentLength() -method.
+     */
+    char* Content() const;
+
+    /**
+     * Returns data content length.
+     * @return Length of the data content.
+     */
+    int ContentLength() const;
+
+    /**
+     * Sets display mode for the source icon.
+     * @param mode Display mode enumeration value.
+     */
+    void SetDisplayMode( IconDisplayMode mode);
+
+    /**
+     * Returns display mode of the icon.
+     * @return Display mode enumeration value.
+     */
+    IconDisplayMode DisplayMode() const;
+
+    /**
+     * Sets display mode for the mask file.
+     * @param mode Display mode enumeration value for the mask file.
+     */
+    void SetMaskDisplayMode( IconDisplayMode mode);
+
+    /**
+     * Returns display mode of the mask file.
+     * @return Display mode enumeration value of the mask file.
+     */
+    IconDisplayMode MaskDisplayMode() const;
+
+protected:
+ 
+    /**
+     * Parses icon depth parameter from the user given argument string. If, for example, user
+     * has given a string "/c8,8" as a depth and mask for the file, this function returns <code>IconDepth_c8</code>
+     * @param depthAndMask String containing the depth and mask parameters for the source file.
+     * @return Icon depth enumeration value
+     */
+    IconDepth ParseIconDepth( const MifConvString& depthAndMask );
+
+    /**
+     * Parses icon mask parameter from the user given argument string. If, for example, user
+     * has given a string "/c8,8" as a depth and mask for the file, this function returns <code>IconMask_8</code>
+     * @param depthAndMask String containing the depth and mask parameters for the source file.
+     * @return Icon mask enumeration value
+     */
+    IconMaskDepth ParseIconMaskDepth( const MifConvString& depthAndMask );
+
+    MifConvString   iFilename;
+    MifConvString   iDepthString;
+    MifConvString   iMaskDepthString;
+    IconDepth       iDepth;
+    IconMaskDepth   iMaskDepth;
+    IconDisplayMode iDisplayMode;
+    IconDisplayMode iMaskDisplayMode;
+    bool iAnimated;    
+    MifConvString iMaskFilename;
+    char* iContent;
+    unsigned int iContentLen;
+};
+
+typedef std::vector<MifConvSourceFile> MifConvSourceFileList;
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/inc/mifconv_types.h	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,100 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mifconv type definitions.
+*
+*/
+
+
+#ifndef __MIFCONVTYPES_H__
+#define __MIFCONVTYPES_H__
+
+#include <vector>
+#include <string>
+#include <map>
+
+namespace MifConvDefs
+{
+	typedef std::string MifConvString;
+	typedef std::vector<MifConvString> MifConvStringList;
+    
+	enum IconDepth
+	{
+		IconDepth_Undefined = 0,
+		IconDepth_1,
+		IconDepth_2,
+		IconDepth_4,
+		IconDepth_8,
+		IconDepth_c4,
+		IconDepth_c8,
+		IconDepth_c12,
+		IconDepth_c16,
+		IconDepth_c24,
+		IconDepth_c32
+	};
+
+	enum IconMaskDepth
+	{
+		IconMaskDepth_Undefined = 0,
+		IconMaskDepth_1,
+		IconMaskDepth_8
+	};
+    
+    enum IconDisplayMode
+	{
+	/** No display mode */
+	DisplayMode_None,
+	/** Monochrome display mode (1 bpp) */
+	DisplayMode_Gray2,
+	/** Four grayscales display mode (2 bpp) */
+	DisplayMode_Gray4,
+	/** 16 grayscales display mode (4 bpp) */
+	DisplayMode_Gray16,
+	/** 256 grayscales display mode (8 bpp) */
+	DisplayMode_Gray256,
+	/** Low colour EGA 16 colour display mode (4 bpp) */
+	DisplayMode_Color16,
+	/** 256 colour display mode (8 bpp) */
+	DisplayMode_Color256,
+	/** 64,000 colour display mode (16 bpp) */
+	DisplayMode_Color64K,
+	/** True colour display mode (24 bpp) */
+	DisplayMode_Color16M,
+	/** (Not an actual display mode used for moving buffers containing bitmaps) */
+	DisplayMode_Rgb,
+	/** 4096 colour display (12 bpp). */
+	DisplayMode_Color4K,
+	DisplayMode_Color16MU,
+	//Any new display mode should be insterted here!
+	//There might be up to 255 display modes, so value of the last
+	//inserted EColorXXX enum item should be less than 256 -
+	//BC reasons!
+	DisplayMode_ColorLast
+	};
+    
+    enum IconFormatType
+    {
+        IconFormatType_BMP,
+        IconFormatType_SVG,
+        IconFormatType_NVG
+    };
+
+    typedef std::map<MifConvString, IconDepth> MifConvIconDepthMap;
+    typedef std::map<MifConvString, IconMaskDepth> MifConvIconMaskDepthMap;
+    typedef std::map<IconDepth, IconDisplayMode> MifConvIconDisplayModeMap;
+    typedef std::map<IconMaskDepth, IconDisplayMode> MifConvMaskIconDisplayModeMap;
+
+    typedef std::pair<char*, unsigned int> MifConvFileData;
+}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/inc/mifconv_util.h	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,246 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mifconv utilities.
+*
+*/
+
+
+#ifndef __MIFCONVUTIL_H__
+#define __MIFCONVUTIL_H__
+
+#include "mifconv.h"
+#include "mifconv_sourcefile.h"
+#include <sstream>
+
+class MifConvUtil
+{
+public:
+
+    /**
+     * Returns file extension of the given filename
+     * @return String representing the file extension
+     * @param fileName String representing the file name.
+     */
+	static MifConvString FileExtension( const MifConvString& fileName );
+
+    /**
+     * Returns file name without the extension
+     * @return String representing the file name without the extension
+     * @param fileName String representing the file name.
+     */
+    static MifConvString FilenameWithoutExtension( const MifConvString& fileName );
+
+    /**
+     * Returns file name without the path
+     * @return String representing the file name without the path
+     * @param fileName String representing the file name.
+     */
+    static MifConvString FilenameWithoutPath( const MifConvString& fileName );
+
+    /**
+     * Tells whether the file with the given filename exists.
+     * @return true if the given file exists, false otherwise.
+     * @param fileName File name
+     */
+    static bool FileExists( const MifConvString& fileName ); 
+
+    /**
+     * Returns file size
+     * @return File size
+     * @param fileName File name
+     */
+    static size_t FileSize( const MifConvString& fileName );
+
+    /**
+     * Reads file contents and returns pointer to data buffer. Returns also
+     * the data size in bytes.
+     * @return std::pair object containing the pointer to the allocated data buffer and the 
+     * data size in byte. The caller must take the ownership of the returned data pointer.
+     * @param fileName Filename
+     */
+    static MifConvFileData FileContents( const MifConvString& fileName );
+
+    /**
+     * Converts the given object to string. Can be used for example to converting integers to string:
+     * <code>
+     * int i = 0;
+     * MifConvString iAsString(MifConvUtil::ToString(i));
+     * </code>
+     *
+     * @return String built from the given object.
+     * @param s Reference to the object to be converted to string.
+     */
+    template <typename T>
+    static MifConvString ToString(const T& s)
+    {
+        std::stringstream ss;
+        ss << s;
+        return MifConvString(ss.str());
+    }
+
+    /**
+     * Replaces given characters to other one from the given string.
+     * @param str String from which the characters will be replaced.
+     * @param replaceFrom This character will be replaced by other one.
+     * @param replaceTo Characters will be replaced by this.
+     */
+    static void ReplaceChar( MifConvString& str, char replaceFrom, char replaceTo);
+
+    /** 
+     * Tells whether the given character is a whitespace character or not.
+     * @param c Charater to be investigated.
+     * @return true if the given character is whitespace character, false otherwise.
+     */
+    static bool IsWhiteSpace(char c);
+
+    /**
+     * Splits the given path to drive and directory path parts.
+     * @param sourcePath Directory path to be splitted.
+     * @param drive Drive part of the given path, if any.
+     * @param path Directory path of the given path, if any.
+     */
+    static void SplitPath( const MifConvString& sourcePath, MifConvString& drive, MifConvString& path);
+
+    /**
+     * Compares two string. Ignores the case of the letters.
+     * @return zero if the strings are equal
+     * @param lhs Left hand side string
+     * @param rhs Right hand side string
+     */
+    static int CompareIgnoreCase( const MifConvString& lhs, const MifConvString& rhs );
+
+    /**
+     * Replaces all the charactes by lower case characters.
+     * @return String with lower case letters.
+     * @param str Input string
+     */
+    static MifConvString& ToLower( MifConvString& str );
+
+    /**
+     * Splits the given string using the given separator.
+     * @param str Input string
+     * @param separator The input string is splitted using this sub-string as a separator
+     * @param components List of the sub-strings splitted from the original input string
+     */
+    static void SplitString( const MifConvString& str, const MifConvString& separator, MifConvStringList& components );
+
+    /**
+     * Ensures that the given path exists. Tries to create it if it does not exist.
+     * @param destFileName Filename that is to be checked.
+     * @param ignoreLast If true, last part of the <code>destFileName</code> is stripped of 
+     * Directory separator used as a separator.
+     */
+    static void EnsurePathExists( const MifConvString& destFileName, bool ignoreLast = false );
+
+    /**
+     * Removes duplicated directory separators from the given string.
+     * @param str String from which the duplicated directory separators are to be searched and removed.
+     */
+    static void RemoveDuplicateDirSeparators( MifConvString& str );
+
+    /**
+     * Creates a directory with given path
+     * @return True if the directory was successfully created, false otherwise.
+     * @param path Directory path
+     */
+    static bool CreateDirectory( const MifConvString& path );
+
+    /**
+     * Trims the filename so that first letter is capitalized and others are lower case.
+     * @return Trimmed string
+     * @param filename Filename to be trimmed.
+     */
+    static MifConvString UnadornedFilename( const MifConvString& filename );
+
+    /**
+     * Finds the correct mask file for the bitmap file and sets it to the given object.
+     * @param srcFile Source file object.
+     */
+    static void FindAndSetBitmapMaskFile( MifConvSourceFile& srcFile );
+
+    /**
+     * Returns a unique temporary file name.
+     * @return Temporary file name string.
+     */
+    static MifConvString TemporaryFilename();
+
+    /**
+     * Copies a file 
+     * @return True if the copying was successful, false otherwise.
+     * @param from File which is to be copied from
+     * @param to Destination file.
+     */
+    static bool CopyFile(const MifConvString& from, const MifConvString& to);
+
+    /**
+     * Returns current working directory path.
+     * @return Current working directory path.
+     */
+    static MifConvString CurrentPath();
+
+    /**
+     * Changes the working directory
+     * @param dirName Working directory name
+     */
+    static void ChangeDirectory( const MifConvString& dirName );
+
+    /**
+     * Removes a directory
+     * @return Zero if the removal was successful, non-zero otherwise.
+     * @param dirName Directory name
+     */
+    static int RemoveDirectory( const MifConvString& dirName );
+
+    /**
+     * Removes a file
+     * @param fileName Filename
+     * @param maxTries Maximum number of file deletion times in case of failure.
+     * @param noException If true, no exception is thrown in case of failure. Warning is 
+     * printed in debug log. If false, <code>MifConvException</code> is thrown in case of failure.
+     */
+    static void RemoveFile( const MifConvString& fileName, int maxTries = 1, bool noException = false );
+            
+    /**
+     * Returns MifConv debug filename specified in MIFCONV_DEBUG_FILE
+     * @return Debug file name
+     */
+    static MifConvString DebugFile();
+
+    /**
+     * Logs string to debug file
+     * @param debugStr Debug string to be logged.
+     */
+    static void DebugLog(const MifConvString& debugStr);
+    
+    /**
+     * Returns default temp directory for intermediate and temporary files
+     * @return Temporary directory name
+     */
+    static const MifConvString& DefaultTempDirectory();
+
+private:
+    enum MifConvDebugMode
+    {
+        DebugMode_Unknown,
+        DebugMode_NoDebug,
+        DebugMode_Debug
+    };
+
+    static MifConvDebugMode iDebugMode;
+    static MifConvString iDebugFile;
+    static MifConvString iTempDirectory;
+};
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/makefile_templates/config/export.mk	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,28 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+# 
+# Description: makefile_templates, actual build configuration export makefile
+# 
+ 
+MAKEFILE =      /sf/mw/platformtools/gfxconversion/mifconv/makefile_templates/config/export.mk
+$(call push,MAKEFILE_STACK,$(MAKEFILE)) 
+
+ 
+TEMPLATEMAKEFILES =	/sf/mw/platformtools/gfxconversion/mifconv/makefile_templates/*.*			/epoc32/tools/makefile_templates/s60/
+
+template_makefiles :: template_makefiles_config
+         
+$(call addfiles, $(TEMPLATEMAKEFILES), template_makefiles_config) 
+         
+
+$(call popout,MAKEFILE_STACK) 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/makefile_templates/makefile	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+# 
+# Description: S60 makefile_templates level configuration makefile
+#
+
+ 
+MAKEFILE = /sf/mw/platformtools/gfxconversion/mifconv/makefile_templates/makefile
+
+ 
+# Place the first target as the default target which is executed from this level 
+
+export_template_files :: template_makefiles
+          
+include include_template.mk 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/makefile_templates/mifconv.flm	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,116 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+# 
+# Description:
+# 
+#
+
+# Check if $/ variable has been defined, if not, then it is always /
+ifeq ($(strip $(/)),)
+    /:=/
+endif
+
+# Replace \ with / in EPOCROOT
+EPOCROOT:=$(subst \,/,$(EPOCROOT))
+# Make sure that EPOCROOT ends in /
+EPOCROOT:=$(patsubst %/,%,$(EPOCROOT))/
+# Replace / with $/ in EPOCROOT
+EPOCROOT:=$(subst /,$/,$(EPOCROOT))
+
+# Important initialise
+RELEASEABLES:=
+
+ifeq ($(SBS_BUILD_DIR),)
+VECTORINTERMEDIATEDIR:=$(EPOCROOT)epoc32$/build$/s60$/icons$/$(notdir $(basename $(TARGETFILE)))
+else
+VECTORINTERMEDIATEDIR:=$(SBS_BUILD_DIR)$/s60$/icons$/$(notdir $(basename $(TARGETFILE)))
+endif
+
+include $(EPOCROOT)epoc32$/tools$/makefile_templates$/s60$/mifconv_global_options.make
+include $(EPOCROOT)epoc32$/tools$/makefile_templates$/s60$/mifconv_step1.make
+include $(EPOCROOT)epoc32$/tools$/makefile_templates$/s60$/mifconv_step2.make
+include $(EPOCROOT)epoc32$/tools$/makefile_templates$/s60$/mifconv_option_reader.make
+include $(EPOCROOT)epoc32$/tools$/makefile_templates$/s60$/mifconv_step3.make
+
+ifeq ($(OSTYPE),unix) 
+MIFCONV:=$(MIFCONV)
+SVGTBINENCODE:=$(SVGTBINENCODE)
+else 
+MIFCONV:=$(MIFCONV)$(DOTEXE)
+SVGTBINENCODE:=$(SVGTBINENCODE)$(DOTEXE)
+endif
+
+ifeq ($(strip $(MIFCONVDEBUG)),1)
+$(info <TOOLCAT toolcat='$(TOOLCAT)'/>)
+$(info <TOOLCOPY toolcopy='$(TOOLCOPY)'/>)
+$(info <TOOLMKDIR toolmkdir='$(TOOLMKDIR)'/>)
+$(info <MIFCONV mifconv='$(MIFCONV)'/>)
+endif
+
+ifeq ($(strip $(MIFCONVDEBUG)),1)
+$(warning MIFCONVOPTS $(MIFCONVOPTS))
+endif
+
+# The groupsvgin10 macro allows us to construct a command file, 10 
+# svgs/bmps objects at a time to avoid limits on argument lengths and 
+# sizes on Windows.
+define groupsvgin10
+	$(if $1,$(shell echo -e $(foreach L,$(wordlist 1,10,$1),"$(L)\\n") >>$(PARAMFILE)),)
+	$(if $1,$(call groupsvgin10,$(wordlist 11,$(words $1),$1)),true)
+endef
+
+define generatemif
+
+TARGET_$(TARGETFILE):=1
+MIFCONVOPTS:=$(MIFCONVOPTS)
+BITMAPS:=$(addsuffix .bmp,$(BITMAPBASESOURCES))
+
+BITMAP:: $(BITMAPFILE) $(TARGETFILE)
+
+ifeq ($(INIT_CFG),$(PLATFORM)$(CFG))
+ifneq ($(HEADERFILE),)
+$(HEADERFILE): $(TARGETFILE)
+endif
+endif
+
+ifneq ($(BITMAPFILE),)
+$(BITMAPFILE): $(TARGETFILE)
+endif
+
+
+$(if $(HEADERFILE),$(shell echo -e "-h$(HEADERFILE)\n-e\n" >$(PARAMFILE)), $(shell echo -e "-e\n" >$(PARAMFILE)) )
+$(if $(SOURCEDIR),$(shell echo -e "-i$(SOURCEDIR)\n" >>$(PARAMFILE)),)
+
+$(call groupsvgin10, $(MIFCONVOPTS))
+
+$(TARGETFILE): $(SVGBFILES) $(MIFCONV) $(SVGTBINENCODE) $(BMPFILES) $(MASKFILES)
+	$(call startrule,mifcompile,FORCESUCCESS) \
+	$(MIFCONV) $(TARGETFILE) -f$(PARAMFILE) \
+	$(call endrule,mifcompile)
+
+endef
+
+ifeq ($(TARGET_$(TARGETFILE)),)
+$(eval $(call generatemif))
+endif
+
+%-erase :
+	-$(GNURM) $*
+
+# FLM specific block begins
+CLEAN CLEANMAKEFILE :: $(addsuffix -erase,$(wildcard $(TARGETFILE) $(HEADERFILE) $(BITMAPFILE) $(PARAMFILE) $(patsubst %b,%,$(SVGBFILES)) $(SVGBFILES)))
+# FLM specific block ends
+
+# for the abld -what target 
+RELEASEABLES:=$(TARGETFILE) $(HEADERFILE) $(BITMAPFILE)
+$(eval $(call whatmacro,$(RELEASEABLES),WHATBITMAP))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/makefile_templates/mifconv.meta	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,21 @@
+# ============================================================================
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+# 
+# Description:
+# 
+#
+
+platform	win32
+makefile 	gnumake
+techstream	s60
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/makefile_templates/mifconv.mk	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,89 @@
+#
+# Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:  
+#
+
+# TEM specific block begins
+include $(EPOCROOT)epoc32/tools/shell/$(notdir $(basename $(SHELL))).mk
+# TEM specific block ends
+
+
+# Check if $/ variable has been defined, if not, then it is always /
+ifeq ($(strip $(/)),)
+    /:=/
+endif
+
+# Replace \ with / in EPOCROOT
+EPOCROOT:=$(subst \,/,$(EPOCROOT))
+# Make sure that EPOCROOT ends in /
+EPOCROOT:=$(patsubst %/,%,$(EPOCROOT))/
+# Replace / with $/ in EPOCROOT
+EPOCROOT:=$(subst /,$/,$(EPOCROOT))
+
+# Platform specific helper tools
+ifeq ($(TEMTARGET),)
+    TOOLCAT:=type
+    TOOLCOPY:=copy
+    TOOLMKDIR:=md
+else
+    TOOLCAT:=cat
+    TOOLCOPY:=cp
+    TOOLMKDIR:=mkdir -p
+endif
+
+VECTORINTERMEDIATEDIR:=$(EPOCROOT)epoc32$/build$/s60$/icons$/$(notdir $(basename $(TARGETFILE)))
+include $(EPOCROOT)epoc32$/tools$/makefile_templates$/s60$/mifconv_global_options.make
+include $(EPOCROOT)epoc32$/tools$/makefile_templates$/s60$/mifconv_step1.make
+
+
+# TEM specific block begins
+MAKMAKE : 
+
+WHATMAKEFILE \
+WHATRESOURCE : 
+	@echo $(TARGETFILE) 
+	@echo $(HEADERFILE)
+
+
+
+MAKMAKE \
+WHATMAKEFILE \
+BLD \
+SAVESPACE \
+LIB \
+FREEZE \
+RESOURCE \
+FINAL \
+RELEASABLES \
+ROMFILE  :
+# TEM specific block ends
+
+
+include $(EPOCROOT)epoc32$/tools$/makefile_templates$/s60$/mifconv_step2.make
+include $(EPOCROOT)epoc32$/tools$/makefile_templates$/s60$/mifconv_option_reader_recursive.make
+include $(EPOCROOT)epoc32$/tools$/makefile_templates$/s60$/mifconv_step3.make
+
+
+# TEM specific block begins
+MAKMAKE \
+RESOURCE : $(BITMAPFILE) $(TARGETFILE) $(HEADERFILE)
+# TEM specific block begins
+
+
+include $(EPOCROOT)epoc32$/tools$/makefile_templates$/s60$/mifconv_step4.make
+
+
+# TEM specific block begins
+CLEAN CLEANMAKEFILE : $(addsuffix -erase,$(wildcard $(TARGETFILE) $(HEADERFILE) $(BITMAPFILE) $(PARAMFILE) $(patsubst %b,%,$(SVGBFILES)) $(SVGBFILES)))
+# TEM specific block ends
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/makefile_templates/mifconv.xml	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+# 
+# Description:
+# 
+#
+-->
+
+<build xmlns="http://symbian.com/xml/build" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symbian.com/xml/build ../../schema/build/2_0.xsd">
+    <interface name="s60.mifconv" extends="Symbian.UserFLM" flm="mifconv.flm">
+
+    <!-- For debugging -->
+    <param name='MIFCONVDEBUG' default='0' />
+    
+    <!-- Tools -->
+    <param name='TOOLCAT' default="$(GNUCAT)"/>
+    <param name='TOOLCOPY' default="$(GNUCP)" />
+    <param name='TOOLMKDIR' default="$(GNUMKDIR) -p"/>
+        
+    <!-- Mifconv user defined variables (please notice use of default attribute) -->
+    <param name='TARGETFILE' default="" />
+    <param name='HEADERFILE' default="" />
+    <param name='SOURCES' default="" />
+    <param name='SOURCEFILE' default="" />
+    <param name='SOURCEDIR' default="" />
+    <param name='SVGENCODINGVERSION' default="" />
+    <param name='SBS_BUILD_DIR' default="" />
+    </interface>
+</build>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/makefile_templates/mifconv_global_options.make	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,49 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+# 
+# Description:
+# 
+
+# Check if $CFG variable has been defined, if not, then it is always udeb
+# This is needed because some build operations are not urel/udeb specific, but
+# Mifconv must always have one specific, because in WINSCW we need to know the
+# correct target directory
+ifeq ($(strip $(CFG)),)
+    CFG:=udeb
+endif
+
+# Parallel builds may cause 'overriding commands for target...' warnings.
+# This is caused by multiple configurations having same targets.
+# To avoid those warnings, let's take the initial configuration and build 
+# dependencies only for it.
+ifeq ($(strip $(INIT_CFG)),)
+	INIT_CFG:=$(PLATFORM)$(CFG)
+endif
+
+# Icon BMP bitmap depth mask additional name parts:
+MASK_OPTION_1:=_mask
+MASK_OPTION_8:=_mask_soft
+		
+# Binary conversion tools:
+SVGTBINENCODE:=$(EPOCROOT)epoc32$/tools$/svgtbinencode
+MIFCONV:=$(EPOCROOT)epoc32$/tools$/mifconv
+
+# SVG and BMP icon bitmap searching directories, depends on a platform:
+VECTORSOURCEDIR:=$(EPOCROOT)epoc32$/s60$/icons
+BITMAPSOURCEDIR:=$(EPOCROOT)epoc32$/s60$/bitmaps
+
+# Default target directories:
+WINS_TARGETDIR:=$(EPOCROOT)epoc32$/release$/wins$/$(CFG)$/z$/resource$/apps
+WINSCW_TARGETDIR:=$(EPOCROOT)epoc32$/release$/winscw$/$(CFG)$/z$/resource$/apps
+TARGETDIR:=$(EPOCROOT)epoc32$/data$/z$/resource$/apps
+HEADERDIR:=$(EPOCROOT)epoc32$/include
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/makefile_templates/mifconv_option_reader.make	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,121 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+# 
+# Description:
+# 
+
+
+# This file converts the input stored in $(OPTIONS) variable into several different variables
+# depending in the content.
+#
+# $(OPTIONS) variable is assumed to contain following syntax:
+# -X,Y filename.ext -X filename.ext
+#
+# where X and Y are numbers for the color depth.
+# The first number is the actual color depth of the file and the second is the color depth
+# of the mask file. The second number (and the comma) may or may not be defined.
+#
+# Since there are color depths defined for both the actual file and it's mask file, we need
+# to determine also the name of the mask file somehow. 
+# It is assumed that depending on the mask file color depth (Y) 
+# the mask file has a different string appended to it's file name.
+#
+# These mask file strings must be defined in the variable $(MASK_OPTION_Y) where Y is the 
+# mask file color depth.
+#
+#
+# Options will be splitted into variables of $(FILES) which contains the filenames after the
+# options and to OPTION_$(FILE) where $(FILE) is each of the $(FILES) and 
+# $(OPTION1_$(FILE)) and $(OPTION2_$(FILE)) depending whether the option for the file
+# was infact 2 options separated with comma or not.
+# 
+# Example: lets consider following variables are defined:
+#
+# MASK_OPTION_1=_mask
+# MASK_OPTION_8=_mask_soft
+# 
+# And that our input is:
+# OPTIONS=-c8,1 calc_paper -c8,8 display_side_l -c8 display_center
+#
+# The option reader would go through the $(OPTIONS) and fill out following variables:
+#
+# FILES=calc_paper display_side_l display_center
+#
+#
+# OPTION_calc_paper=-c8,2
+# OPTION1_calc_paper=-c8
+# OPTION2_calc_paper=2
+# OPTION1_calc_paper_mask=-2
+#
+# OPTION_display_side_l=-c8,8
+# OPTION1_display_side_l=-c8
+# OPTION2_display_side_l=8
+# OPTION1_calc_paper_mask_soft=-8
+#
+# OPTION1_display_center=-c8
+
+
+# Get files from the option list, i.e. everything that does not start with '-'
+FILES := $(foreach OPTION,\
+	$(OPTIONS),\
+	$(filter-out -%, $(OPTION)))
+#$(warning FILES $(FILES))
+
+
+# Option list without files
+OPTION_LIST_WITHOUT_FILES:=$(filter-out $(FILES), $(OPTIONS))
+#$(warning OPTION_LIST_WITHOUT_FILES $(OPTION_LIST_WITHOUT_FILES))
+
+
+# Strip out possible suffixes from all files
+FILES:=$(basename $(FILES))
+#$(warning FILES $(FILES))
+
+
+# Get options for each file, in the form of OPTION_$FILE
+$(foreach FILE,\
+	$(FILES),\
+	$(eval OPTION_$(FILE):=$(firstword $(OPTION_LIST_WITHOUT_FILES))) \
+	$(eval OPTION_LIST_WITHOUT_FILES:=$(wordlist 2, $(words $(OPTION_LIST_WITHOUT_FILES)), $(OPTION_LIST_WITHOUT_FILES))) \
+)
+
+
+# If option consists of anything like *X,Y separate the parts from comma
+# The part before the comma is in OPTION1_file, if no comma it is same as OPTION_file
+# The possible part after the comma is in OPTION2_file
+COMMA:=,
+$(foreach FILE,\
+	$(FILES),\
+	$(eval SPACE_OPTIONS:=$(subst $(COMMA), ,$(OPTION_$(FILE)))) \
+	$(eval OPTION1_$(FILE):=$(firstword $(SPACE_OPTIONS))) \
+	$(eval OPTION2_$(FILE):=$(word 2,$(SPACE_OPTIONS))) \
+)
+       
+
+# Generate mask files (from those files which had options after the comma)
+$(foreach FILE,\
+	$(FILES),\
+	$(eval $(FILE)_MASKFILE:=$(FILE)$(MASK_OPTION_$(OPTION2_$(FILE)))) \
+)
+
+
+# Filter out other than mask files
+MASKFILES:=$(filter %$(MASK_OPTION_1) %$(MASK_OPTION_8), $(foreach FILE, $(FILES), $($(FILE)_MASKFILE)))
+#$(warning MASKFILES $(MASKFILES))
+
+
+# Create options to mask files based on the option given after comma to the corresponding original file
+$(foreach MASKFILE,\
+	$(MASKFILES),\
+	$(eval OPTION1_$(MASKFILE):=-$(OPTION2_$(subst $(MASK_OPTION_1),,$(subst $(MASK_OPTION_8),,$(MASKFILE))))) \
+)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/makefile_templates/mifconv_option_reader_recursive.make	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,66 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+# 
+# Description:
+# 
+
+# This file converts the input stored in $(OPTIONS) variable into several different variables
+# depending in the content.
+#
+# $(OPTIONS) variable is assumed to contain following syntax:
+# -X,Y filename.ext -X filename.ext
+#
+# where X and Y are numbers for the color depth.
+# The first number is the actual color depth of the file and the second is the color depth
+# of the mask file. The second number (and the comma) may or may not be defined.
+#
+#
+# Options will be splitted into variables of $(FILES) which contains the filenames after the
+# options and to OPTION_$(FILE) where $(FILE) is each of the $(FILES)
+# 
+# Example: lets consider following variables are defined:
+#
+# 
+# And that our input is:
+# OPTIONS=-c8,1 calc_paper -c8,8 display_side_l -c8 display_center
+#
+# The option reader would go through the $(OPTIONS) and fill out following variables:
+#
+# FILES=calc_paper display_side_l display_center
+#
+# OPTION_calc_paper=-c8,2
+#
+# OPTION_display_side_l=-c8,8
+#
+# OPTION_display_center=-c8
+
+# File is the second word from the start, strip extension away just in case
+FILE:=$(basename $(word 2,$(OPTIONS)))
+#$(warning FILE $(FILE))
+
+# Set OPTION_file variable to the option preceding the file
+OPTION_$(FILE):=$(firstword $(OPTIONS))
+#$(warning OPTION_$(FILE) $(OPTION_$(FILE)))
+
+# Collect all the files 
+FILES:=$(FILES) $(FILE)
+
+# Shift away the 2 first variables from OPTIONS
+OPTIONS:=$(wordlist 3,$(words $(OPTIONS)),$(OPTIONS))
+#$(warning OPTIONS $(OPTIONS))
+
+ifneq ($(strip $(OPTIONS)),)
+  # Loop again
+  include $(EPOCROOT)epoc32$/tools$/makefile_templates$/s60$/mifconv_option_reader_recursive.make
+endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/makefile_templates/mifconv_step1.make	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,32 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+# 
+# Description:
+# 
+
+
+# Define location for the parameter file
+PARAMFILE=$(VECTORINTERMEDIATEDIR)$/mifconv-$(notdir $(TARGETFILE))-params.txt
+
+# Set file-extension to .mif
+TARGETFILE:=$(addsuffix .mif,$(basename $(TARGETFILE)))
+
+# Set default directory for TARGETFILE if no diretory set
+ifeq ($(strip $(dir $(TARGETFILE))),./)
+    TARGETFILE:=$(addprefix $(firstword $($(PLATFORM)_TARGETDIR) $(TARGETDIR))$/,$(TARGETFILE))
+endif
+
+# Set default directory for HEADERFILE if no directory set 
+ifeq ($(strip $(dir $(HEADERFILE))),./)
+    HEADERFILE:=$(addprefix $(HEADERDIR)$/,$(HEADERFILE))
+endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/makefile_templates/mifconv_step2.make	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,74 @@
+##
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+# 
+# Description:
+# 
+#
+
+
+# Handle issues related to SOURCEDIR
+ifneq ($(strip $(SOURCEDIR)),)
+    # Replace \ with / in SOURCEDIR
+    SOURCEDIR:=$(subst \,/,$(SOURCEDIR))
+    
+    # Replace / with $/ in SOURCEDIR
+    SOURCEDIR:=$(subst /,$/,$(SOURCEDIR))
+
+    # Insert EXTENSION_ROOT
+    SOURCEDIR:=$(EXTENSION_ROOT)$/$(SOURCEDIR)
+
+endif
+
+
+# Debug prints
+#$(warning PARAMFILE $(PARAMFILE))
+#$(warning VECTORSOURCEDIR $(VECTORSOURCEDIR))
+#$(warning VECTORINTERMEDIATEDIR $(VECTORINTERMEDIATEDIR))
+#$(warning BITMAPSOURCEDIR $(BITMAPSOURCEDIR))
+#$(warning WINS_TARGETDIR $(WINS_TARGETDIR))
+#$(warning WINSCW_TARGETDIR $(WINSCW_TARGETDIR))
+#$(warning TARGETDIR $(TARGETDIR))
+#$(warning HEADERDIR $(HEADERDIR))
+#$(warning SOURCEDIR $(SOURCEDIR))
+#$(warning TARGETFILE $(TARGETFILE))
+#$(warning HEADERFILE $(HEADERFILE))
+#$(warning SOURCES $(SOURCES))
+#$(warning SOURCEFILE $(SOURCEFILE))
+#$(warning SVGENCODINGVERSION $(SVGENCODINGVERSION))
+
+
+
+# Check that SOURCES and SOURCESFILE is not defined at the same time and at least one of them has been defined
+$(if $(SOURCES),$(if $(SOURCEFILE),$(error Must not define both SOURCES- and SOURCEFILE-parameters!),),$(if $(SOURCEFILE),,$(error Must define either SOURCES- or SOURCEFILE-parameter!)))
+
+# If SOURCES-parameter is not empty, then it is the OPTIONS
+ifneq ($(strip $(SOURCES)),)
+    OPTIONS:=$(SOURCES)
+endif
+
+# If SOURCEFILE-parameter is not empty 
+ifneq ($(strip $(SOURCEFILE)),)
+    # Replace \ with / in SOURCEFILE
+    SOURCEFILE:=$(subst \,/,$(SOURCEFILE))
+    
+    # Replace / with $/ in SOURCEFILE
+    SOURCEFILE:=$(subst /,$/,$(SOURCEFILE))
+
+    # Add each of the lines in the file to the OPTIONS
+    OPTIONS:=$(foreach LINE, \
+                $(shell $(TOOLCAT) $(EXTENSION_ROOT)$/$(SOURCEFILE)), \
+                $(LINE))
+endif
+
+# Change any leading '/' into '-' due to problems in make
+OPTIONS := $(patsubst /%,-%,$(OPTIONS))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/makefile_templates/mifconv_step3.make	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,170 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+# 
+# Description:
+# 
+#
+
+##########################################################################################
+# Get list of files
+#
+
+# First get SVG files from SOURCEDIR, then .bmp files from SOURCEDIR, then .svg from VECTORSOURCEDIR and finally .bmp from BITMAPSOURCEDIR
+SOURCEPATHS:=$(foreach FILE, \
+					$(basename $(FILES)), \
+					$(firstword $(wildcard $(SOURCEDIR)$/$(FILE).svg $(SOURCEDIR)$/$(FILE).bmp $(VECTORSOURCEDIR)$/$(FILE).svg) $(BITMAPSOURCEDIR)$/$(FILE).bmp))
+
+# Get a full list of SVG files
+SVGFILES:=$(filter %.svg,$(SOURCEPATHS))
+
+# Paths of SVGB files will be under the intermediate directory
+SVGBFILES:=$(addprefix $(VECTORINTERMEDIATEDIR)$/,$(notdir $(addsuffix b,$(SVGFILES))))
+
+# BMP files are all the other files
+BMPFILES:=$(filter-out $(SVGFILES),$(SOURCEPATHS))
+
+# Resolve mask files. Mask files are assumed to locate in the same folder than the actual bmp-file.
+MASKFILES:=$(foreach FILE, \
+                          $(BMPFILES), \
+                          $(FILE) $(foreach MASK, \
+                                            $(filter $(notdir $(basename $(FILE)))$(MASK_OPTION_1) $(notdir $(basename $(FILE)))$(MASK_OPTION_8),$(MASKFILES)), \
+                                            $(dir $(FILE))$(MASK).bmp) )
+
+# Filter out the actual bmp-files:
+MASKFILES:=$(filter-out $(BMPFILES), $(MASKFILES))
+
+
+##########################################################################################
+# Define copy rules
+#
+
+# If SOURCEDIR is defined, we need to create a rule for copying the vector files into the intermediate directory
+ifneq ($(strip $(SOURCEDIR)),)
+
+	# Create list of files
+	USERSVGFILES:=$(filter $(SOURCEDIR)%,$(SVGFILES))
+	USERBMPFILES:=$(filter $(SOURCEDIR)%,$(BMPFILES))
+	USERINTERMEDIATESVGFILES := $(subst $(SOURCEDIR), \
+										$(VECTORINTERMEDIATEDIR), \
+										$(USERSVGFILES) \
+								)
+
+	# Now define the copy rule
+ifeq ($(INIT_CFG),$(PLATFORM)$(CFG))
+    $(USERINTERMEDIATESVGFILES) : $(VECTORINTERMEDIATEDIR)% : $(SOURCEDIR)%
+	$(TOOLCOPY) $< $@
+ifeq ($(OSTYPE),cygwin)
+	$(GNUCHMOD) a+rw "$@"
+endif
+endif
+endif 
+
+
+# The same copy rule is needed for system files as well, first generate the lists
+SYSTEMSVGFILES:=$(filter $(VECTORSOURCEDIR)%,$(SVGFILES))
+SYSTEMBMPFILES:=$(filter $(BITMAPSOURCEDIR)%,$(BMPFILES))
+SYSTEMINTERMEDIATESVGFILES := $(subst $(VECTORSOURCEDIR), \
+									$(VECTORINTERMEDIATEDIR), \
+									$(SYSTEMSVGFILES) \
+								)
+
+# And finally define the copy rule
+ifeq ($(INIT_CFG),$(PLATFORM)$(CFG))
+$(SYSTEMINTERMEDIATESVGFILES) : $(VECTORINTERMEDIATEDIR)% : $(VECTORSOURCEDIR)% 
+	$(TOOLCOPY) $< $@	
+ifeq ($(OSTYPE),cygwin)
+	$(GNUCHMOD) a+rw "$@"
+endif
+endif
+
+# Get full list of intermediate files
+VECTORINTERMEDIATESOURCES := $(SYSTEMINTERMEDIATESVGFILES) $(USERINTERMEDIATESVGFILES)
+
+
+
+# Debug prints for debugging purposes
+#$(warning SOURCEPATHS $(SOURCEPATHS))
+#$(warning SVGFILES $(SVGFILES))
+#$(warning SVGBFILES $(SVGBFILES))
+#$(warning BMPFILES $(BMPFILES))
+#$(warning USERSVGFILES $(USERSVGFILES))
+#$(warning USERBMPFILES $(USERBMPFILES))
+#$(warning USERINTERMEDIATESVGFILES $(USERINTERMEDIATESVGFILES))
+#$(warning SYSTEMSVGFILES $(SYSTEMSVGFILES))
+#$(warning SYSTEMBMPFILES $(SYSTEMBMPFILES))
+#$(warning SYSTEMINTERMEDIATESVGFILES $(SYSTEMINTERMEDIATESVGFILES))
+#$(warning VECTORINTERMEDIATESOURCES $(VECTORINTERMEDIATESOURCES))
+
+
+
+##########################################################################################
+# Rules for creating directories
+#
+# Please note that this implementation assumes that Mifconv core takes care of creating
+# directories for files which it generates
+#
+
+# Check if the intermediate directory exists - if not, create it
+ifeq ($(wildcard $(VECTORINTERMEDIATEDIR)$/),) 
+	__DUMMY_MKDIR := $(shell $(TOOLMKDIR) $(VECTORINTERMEDIATEDIR)) 
+endif
+
+
+
+##########################################################################################
+# Rule for calling SVGTBINENCODE ie SVG to SVGB conversion
+#
+
+%.svgb : %.svg
+# If SVGENCODINGVERSION contains anything else but whitespace, provide it to svgtbinencode with -v option
+	$(SVGTBINENCODE) $(addprefix -v ,$(SVGENCODINGVERSION)) $<
+
+
+
+##########################################################################################
+# MBM file name resolution. BMCONV is called by mifconv.
+#
+
+# Check if we have any bitmap sources available
+ifneq ($(strip $(BMPFILES)),)
+    
+    # The name of the bitmap file is decided from the miffile or header file depending which one is defined
+    BITMAPFILE:=$(addsuffix .mbm,$(basename $(firstword $(TARGETFILE) $(HEADERFILE))))
+    #$(warning BITMAPFILE $(BITMAPFILE))
+
+# No bitmap sources, so the filename of the MBM file is empty 
+else
+    BITMAPFILE:=
+endif 
+
+##########################################################################################
+# This may require some explaining
+# Line 5: Strip paths from SOURCEPATHS (the input files with paths)
+# Line 3: For all .svg files in previous, change suffix to .svgb
+# Line 2: From previous, list each item twice, once with VECTORINTERMEDIATEDIR path, and once without any path
+#            Now we should have all the files in correct order in format:
+#            file.bmp VECTORINTERMEDIATEDIR/file.bmp otherfile.svgb VECTORINTERMEDIATEDIR/otherfile.svgb ...
+# Line 1: Use filter to select only one or either from the list above
+
+MIFCONVFILES:=$(filter $(SVGBFILES) $(notdir $(BMPFILES)), \
+                 $(foreach FILE, \
+                                     $(patsubst %.svg, \
+                                     %.svgb,\
+                                     $(notdir $(SOURCEPATHS)) \
+                  ) , \
+                  $(FILE) $(VECTORINTERMEDIATEDIR)$/$(FILE) \
+                  ) \
+               )
+
+MIFCONVOPTS:=$(foreach FILE,$(MIFCONVFILES),$(OPTION_$(notdir $(basename $(FILE)))) $(FILE))
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/makefile_templates/mifconv_step4.make	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,107 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+# 
+# Description:
+# 
+#
+
+# Generation of TARGETFILE, BITMAPFILE or HEADERFILE is depending on *.svgb and *.bmp files
+$(TARGETFILE) $(BITMAPFILE) $(HEADERFILE) : MIFCONVOPTS:=$(MIFCONVOPTS)
+$(TARGETFILE) $(BITMAPFILE) $(HEADERFILE) : BITMAPS:=$(addsuffix .bmp,$(BITMAPBASESOURCES))
+$(TARGETFILE) $(BITMAPFILE) $(HEADERFILE) : TARGETFILE:=$(TARGETFILE)
+$(TARGETFILE) $(BITMAPFILE) $(HEADERFILE) : HEADERFILE:=$(HEADERFILE)
+$(TARGETFILE) $(BITMAPFILE) $(HEADERFILE) : PARAMFILE:=$(PARAMFILE)
+$(TARGETFILE) $(BITMAPFILE) $(HEADERFILE) : $(SVGBFILES) $(BMPFILES)
+    # Set the prefix for header 
+    # Pick only input files matching *.svgb (created directory may also appear in the input)
+    # And set the colordepth options
+ifneq ($(strip $(HEADERFILE)),)
+	echo $(addprefix -h,$(HEADERFILE))  > $(PARAMFILE)
+	echo $(wordlist 1,100,$(MIFCONVOPTS)) >> $(PARAMFILE)
+else
+	echo $(wordlist 1,100,$(MIFCONVOPTS)) > $(PARAMFILE)
+endif
+
+ifneq ($(strip $(wordlist 101,200,$(MIFCONVOPTS))),)
+	echo $(wordlist 101,200,$(MIFCONVOPTS)) >> $(PARAMFILE)
+endif
+
+ifneq ($(strip $(wordlist 201,300,$(MIFCONVOPTS))),)
+	echo $(wordlist 201,300,$(MIFCONVOPTS)) >> $(PARAMFILE)
+endif
+
+ifneq ($(strip $(wordlist 301,400,$(MIFCONVOPTS))),)
+	echo $(wordlist 301,400,$(MIFCONVOPTS)) >> $(PARAMFILE)
+endif
+
+ifneq ($(strip $(wordlist 401,500,$(MIFCONVOPTS))),)
+	echo $(wordlist 401,500,$(MIFCONVOPTS)) >> $(PARAMFILE)
+endif
+
+ifneq ($(strip $(wordlist 501,600,$(MIFCONVOPTS))),)
+	echo $(wordlist 501,600,$(MIFCONVOPTS)) >> $(PARAMFILE)
+endif
+
+ifneq ($(strip $(wordlist 601,700,$(MIFCONVOPTS))),)
+	echo $(wordlist 601,700,$(MIFCONVOPTS)) >> $(PARAMFILE)
+endif
+
+ifneq ($(strip $(wordlist 701,800,$(MIFCONVOPTS))),)
+	echo $(wordlist 701,800,$(MIFCONVOPTS)) >> $(PARAMFILE)
+endif
+
+ifneq ($(strip $(wordlist 801,900,$(MIFCONVOPTS))),)
+	echo $(wordlist 801,900,$(MIFCONVOPTS)) >> $(PARAMFILE)
+endif
+
+ifneq ($(strip $(wordlist 901,1000,$(MIFCONVOPTS))),)
+	echo $(wordlist 901,1000,$(MIFCONVOPTS)) >> $(PARAMFILE)
+endif
+
+ifneq ($(strip $(wordlist 1001,1100,$(MIFCONVOPTS))),)
+	echo $(wordlist 1001,1100,$(MIFCONVOPTS)) >> $(PARAMFILE)
+endif
+
+ifneq ($(strip $(wordlist 1101,1200,$(MIFCONVOPTS))),)
+	echo $(wordlist 1101,1200,$(MIFCONVOPTS)) >> $(PARAMFILE)
+endif
+
+ifneq ($(strip $(wordlist 1201,1300,$(MIFCONVOPTS))),)
+	echo $(wordlist 1201,1300,$(MIFCONVOPTS)) >> $(PARAMFILE)
+endif
+
+ifneq ($(strip $(wordlist 1301,1400,$(MIFCONVOPTS))),)
+	echo $(wordlist 1301,1400,$(MIFCONVOPTS)) >> $(PARAMFILE)
+endif
+
+ifneq ($(strip $(wordlist 1401,1500,$(MIFCONVOPTS))),)
+	echo $(wordlist 1401,1500,$(MIFCONVOPTS)) >> $(PARAMFILE)
+endif
+
+ifneq ($(strip $(wordlist 1501,1600,$(MIFCONVOPTS))),)
+	echo $(wordlist 1501,1600,$(MIFCONVOPTS)) >> $(PARAMFILE)
+endif
+
+
+
+# Execute Mifconv with the parameter list 
+ifneq ($(strip $(SOURCEDIR)),)
+	$(MIFCONV) $(TARGETFILE) -i$(SOURCEDIR) -e -f$(PARAMFILE)
+else
+	$(MIFCONV) $(TARGETFILE) -e -f$(PARAMFILE)
+endif
+
+
+
+%-erase :
+	-$(RM) $*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/src/mifconv.cpp	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mifconv main.
+*
+*/
+
+
+#include "mifconv.h"
+#include "mifconv_exception.h"
+#include "mifconv_argumentmanager.h"
+#include "mifconv_convertermanager.h"
+#include "mifconv_util.h"
+
+int main( int argc, char *argv[] )
+{    
+    cout << endl << "Mifconv v" << MifConvVersion << " - " << MifConvDate << endl;
+	// Instantiate the argument manager and mif creator:
+    MifConvArgumentManager* argMgr = MifConvArgumentManager::Instance();
+    MifConvConverterManager* converterMgr = MifConvConverterManager::Instance();
+
+	try {
+		// Read arguments to string vector:
+		MifConvStringList strList;
+		for( int i = 1; i < argc; ++i )
+		{            
+			strList.push_back(MifConvString(argv[i]));
+		}
+
+		// Initialize arguments:
+		argMgr->Init(strList);
+
+        // Initialize converters:
+        converterMgr->Init();
+
+		// Run converters for source files:
+		converterMgr->ProcessIcons();
+		
+		// Cleanup temp files etc:
+		converterMgr->Cleanup();
+	}
+	catch( MifConvException& e ) {
+		// In case of error, print exception to stderr, cleanup temp files and exit:
+        std::stringstream strForInt;
+        strForInt << e.Line();
+
+        MifConvUtil::DebugLog(e.File() + MifConvString(":") + strForInt.str() + MifConvString(":") + e.String());
+		cerr << e.String() << endl;
+		converterMgr->Cleanup(true);
+        converterMgr->Reset();
+        argMgr->Reset();
+		exit(MIFCONV_ERROR);
+	}
+	catch(...)
+	{
+		// Unknown error:
+        MifConvUtil::DebugLog("MifConv: Unknown error");
+		cerr << "MifConv: Unknown error" << endl;
+		converterMgr->Cleanup(true);
+        converterMgr->Reset();
+        argMgr->Reset();
+		exit(MIFCONV_ERROR);
+	}
+    
+    converterMgr->Reset();
+    argMgr->Reset();
+	return MIFCONV_NO_ERROR;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/src/mifconv_argument.cpp	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,20 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mifconv tool argument definitions.
+*
+*/
+
+
+#include "mifconv.h"
+#include "mifconv_argument.h"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/src/mifconv_argumentmanager.cpp	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,991 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mifconv argument manager class.
+*
+*/
+
+
+#include "mifconv.h"
+#include "mifconv_argumentmanager.h"
+#include "mifconv_exception.h"
+#include "mifconv_util.h"
+
+// Static singleton initialization
+MifConvArgumentManager* MifConvArgumentManager::iInstance = 0;
+
+/**
+ * Returns pointer to the singleton object
+ */
+MifConvArgumentManager* MifConvArgumentManager::Instance()
+{
+    if( iInstance == 0 )
+    {
+        iInstance = new MifConvArgumentManager();
+    }
+    return iInstance;
+}
+
+/**
+ * Free the allocated memory
+ */
+void MifConvArgumentManager::Reset()
+{
+    delete iInstance;
+    iInstance = 0;
+}
+
+/**
+ *
+ */
+inline void MifConvArgumentManager::THROW_USAGE_EXCEPTION() const
+{
+	MifConvString usageStr;
+	SetUsageString(usageStr);
+	throw MifConvException(usageStr, MifConvString(__FILE__), __LINE__);
+}
+
+inline void MifConvArgumentManager::THROW_ERROR( const MifConvString& errorMsg, const MifConvString& file, int line ) const
+{    
+    throw MifConvException( MifConvString("ERROR: " + errorMsg + "\nType mifconv -? for help\n"), file, line);
+}
+
+/**
+ *
+ */
+MifConvArgumentManager::MifConvArgumentManager()
+:
+iEpocRoot(DEFAULT_EPOCROOT)
+{
+    GetMifEnv();
+}
+
+/**
+ *
+ */
+MifConvArgumentManager::~MifConvArgumentManager()
+{}
+
+/**
+ * This function checks if the given argument is boolean type of argument.
+ * Boolean type arguments are listed in a <code>MifConvBooleanArguments</code> table
+ * and this function checks if the given string matches any of those. Returns the length
+ * of the argument name if found, zero otherwise.
+ */
+size_t MifConvArgumentManager::IsBooleanArgument( const MifConvString& argName ) const
+{
+	if( IsArgument(argName) )
+	{
+		try {
+			int tblSize = sizeof(MifConvBooleanArguments) / sizeof(MifConvString);
+			for( int i = 0; i < tblSize; ++i )
+			{
+				size_t tmpLen = MifConvBooleanArguments[i].length();
+				if( argName.length() > tmpLen )
+				{
+                    if( MifConvUtil::CompareIgnoreCase(MifConvString(argName.begin()+1, argName.begin() + 1 + tmpLen), MifConvBooleanArguments[i]) == 0 )
+					{
+						return tmpLen;
+					}
+				}
+			}
+		}
+		catch(...)
+		{
+			THROW_USAGE_EXCEPTION();
+		}
+	}
+	return 0;
+}
+
+/**
+ * This function checks if the given argument is a help argument.
+ * Help arguments are listed in a <code>MifConvHelpArguments</code> table
+ * and this function checks if the given string matches any of those. Returns the length
+ * of the argument name if found, zero otherwise.
+ */
+size_t MifConvArgumentManager::IsHelpArgument( const MifConvString& argName ) const
+{
+	if( IsArgument(argName) )
+	{
+		try {
+			int tblSize = sizeof(MifConvHelpArguments) / sizeof(MifConvString);
+			for( int i = 0; i < tblSize; ++i )
+			{
+				size_t tmpLen = MifConvHelpArguments[i].length();
+
+                // Following check separates -H from -Hheadername.mbg parameter:
+                if( argName.length() == tmpLen+1 )
+				{
+                    if( MifConvUtil::CompareIgnoreCase(MifConvString(argName.begin()+1, argName.begin() + 1 + tmpLen), MifConvHelpArguments[i]) == 0 )
+					{
+						return tmpLen;
+					}
+				}
+			}
+		}
+		catch(...)
+		{
+			THROW_USAGE_EXCEPTION();
+		}
+	}
+	return 0;
+}
+
+/**
+ * This function checks if the given argument is string type of argument.
+ * String type arguments are listed in a <code>MifConvStringArguments</code> table
+ * and this function checks if the given string matches any of those. Returns the length
+ * of the argument name if found, zero otherwise.
+ */
+size_t MifConvArgumentManager::IsStringArgument( const MifConvString& argName ) const
+{    
+	if( IsArgument(argName) )
+	{
+		try {
+			int tblSize = sizeof(MifConvStringArguments) / sizeof(MifConvString);
+			for( int i = 0; i < tblSize; ++i )
+			{
+				size_t tmpLen = MifConvStringArguments[i].length();
+				if( argName.length() > tmpLen )
+				{
+                    if( MifConvUtil::CompareIgnoreCase(MifConvString(argName.begin()+1, argName.begin()+1+tmpLen), MifConvStringArguments[i]) == 0 )
+					{
+						return tmpLen;
+					}
+				}				
+			}
+		}
+		catch(...)
+		{
+			THROW_USAGE_EXCEPTION();
+		}
+	}
+	return 0;
+}
+
+/**
+ * This function checks if the given argument is string list type of argument.
+ * String list type arguments are listed in a <code>MifConvStringListArguments</code> table
+ * and this function checks if the given string matches any of those. Returns the length
+ * of the argument name if found, zero otherwise.
+ */
+size_t MifConvArgumentManager::IsStringListArgument( const MifConvString& argName ) const
+{
+	if( IsArgument(argName) )
+	{
+		try {
+			int tblSize = sizeof(MifConvStringListArguments) / sizeof(MifConvString);
+			for( int i = 0; i < tblSize; ++i )
+			{
+				size_t tmpLen = MifConvStringListArguments[i].length();
+				if( argName.length() > tmpLen )
+				{
+                    if( MifConvUtil::CompareIgnoreCase(MifConvString(argName.begin()+1, argName.begin()+1+tmpLen), MifConvStringListArguments[i]) == 0 )
+					{
+						return tmpLen;
+					}
+				}				
+			}
+		}
+		catch(...)
+		{
+			THROW_USAGE_EXCEPTION();
+		}
+	}
+	return 0;
+}
+
+/**
+ *
+ */
+bool MifConvArgumentManager::IsDepthArgument( const MifConvString& argName ) const
+{
+	if( IsArgument(argName) )
+	{
+		try {
+			int tblSize = sizeof(MifConvDepthArguments) / sizeof(MifConvString);
+			for( int i = 0; i < tblSize; ++i )
+			{
+				size_t tmpLen = MifConvDepthArguments[i].length();
+                if( argName.length() > tmpLen )
+				{
+                    MifConvString trimmedArgument(argName.begin()+1, argName.begin() + 1 + tmpLen);                
+                    if( MifConvUtil::CompareIgnoreCase(trimmedArgument, MifConvDepthArguments[i]) == 0 )
+					{
+						return true;
+					}                    
+				}
+			}
+		}
+		catch(...)
+		{
+			THROW_USAGE_EXCEPTION();
+		}
+	}
+	return false;
+}
+
+/**
+ *
+ */
+bool MifConvArgumentManager::IsAnimatedFlag( const MifConvString& argName ) const
+{
+	return IsArgument( argName ) && argName.length() > MifConvAnimatedIconArg.length() && 
+        MifConvUtil::CompareIgnoreCase(MifConvString(argName.begin()+1, argName.end() ), MifConvAnimatedIconArg ) == 0;
+}
+
+/**
+ *
+ */
+void MifConvArgumentManager::SetTargetFile( const MifConvString& arg )
+{
+	iTargetFile = arg;
+}
+
+/**
+ *
+ */
+const MifConvString& MifConvArgumentManager::TargetFile() const
+{
+	return iTargetFile;
+}
+
+/**
+ *
+ */
+IconDisplayMode MifConvArgumentManager::ConvertToDisplayMode(IconDepth depth) const
+{
+    MifConvIconDisplayModeMap::const_iterator i = iDisplayModeMap.find(depth);
+    if( i != iDisplayModeMap.end() )
+        return i->second;
+
+    return DisplayMode_None;    
+}
+
+/**
+ *
+ */
+IconDisplayMode MifConvArgumentManager::ConvertToMaskDisplayMode(IconMaskDepth depth) const
+{
+    MifConvMaskIconDisplayModeMap::const_iterator i = iMaskDisplayModeMap.find(depth);
+    if( i != iMaskDisplayModeMap.end() )
+        return i->second;
+
+    return DisplayMode_None;    
+}
+
+/**
+ *
+ */
+IconDepth MifConvArgumentManager::ConvertToDepth( const MifConvString& depthStr ) const
+{
+    MifConvIconDepthMap::const_iterator i = iDepthMap.find(depthStr);
+    if( i != iDepthMap.end() )
+        return i->second;
+
+    return IconDepth_Undefined;    
+}
+/**
+ *
+ */
+IconMaskDepth MifConvArgumentManager::ConvertToMaskDepth( const MifConvString depthStr ) const
+{
+    MifConvIconMaskDepthMap::const_iterator i = iMaskDepthMap.find(depthStr);
+    if( i != iMaskDepthMap.end() )
+        return i->second;
+
+    return IconMaskDepth_Undefined;    
+}
+
+/**
+ *
+ */
+void MifConvArgumentManager::Init( const MifConvStringList& argList )
+{	    
+    // Build maps for mapping depth, mask and displaymode constants:
+    PopulateDepthAndMaskMaps();
+    // Allocate search paths where to search source files:    
+    MifConvString epocRoot(EpocRoot());
+         
+    // Global icons folder can contain only .svg files:
+    iSearchRules.push_back(MifConvSourceSearchRule(MifConvString(epocRoot + S60_ICONS_PATH), vector<MifConvString>(1, SVG_FILE_EXTENSION)));
+    // Global bitmaps folder can contain only .bmp files:
+    iSearchRules.push_back(MifConvSourceSearchRule(MifConvString(epocRoot + S60_BITMAPS_PATH), vector<MifConvString>(1, BMP_FILE_EXTENSION)));
+    // EPOCROOT, if given in environment variables:
+    if( epocRoot.length() > 0 )
+    {
+        iSearchRules.push_back(MifConvSourceSearchRule(epocRoot+EPOC32_PATH, vector<MifConvString>(1, MIFCONV_WILDCARD)));
+    }
+
+    AddArguments(argList);
+
+    // check if the parameter file is given:
+    const MifConvString& paramFilename = StringValue(MifConvParameterFileArg);
+    if( paramFilename.length() > 0 )
+    {
+        // Add arguments from the parameter file:
+        MifConvStringList paramListFromFile;
+        ReadParameterFile( paramFilename, paramListFromFile );
+        if( paramListFromFile.size() > 0 )
+        {
+            AddArguments(paramListFromFile, true);
+        }
+    }
+    // Resolve file type extensions using given flags and investigating the existing files:
+	FinalizeArguments();
+}
+
+/**
+ * Read string argument value:
+ */
+MifConvString MifConvArgumentManager::ReadStringArgument(const MifConvStringList& argList, MifConvStringList::const_iterator& i, unsigned int argNameLen)
+{    
+    // Take the actual argument value, for example /TmyTempDir --> myTempDir    
+    MifConvString argValue((*i).begin() + argNameLen, (*i).end());
+    if( argValue.length() > 0 )
+    {
+        // String arguments can have spaces when they are enclosed with " marks (For example directory names).
+        if( argValue[0] == '\"' )
+        {
+            MifConvString quotedArgValue(argValue);
+            // Check if the last char is also ":
+            if( quotedArgValue[ quotedArgValue.length()-1 ] == '\"' )
+            {                
+                return quotedArgValue;
+            }
+
+            // See if the next string ends with \" mark, for example "My Folder" is presented with following argument list:
+            // argList[0] = "My
+            // argList[1] = Folder"
+            while(++i != argList.end())
+            {
+                MifConvString nextString((*i).begin(), (*i).end());
+                quotedArgValue += " " + nextString;
+                if( nextString[ nextString.length()-1 ] == '\"' )
+                {                    
+                    return "\"" + quotedArgValue + "\"";
+                }
+            }
+        }
+    }    
+    return argValue;
+}
+
+/**
+ * Read string argument value:
+ */
+void MifConvArgumentManager::ReadStringListArgument(MifConvStringList::const_iterator& i, unsigned int argNameLen, MifConvStringList& StringValueList)
+{    
+    // Take the actual argument value, for example /imyInputDir;myTempDir --> myTempDir    
+    MifConvString argValue((*i).begin() + argNameLen, (*i).end());    
+    MifConvUtil::SplitString( argValue, STRING_LIST_ARGUMENT_SEPARATOR, StringValueList );
+}
+
+/**
+ *
+ */
+void MifConvArgumentManager::AddArguments( const MifConvStringList& argList, bool paramsFromFile )
+{
+	MifConvStringList::const_iterator i = argList.begin();
+
+	if( i == argList.end() )
+	{		
+        THROW_ERROR("No arguments", MifConvString(__FILE__), __LINE__);	
+	}
+
+    // Check if help is needed:
+    while( i != argList.end() )
+    {
+        if( IsHelpArgument(*i) )
+        {
+            THROW_USAGE_EXCEPTION();
+        }
+        ++i;
+    }
+
+    i = argList.begin();
+
+	while( i != argList.end() )
+	{	        
+		unsigned int argLen = 0;
+		if( i == argList.begin() && paramsFromFile == false )
+		{
+			// First command line argument must be the target file.
+            // If the given list (argList) is read from the file, then
+            // the first one is not target file.
+			if( !IsArgument(*i) )
+			{           
+			    MifConvString targetFile(ReadStringArgument( argList, i, 0 ));			    
+			    // Make sure that the file extension is .mif:
+			    targetFile = MifConvUtil::FilenameWithoutExtension(targetFile);
+			    targetFile += MifConvString(FILE_EXTENSION_SEPARATOR) + MifConvString(MIF_FILE_EXTENSION);
+				SetTargetFile(targetFile);                
+			}
+			else
+			{
+                THROW_ERROR( "Target file must be given as first argument.", MifConvString(__FILE__), __LINE__ );                
+			}
+			++i;
+            if( i == argList.end() )
+            {
+                THROW_ERROR("Missing arguments", MifConvString(__FILE__), __LINE__);
+            }
+		}
+		else if( IsBooleanArgument(*i) )
+		{
+			// Insert boolean type argument to the boolean arguments list:
+			MifConvString argName((*i).begin()+1, (*i).end());
+            MifConvUtil::ToLower(argName); // Lower the cases to make comparison easier later
+            std::pair<BooleanArgMap::iterator, bool> res = iBooleanArguments.insert(std::make_pair<MifConvString, MifConvBooleanArgument>(
+				argName, MifConvBooleanArgument( argName, true )));
+            if( res.second == false )
+            {
+                // parameter already exists in the map, update the value:
+                res.first->second = MifConvBooleanArgument( argName, true );
+            }
+			++i;
+		}
+		else if( (argLen = (unsigned int) IsStringArgument(*i) ) > 0 )
+		{			
+			MifConvString argName((*i).begin()+1, (*i).begin() + 1 + argLen);
+            MifConvUtil::ToLower(argName); // Lower the cases to make comparison easier later			
+            MifConvString argValue(ReadStringArgument( argList, i, argLen+1 ));            
+			if( argValue.length() == 0 )
+			{
+				// Do not accept string arguments with zero length (E.g. "/H")
+                THROW_ERROR( "Missing argument value for " + *i, MifConvString(__FILE__), __LINE__ );                
+			}
+			// Insert string type argument to the string arguments list:
+			std::pair<StringArgMap::iterator, bool> res = iStringArguments.insert(std::make_pair<MifConvString, MifConvStringArgument>(
+				argName, MifConvStringArgument( argName, argValue )));
+            if( res.second == false )
+            {
+                // parameter already exists in the map, update the value:
+                res.first->second = MifConvStringArgument( argName, argValue );
+            }
+			++i;
+		}
+        else if( (argLen = (unsigned int) IsStringListArgument(*i)) > 0 )
+        {
+            MifConvString argName((*i).begin()+1, (*i).begin() + 1 + argLen);
+            MifConvUtil::ToLower(argName); // Lower the cases to make comparison easier later			
+            MifConvStringList argValue;
+            ReadStringListArgument( i, argLen+1, argValue );
+
+            if( argValue.size() == 0 )
+			{
+				// Do not accept string arguments with zero length (E.g. "/H")
+                THROW_ERROR( "Missing argument value for " + *i, MifConvString(__FILE__), __LINE__ );                
+			}
+			// Insert string list type argument to the string arguments list:
+			std::pair<StringListArgMap::iterator, bool> res = iStringListArguments.insert(std::make_pair<MifConvString, MifConvStringListArgument>(
+				argName, MifConvStringListArgument( argName, argValue )));
+            if( res.second == false )
+            {
+                // parameter already exists in the map, update the value:
+                res.first->second = MifConvStringListArgument( argName, argValue );
+            }
+			++i;
+        }
+		else if( IsDepthArgument(*i) )
+		{
+			// Let's build source file argument...
+			// ... first is depth and mask:
+			MifConvString depthAndMask(*i);
+            MifConvUtil::ToLower(depthAndMask); // Lower the cases to make comparison easier later
+			++i;
+            // Check that there is still an argument:
+            if( i == argList.end() )
+            {
+                THROW_ERROR( "Missing source file argument.", MifConvString(__FILE__), __LINE__ );                
+            }
+
+			// Then we check if animated flag is given next:
+			bool isAnimated = IsAnimatedFlag(*i);
+
+			if( isAnimated )
+			{
+				// This was an animated flag, so next must be filename:
+				++i;
+                // Check that there is still an argument:
+                if( i == argList.end() )
+                {
+                    THROW_ERROR( "Missing source file argument.", MifConvString(__FILE__), __LINE__ );
+                    //THROW_USAGE_EXCEPTION();
+                }
+			}
+			
+			// One more check... Check that the next string is not an argument (starting with '-' or '/')
+			// It should be a filename for the source icon.
+			if( IsArgument(*i) )
+			{
+                THROW_ERROR( "Missing source file argument.", MifConvString(__FILE__), __LINE__ );                
+			}
+
+            MifConvSourceFile srcFile;
+            srcFile.SetDepthAndMask(depthAndMask);
+            srcFile.SetDisplayMode(ConvertToDisplayMode(srcFile.Depth()));
+            srcFile.SetMaskDisplayMode(ConvertToMaskDisplayMode(srcFile.MaskDepth()));
+            srcFile.SetFilename(ReadStringArgument( argList, i, 0 ));
+            srcFile.SetAnimated(isAnimated);
+            iSourceFiles.push_back(srcFile);			
+			++i;
+		}
+		else if( IsAnimatedFlag(*i) )
+		{
+			// Icon animated flag found
+			// Let's see if the next is depth argument:
+			++i;
+			MifConvString depthAndMask;
+			if( IsDepthArgument(*i) )
+			{
+				depthAndMask = *i;
+                MifConvUtil::ToLower(depthAndMask);
+				++i;
+			}
+
+			// One more check... Check that the next string is not an argument (starting with '-' or '/')
+			if( IsArgument(*i) )
+			{
+                THROW_ERROR( "Missing source file argument.", MifConvString(__FILE__), __LINE__ );                
+			}
+
+            MifConvSourceFile srcFile;
+            srcFile.SetDepthAndMask(depthAndMask);
+            srcFile.SetDisplayMode(ConvertToDisplayMode(srcFile.Depth()));
+            srcFile.SetMaskDisplayMode(ConvertToMaskDisplayMode(srcFile.MaskDepth()));
+            srcFile.SetFilename(*i);
+            srcFile.SetAnimated(true);
+            iSourceFiles.push_back(srcFile);
+			++i;
+		}
+		else
+		{
+            THROW_ERROR( "Invalid argument: " + *i, MifConvString(__FILE__), __LINE__ );            
+        }
+	}
+}
+
+/**
+ * Resolves correct type for the source file. Sets also mask filenames for bmp-files:
+ */
+void MifConvArgumentManager::ResolveSourceFileTypes()
+{
+    bool extensionFlag = BooleanValue(MifConvUseExtensionArg);
+
+    // check if the input directory is given:
+    const MifConvStringList& inputDirList = StringListValue(MifConvIconSourceDirectory);
+
+    // Add user-defined input directory to search directory list, put MIFCONV_WILDCARD
+    // as filetype rule, because user defined directory can contain all supported filetypes:
+    int indexcounter = 0;
+    for( MifConvStringList::const_iterator iDir = inputDirList.begin(); iDir != inputDirList.end(); ++iDir )
+    {
+        MifConvSourceSearchRule customRule(*iDir, MifConvStringList(1, MIFCONV_WILDCARD));
+        MifConvUtil::ReplaceChar(customRule.SearchPath(), INCORRECT_DIR_SEPARATOR2, DIR_SEPARATOR2);
+        MifConvUtil::RemoveDuplicateDirSeparators(customRule.SearchPath());
+        iSearchRules.insert(iSearchRules.begin()+indexcounter, customRule);
+        
+        ++indexcounter;
+    }
+    
+    for( MifConvSourceFileList::iterator src = iSourceFiles.begin(); src != iSourceFiles.end(); ++ src )
+    {
+        if( extensionFlag )
+        {
+            MifConvString extension = MifConvUtil::FileExtension(src->Filename());
+            if( !FindAndSetPathAndType( *src, extension ) )
+            {                 
+                THROW_ERROR_COMMON("File not found " + src->Filename(), MifConvString(__FILE__), __LINE__ );
+            }
+        }
+        else
+        {
+            // "Use extension" -flag not given, so resolve extensions for source files
+            if( !FindAndSetPathAndType( *src, SVGB_BINARY_FILE_EXTENSION ) )
+            { 
+                if( !FindAndSetPathAndType( *src, SVG_FILE_EXTENSION ) )
+                {                
+                    if( !FindAndSetPathAndType( *src, BMP_FILE_EXTENSION ) )
+                    {                
+                        THROW_ERROR_COMMON("File not found " + src->Filename(), MifConvString(__FILE__), __LINE__ );
+                    }
+                }
+            }
+        }
+    }
+}
+
+/**
+ *
+ */
+void MifConvArgumentManager::GetMifEnv()
+{    
+    // Read EPOCROOT environment variable
+    char* tmpPtr = 0;
+    tmpPtr = getenv(EPOCROOT_ENV.c_str());
+    if( tmpPtr )
+    {        
+        iEpocRoot = MifConvString(tmpPtr);
+        MifConvUtil::ReplaceChar(iEpocRoot, INCORRECT_DIR_SEPARATOR2, DIR_SEPARATOR2);
+        // Make sure that the last char is directory separator
+        if( iEpocRoot.length() > 0 && iEpocRoot.at( iEpocRoot.length()-1) != DIR_SEPARATOR2 )
+        {
+            iEpocRoot += DIR_SEPARATOR;
+        }
+    }
+}
+
+/**
+ *
+ */
+const MifConvString& MifConvArgumentManager::EpocRoot() const
+{
+    return iEpocRoot;
+}
+
+/**
+ *
+ */
+bool MifConvArgumentManager::FindAndSetPathAndType( MifConvSourceFile& srcFile, const MifConvString& extension )
+{    
+    // Search the filename first "as is":
+    MifConvString tmp( MifConvUtil::FilenameWithoutExtension( srcFile.Filename() ) + MifConvString(FILE_EXTENSION_SEPARATOR) + extension );     
+    if( MifConvUtil::FileExists(tmp) )
+    {
+        srcFile.SetFilename(tmp);
+        MifConvUtil::FindAndSetBitmapMaskFile(srcFile);
+        return true;
+    }
+
+    // If the absolute path was given, return false, because the file was not found with given path and filename. 
+    // Otherwise continue searching.
+    if( //(srcFile.Filename().length() > 0 && srcFile.Filename().at(0) == DIR_SEPARATOR2) ||
+        (srcFile.Filename().length() > 1 && srcFile.Filename().at(1) == ':') )
+    {        
+        return false;
+    }
+
+    // Search from the pre-defined locations:        
+    for( SearchRules::iterator i = iSearchRules.begin(); i != iSearchRules.end(); ++i )
+    {
+        bool validPath = false;
+        const MifConvStringList& allowedTypes = i->AllowedFileTypes();
+
+        // See if the file with given extension is allowed to locate in search path.
+        // For example, epoc32\s60\icons folder can contain only .svg files and epoc32\s60\bitmaps 
+        // can contain only .bmp files:
+        for( MifConvStringList::const_iterator typeIter = allowedTypes.begin(); typeIter != allowedTypes.end(); ++typeIter )
+        {
+            if( *typeIter == MIFCONV_WILDCARD || *typeIter == extension )
+            {        
+                validPath = true;
+                break;
+            }
+        }
+
+        if( validPath )
+        {            
+            MifConvString searchPath(i->SearchPath());
+
+            // Make sure that the last char is directory separator
+            if( searchPath.length() > 0 && searchPath.at( searchPath.length()-1) != DIR_SEPARATOR2 )
+            {
+                searchPath += DIR_SEPARATOR;
+            }
+
+            searchPath += MifConvUtil::FilenameWithoutExtension( srcFile.Filename() ) + MifConvString(FILE_EXTENSION_SEPARATOR) + extension;
+
+            MifConvUtil::RemoveDuplicateDirSeparators(searchPath);
+
+            if( MifConvUtil::FileExists( searchPath ) )
+            {
+                srcFile.SetFilename(searchPath);
+                MifConvUtil::FindAndSetBitmapMaskFile(srcFile);                
+                return true; 
+            }  
+        }            
+    }
+    return false;
+}
+
+/**
+ *
+ */
+void MifConvArgumentManager::ProcessArgumentPaths()
+{
+	// Fix directory separators first:
+    for( StringArgMap::iterator i = iStringArguments.begin(); i != iStringArguments.end(); ++i )
+    {
+        MifConvString tmp = i->second.Value();
+        MifConvUtil::ReplaceChar(tmp, INCORRECT_DIR_SEPARATOR2, DIR_SEPARATOR2);
+        MifConvUtil::RemoveDuplicateDirSeparators(tmp);
+        i->second.SetValue(tmp);
+    }
+
+    // Fix directory separators in source filenames also:
+    for( MifConvSourceFileList::iterator j = iSourceFiles.begin(); j != iSourceFiles.end(); ++j )
+    {
+        MifConvString tmp = j->Filename();
+        MifConvUtil::ReplaceChar(tmp, INCORRECT_DIR_SEPARATOR2, DIR_SEPARATOR2);
+        MifConvUtil::RemoveDuplicateDirSeparators(tmp);
+        j->SetFilename(tmp);
+    }
+    
+    // Fix directory separators in search rule directories also:
+    for( SearchRules::iterator k = iSearchRules.begin(); k != iSearchRules.end(); ++k )
+    {
+        MifConvString& tmp = k->SearchPath();
+        MifConvUtil::ReplaceChar(tmp, INCORRECT_DIR_SEPARATOR2, DIR_SEPARATOR2);
+        MifConvUtil::RemoveDuplicateDirSeparators(tmp);
+    }
+
+    // Fix target file also:
+    MifConvUtil::ReplaceChar(iTargetFile, INCORRECT_DIR_SEPARATOR2, DIR_SEPARATOR2);
+    MifConvUtil::RemoveDuplicateDirSeparators(iTargetFile);
+}
+
+/**
+ *
+ */
+void MifConvArgumentManager::FinalizeArguments()
+{
+	ProcessArgumentPaths();
+	ResolveSourceFileTypes();
+}
+
+/**
+ *
+ */
+void MifConvArgumentManager::SetUsageString( MifConvString& usageStr ) const
+{
+	usageStr = "";
+
+    usageStr += "Copyright (c) " + MifConvYears + " Nokia Corporation and/or its subsidiary(-ies). All rights reserved.\n";
+    usageStr += "\n";
+    usageStr += "Usage: mifconv <MIFFILE> [-F<file>] <options> <sources>]\n";
+    usageStr += "\n";
+    usageStr += "Where:\n";
+    usageStr += "  MIFFILE            Specifies the target MIF file to be created\n";
+    usageStr += "  -F<file>           Specifies a parameter file, which can contain any of the options\n";
+    usageStr += "                        and sources separated by spaces or newlines\n";
+    usageStr += "\n";
+    usageStr += "Options:\n";
+    usageStr += "  -H<file>           Specifies a name of the MIF header file (default extension MBG)\n";
+    usageStr += "  -I<dir;dir;...>    Specifies a set of custom source directories where source files\n";
+    usageStr += "                        will be searched. As a fallback, global source directories are\n";
+    usageStr += "                        used\n";
+    usageStr += "  -E                 Specifies that source icons are only loaded with given file\n";
+    usageStr += "                        extensions. By default, Mifconv prefers source icons with\n";
+    usageStr += "                        extension .SVG over .BMP, regardless of which is given as\n";
+    usageStr += "                        a parameter\n";
+    usageStr += "  -X                 Disables SVG compression. If this flag is set, SVG icons are\n";
+    usageStr += "                        added to MIF file without compressing them first\n";
+    usageStr += "  -P<file>           Specifies a path to custom palette file for bitmap files\n";
+    usageStr += "  -T<dir>            Specifies a path where temporary files are created\n";
+    usageStr += "  -B<file>           Specifies a path for non-default BMConv utility\n";
+    usageStr += "  -S<file>           Specifies a path for non-default SVGTBinenCode utility\n";
+    usageStr += "  -V<string>         Specifies a non-platform default format version of SVGT binary\n";
+    usageStr += "                        conversion. It can be any of the following value:\n";
+    usageStr += "                             1      BGR / float encoding\n";
+    usageStr += "                             2      BGR / fixed point encoding\n";
+    usageStr += "                             3      RGB / fixed point encoding\n";
+    usageStr += "                             4      RGB / float encoding\n";
+    usageStr += "Sources:\n";
+    usageStr += "  [-A] <DEPTH[,MASK]> <FILE> [ [-A] <DEPTH[,MASK]> <FILE> ... ]\n";
+    usageStr += "        [-A]         Specifies animated flag for the icon\n";
+    usageStr += "        [DEPTH]      Specifies icon depth, it can be any of these values\n";
+    usageStr += "                        -1,-2,-4,-8,-c4,-c8,-c12,-c16,-c24,-c32\n";
+    usageStr += "        [MASK]       Specifies icon mask depth, it can be any of these values\n";
+    usageStr += "                        1,8\n";
+    usageStr += "        [FILE]       Specifies path to the input file, supported file extensions are\n";
+    usageStr += "                        SVG, SVGB, BMP\n";
+    usageStr += "\n";
+    usageStr += "Other info:\n";
+#ifdef WIN32
+    usageStr += "  * '-' or '/' can be used as parameter switch prefix\n";
+#endif    
+    usageStr += "  * Value of icon mask and depth is meaningful only for bitmap files, but the mask\n";
+    usageStr += "    value defines if mask entry will be available or not in the header file\n";
+    usageStr += "  * If mask parameter is defined for a BMP file, Mifconv automatically pics\n";
+    usageStr += "    a file ending _mask_soft for value 8 and _mask for value 1 of mask\n";
+    usageStr += "\n";
+    usageStr += "Examples:\n";
+    usageStr += "  mifconv mybuttons.mif -Hmybuttons.mbg -c8,8 button1 -c8,8 button2\n";
+}
+
+/**
+ *
+ */
+const MifConvString& MifConvArgumentManager::StringValue( const MifConvString& argName ) const
+{
+	StringArgMap::const_iterator i = iStringArguments.find(argName);
+	if( i != iStringArguments.end() )
+	{
+		return i->second.Value();
+	}
+	
+	return iDummyString;
+}
+
+/**
+ *
+ */
+const MifConvStringList& MifConvArgumentManager::StringListValue( const MifConvString& argName ) const
+{
+	StringListArgMap::const_iterator i = iStringListArguments.find(argName);
+	if( i != iStringListArguments.end() )
+	{
+		return i->second.Value();
+	}
+	
+	return iDummyStringList;
+}
+
+/**
+ *
+ */
+bool MifConvArgumentManager::BooleanValue( const MifConvString& argName ) const
+{
+	BooleanArgMap::const_iterator i = iBooleanArguments.find(argName);
+	if( i != iBooleanArguments.end() )
+	{
+		return i->second.Value();
+	}
+	
+	return false;
+}
+
+/**
+ *
+ */
+const MifConvSourceFileList& MifConvArgumentManager::SourceFiles() const
+{
+	return iSourceFiles;
+}
+
+/**
+ *
+ */
+bool MifConvArgumentManager::IsArgument( const MifConvString& str ) const
+{
+	try {
+		return str.at(0) == OPTION_PREFIX1_CHAR || str.at(0) == OPTION_PREFIX2_CHAR;
+	}
+	catch(...)
+	{
+		THROW_ERROR("Zero or corrupted string in MifConvArgumentManager::IsArgument()\n", MifConvString(__FILE__), __LINE__);
+	}
+	return false;
+}
+
+/**
+ *
+ */
+void MifConvArgumentManager::PopulateDepthAndMaskMaps()
+{
+    // Insert value-string pairs for the icon depths:
+    iDepthMap.insert(std::make_pair(MifConvDepth_1,    IconDepth_1));
+    iDepthMap.insert(std::make_pair(MifConvDepth_2,    IconDepth_2));
+    iDepthMap.insert(std::make_pair(MifConvDepth_4,    IconDepth_4));
+    iDepthMap.insert(std::make_pair(MifConvDepth_8,    IconDepth_8));
+    iDepthMap.insert(std::make_pair(MifConvDepth_c4,   IconDepth_c4));
+    iDepthMap.insert(std::make_pair(MifConvDepth_c8,   IconDepth_c8));
+    iDepthMap.insert(std::make_pair(MifConvDepth_c12,  IconDepth_c12));
+    iDepthMap.insert(std::make_pair(MifConvDepth_c16,  IconDepth_c16));
+    iDepthMap.insert(std::make_pair(MifConvDepth_c24,  IconDepth_c24));
+    iDepthMap.insert(std::make_pair(MifConvDepth_c32,  IconDepth_c32));
+    
+    // Insert value-string pairs for the icon masks:
+    iMaskDepthMap.insert(std::make_pair(MifConvMaskDepth_1, IconMaskDepth_1));
+    iMaskDepthMap.insert(std::make_pair(MifConvMaskDepth_8, IconMaskDepth_8));
+
+    // Insert value-pairs for display modes:
+    iDisplayModeMap.insert(std::make_pair(IconDepth_1,      DisplayMode_Gray2));
+    iDisplayModeMap.insert(std::make_pair(IconDepth_2,      DisplayMode_Gray4));
+    iDisplayModeMap.insert(std::make_pair(IconDepth_4,      DisplayMode_Gray16));
+    iDisplayModeMap.insert(std::make_pair(IconDepth_8,      DisplayMode_Gray256));
+    iDisplayModeMap.insert(std::make_pair(IconDepth_c4,     DisplayMode_Color16));
+    iDisplayModeMap.insert(std::make_pair(IconDepth_c8,     DisplayMode_Color256));
+    iDisplayModeMap.insert(std::make_pair(IconDepth_c12,    DisplayMode_Color4K));
+    iDisplayModeMap.insert(std::make_pair(IconDepth_c16,    DisplayMode_Color64K));
+    iDisplayModeMap.insert(std::make_pair(IconDepth_c24,    DisplayMode_Color16M));
+    iDisplayModeMap.insert(std::make_pair(IconDepth_c32,    DisplayMode_Color16MU));
+
+    iMaskDisplayModeMap.insert(std::make_pair(IconMaskDepth_1,  DisplayMode_Gray2));
+    iMaskDisplayModeMap.insert(std::make_pair(IconMaskDepth_8,  DisplayMode_Gray256));
+}
+
+/**
+ *
+ */
+void MifConvArgumentManager::ReadParameterFile(const MifConvString& paramFilename, MifConvStringList& paramList)
+{
+    // Check if the file exists:
+    if( MifConvUtil::FileExists(paramFilename) == false )
+    {
+        THROW_ERROR_COMMON("Unable to open file for reading! " + paramFilename, MifConvString(__FILE__), __LINE__ );
+    }
+
+    MifConvFileData paramFileData = MifConvUtil::FileContents(paramFilename);    
+
+    MifConvString tmpString;
+    for(size_t i = 0; i < paramFileData.second; ++i )
+    {
+        if( MifConvUtil::IsWhiteSpace(paramFileData.first[i]) == false )
+        {
+            tmpString += paramFileData.first[i];
+        }
+        else if( tmpString.length() > 0 )
+        {
+            paramList.push_back( tmpString );            
+            tmpString = MifConvString();       
+        }
+    }
+
+    if( tmpString.length() > 0 )
+    {
+        paramList.push_back( tmpString );
+        tmpString = MifConvString();
+    }
+    delete[] paramFileData.first;
+}
+
+/**
+ * Helper class for source search rules
+ */
+
+MifConvSourceSearchRule::MifConvSourceSearchRule(const MifConvString& path, const MifConvStringList& types)
+:
+iSearchPath(path),
+iAllowedFileTypes(types)
+{}
+
+MifConvSourceSearchRule::~MifConvSourceSearchRule()
+{}
+
+const MifConvString& MifConvSourceSearchRule::SearchPath() const 
+{ 
+    return iSearchPath; 
+}
+
+MifConvString& MifConvSourceSearchRule::SearchPath() 
+{ 
+    return iSearchPath; 
+}
+
+const MifConvStringList& MifConvSourceSearchRule::AllowedFileTypes() const
+{
+    return iAllowedFileTypes;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/src/mifconv_bitmapconverter.cpp	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,277 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mifconv bitmap converters class.
+*
+*/
+
+
+#include "mifconv.h"
+#include "mifconv_bitmapconverter.h"
+#include "mifconv_util.h"
+#include "mifconv_exception.h"
+#include "mifconv_argumentmanager.h"
+#include <stdio.h>
+
+const MifConvString BMCONV_DEFAULT_PATH(EPOC_TOOLS_PATH);
+
+/**
+ *
+ */
+MifConvBitmapConverter::MifConvBitmapConverter()
+{
+    MifConvArgumentManager* argMgr = MifConvArgumentManager::Instance();
+	// Output file:
+	iTargetFilename = MifConvUtil::FilenameWithoutExtension(argMgr->TargetFile()) + "." + MifConvString(MBM_FILE_EXTENSION);
+}
+
+/**
+ *
+ */
+MifConvBitmapConverter::~MifConvBitmapConverter()
+{
+}
+
+/**
+ *
+ */
+void MifConvBitmapConverter::Init()
+{
+    CleanupTargetFiles();
+}
+
+/**
+ *
+ */
+void MifConvBitmapConverter::CleanupTargetFiles()
+{
+	if( MifConvUtil::FileExists(iTargetFilename) )
+	{
+        // Try to remove file MIFCONV_MAX_REMOVE_TRIES times, no exception in case of failure:
+        MifConvUtil::RemoveFile(iTargetFilename, MIFCONV_MAX_REMOVE_TRIES, true);
+	}
+}
+
+/**
+ *
+ */
+void MifConvBitmapConverter::AppendFile( const MifConvSourceFile& sourcefile )
+{    
+	if( MifConvUtil::FileExtension( sourcefile.Filename() ) == BMP_FILE_EXTENSION )
+	{
+		iSourceFiles.push_back( sourcefile );
+	}
+}
+
+/**
+ *
+ */
+void MifConvBitmapConverter::Convert()
+{
+    if( iSourceFiles.size() > 0 )
+    {
+	    ConvertToMbm();
+    }
+}
+
+/**
+ *
+ */
+void MifConvBitmapConverter::Cleanup(bool err)
+{
+	CleanupTempFiles();
+	if( err )
+	{
+	    CleanupTargetFiles();
+	}
+}
+
+/**
+ *
+ */
+void MifConvBitmapConverter::ConvertToMbm()
+{    
+    RunBmconv();
+}
+
+/**
+ *
+ */
+void MifConvBitmapConverter::InitTempFile()
+{
+    MifConvArgumentManager* argMgr = MifConvArgumentManager::Instance();
+    // Construct temp file name
+    iTempDir = MifConvUtil::DefaultTempDirectory();
+    const MifConvString& tempDirArg = argMgr->StringValue(MifConvTempPathArg);
+    if( tempDirArg.length() > 0 )
+    {
+        iTempDir = tempDirArg;
+    }
+
+    if( iTempDir.length() > 0 && iTempDir.at(iTempDir.length()-1) != DIR_SEPARATOR2 )
+    {
+        iTempDir.append(DIR_SEPARATOR);
+    }
+
+    // Generate new temp-filename:
+    iTempDir.append(MifConvUtil::TemporaryFilename());
+
+    // append tmp at as postfix
+    // this is needed because the generated name can contain a single period '.'
+    // character as the last character which is eaten away when the directory created.
+    iTempDir.append(MifConvString("tmp"));
+
+    MifConvUtil::EnsurePathExists(iTempDir);
+
+    iTempDir.append(DIR_SEPARATOR);
+
+    iTempFilename = iTempDir + MifConvUtil::FilenameWithoutExtension(MifConvUtil::FilenameWithoutPath(argMgr->TargetFile()));
+    iTempFilename += BMCONV_TEMP_FILE_POSTFIX;
+
+    // Create temp file
+    fstream tempFile(iTempFilename.c_str(), ios::out|ios::binary|ios::trunc);
+    if (!tempFile.is_open())
+    {        
+        throw MifConvException(MifConvString("Unable to create tmp file! ") + iTempFilename);        
+    }
+
+    try {
+        // quiet mode        
+        tempFile << BMCONV_OPTION_PREFIX << BMCONV_QUIET_PARAMETER << " ";
+        // Palette argument
+        const MifConvString& paletteArg = argMgr->StringValue(MifConvPaletteFileArg);
+        if( paletteArg.length() > 0 )
+        {
+            tempFile << BMCONV_OPTION_PREFIX << BMCONV_PALETTE_PARAMETER;            
+            tempFile << MifConvString(paletteArg + " ");
+        }
+
+        tempFile << iTargetFilename << " ";                
+        // Add filenames to the temp file
+        for( MifConvSourceFileList::iterator i = iSourceFiles.begin(); i != iSourceFiles.end(); ++i )
+        {
+            AppendBmpToTempFile(tempFile, *i);
+        }
+    }
+    catch(...) {
+        tempFile.close();
+        throw;
+    }        
+
+    tempFile.close();
+}
+
+/**
+ *
+ */
+void MifConvBitmapConverter::RunBmconv()
+{
+    MifConvArgumentManager* argMgr = MifConvArgumentManager::Instance();
+    // Create and initialize the temp file:    
+    InitTempFile();
+
+    // Build bmconv command    
+    MifConvString bmconvCommand("\""); // Open " mark
+    
+    const MifConvString& bmconvPath = argMgr->StringValue(MifConvBmconvPathArg);
+    const MifConvString& defaultBmconvPath = GetDefaultBmConvPath();
+    if( bmconvPath.length() > 0 )
+    {
+        bmconvCommand += bmconvPath; // If the path is given, use it.
+    }
+    else
+    {
+        bmconvCommand += defaultBmconvPath; // Use default path
+    }
+
+    // Ensure that the last char of the path is dir-separator:
+    if( bmconvCommand.length() > 1 && bmconvCommand.at(bmconvCommand.length()-1) != DIR_SEPARATOR2 )
+        bmconvCommand += DIR_SEPARATOR;
+
+    // Then add bmconv executable call and close the " mark
+    bmconvCommand += BMCONV_EXECUTABLE_NAME + MifConvString("\" ");  
+    bmconvCommand += "\"" + iTempFilename + "\"";
+        
+    MifConvUtil::EnsurePathExists(iTargetFilename, true);
+    
+    cout << "Writing mbm: " << iTargetFilename << endl;           
+    int err = 0;
+    
+#ifdef __linux__
+    if ((err = system (MifConvString(bmconvCommand).c_str())) != 0)   // Returns 0 if success
+#else
+    if ((err = system (MifConvString("\""+bmconvCommand+"\"").c_str())) != 0)   // Returns 0 if success
+#endif
+    {
+    	THROW_ERROR_COMMON("Executing BMCONV failed", MifConvString(__FILE__), __LINE__);
+    }
+}
+
+/**
+ *
+ */
+void MifConvBitmapConverter::CleanupTempFiles()
+{
+    if( iTempFilename.length() > 0 && remove( iTempFilename.c_str() ) != 0 )
+    {
+        perror( "Error deleting temporary file (bitmap conversion)" );
+    }
+    
+    if( iTempDir.length() > 0 && MifConvUtil::RemoveDirectory( iTempDir ) != 0 )
+    {
+        perror( "Error deleting temporary directory (bitmap conversion)" );
+    }
+}
+
+/**
+ *
+ */
+const MifConvString& MifConvBitmapConverter::GetDefaultBmConvPath()
+{
+    if( iDefaultBmConvPath.length() == 0 )
+    {        
+        // Check if the EPOCROOT is given
+        MifConvString epocRoot(MifConvArgumentManager::Instance()->EpocRoot());
+        if( epocRoot.length() > 0 )
+        {
+            // EPOCROOT environment variable defined.
+            iDefaultBmConvPath = epocRoot + BMCONV_DEFAULT_PATH;
+        }        
+    }
+
+    return iDefaultBmConvPath;
+}
+
+/**
+ *
+ */
+void MifConvBitmapConverter::AppendBmpToTempFile(fstream& aStream, const MifConvSourceFile& bmpFile)
+    {
+    cout << "Loading file: " << bmpFile.Filename() << endl;
+
+    aStream << BMCONV_OPTION_PREFIX;
+    aStream << bmpFile.DepthString();
+    aStream << bmpFile.Filename();
+    aStream << " ";
+        
+    // Prepare also for the case that mask is not used at all.
+    const MifConvString& maskName = bmpFile.BmpMaskFilename();
+    if (maskName.length() > 0 )
+    {
+        cout << "Loading file: " << maskName << endl;
+        aStream << BMCONV_OPTION_PREFIX;
+        aStream << bmpFile.MaskDepthString();
+        aStream << maskName;        
+    }
+    aStream << " ";    
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/src/mifconv_bitmapheaderconverter.cpp	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,166 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mifconv bitmap header converter class.
+*
+*/
+
+
+#include "mifconv.h"
+#include "mifconv_bitmapheaderconverter.h"
+#include "mifconv_argumentmanager.h"
+#include "mifconv_util.h"
+#include "mifconv_exception.h"
+
+const int MIF_ID_FIRST = 16384;
+
+/**
+ *
+ */
+MifConvBitmapHeaderConverter::MifConvBitmapHeaderConverter()
+:
+iCurrentSourceId(MIF_ID_FIRST)
+{
+	MifConvArgumentManager* argMgr = MifConvArgumentManager::Instance();
+    iHeaderFilename = argMgr->StringValue(MifConvHeaderArg);
+}
+
+/**
+ *
+ */
+MifConvBitmapHeaderConverter::~MifConvBitmapHeaderConverter()
+{
+}
+
+/**
+ *
+ */
+void MifConvBitmapHeaderConverter::Init()
+{
+    CleanupTargetFiles();
+}
+
+/**
+ *
+ */
+void MifConvBitmapHeaderConverter::CleanupTargetFiles()
+{
+	if( MifConvUtil::FileExists(iHeaderFilename) )
+	{
+        // Try to remove file MIFCONV_MAX_REMOVE_TRIES times, no exception in case of failure:
+        MifConvUtil::RemoveFile(iHeaderFilename, MIFCONV_MAX_REMOVE_TRIES, true);
+	}
+}
+
+/**
+ *
+ */
+void MifConvBitmapHeaderConverter::AppendFile( const MifConvSourceFile& sourcefile )
+{    
+	iSourceFiles.push_back( sourcefile );	
+}
+
+/**
+ *
+ */
+void MifConvBitmapHeaderConverter::Convert()
+{
+    // Check if the headerfile name is given. Return if not:    
+    if( iHeaderFilename.length() > 0 )
+    {
+        cout << "Writing mbg: " << iHeaderFilename << endl;
+        MifConvUtil::EnsurePathExists(iHeaderFilename, true);
+    }
+    else
+    {
+        return;
+    }
+
+    // Create / open the header file:
+    fstream headerFile(iHeaderFilename.c_str(), ios::out|ios::trunc);
+    
+    // If file creation/opening was not successful, give warning and return:
+    if( !headerFile.is_open() )
+    {
+        MifConvString debugStr("WARNING: Headerfile " + iHeaderFilename + " cannot be opened for writing.");
+        cout <<  debugStr  << endl;
+        MifConvUtil::DebugLog(debugStr);
+        return;
+    }
+    iDestFile = &headerFile; // Save the pointer to the file stream    
+    (*iDestFile) << endl;
+    // Write the beginning of the header file:
+    WriteStart();
+
+    // Add source file items to enumerator:
+    for( MifConvSourceFileList::iterator i = iSourceFiles.begin(); i != iSourceFiles.end(); ++i )
+    {
+        WriteItemToHeader(*i);
+    }
+
+    // Write the end of the file...
+    WriteEnd();
+
+    // ...and close the file:
+    iDestFile->close();
+}
+
+/**
+ *
+ */
+void MifConvBitmapHeaderConverter::WriteStart()
+{
+    (*iDestFile) << "/* This file has been generated, DO NOT MODIFY. */" << endl;
+    (*iDestFile) << "enum TMif" << MifConvUtil::UnadornedFilename(iHeaderFilename) << "\n\t{" << endl;
+}
+
+/**
+ *
+ */
+void MifConvBitmapHeaderConverter::WriteItemToHeader( const MifConvSourceFile& source )
+{
+    MifConvString unadornedHeaderFile(MifConvUtil::UnadornedFilename(iHeaderFilename));
+    
+    (*iDestFile) << "\tEMbm" << unadornedHeaderFile << MifConvUtil::UnadornedFilename(source.Filename()) <<  " = " << iCurrentSourceId++ << "," << endl;
+
+    // Write mask also, if any:
+    if( source.MaskDepth() != IconMaskDepth_Undefined )
+    {
+        (*iDestFile) << "\tEMbm" << unadornedHeaderFile << MifConvUtil::UnadornedFilename(source.Filename()) <<  "_mask = " << iCurrentSourceId++ << "," << endl;
+    }
+    else
+    {
+        // Skip mask ID if mask not present so that adding a mask later does not change IDs.
+        iCurrentSourceId++;
+    }
+}
+
+/**
+ *
+ */
+void MifConvBitmapHeaderConverter::WriteEnd()
+{
+    (*iDestFile) << "\tEMbm" << MifConvUtil::UnadornedFilename(iHeaderFilename) << "LastElement" << endl;
+    (*iDestFile) << "\t};" << endl;
+}
+
+/**
+ *
+ */
+void MifConvBitmapHeaderConverter::Cleanup(bool err)
+{
+    if( err )
+	{
+	    CleanupTargetFiles();
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/src/mifconv_convertermanager.cpp	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,190 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mifconv converter manager class.
+*
+*/
+
+
+#include "mifconv.h"
+#include "mifconv_convertermanager.h"
+#include "mifconv_argumentmanager.h"
+#include "mifconv_util.h"
+#include "mifconv_bitmapconverter.h"
+#include "mifconv_bitmapheaderconverter.h"
+#include "mifconv_iconbinaryconverter.h"
+#include "mifconv_mifconverter.h"
+
+// Static singleton initialization
+MifConvConverterManager* MifConvConverterManager::iInstance = 0;
+
+/**
+ * Returns pointer to the singleton object
+ */
+MifConvConverterManager* MifConvConverterManager::Instance()
+{
+    if( iInstance == 0 )
+    {
+        iInstance = new MifConvConverterManager();
+    }
+    return iInstance;
+}
+
+/**
+ * Free the allocated memory
+ */
+void MifConvConverterManager::Reset()
+{
+    delete iInstance;
+    iInstance = 0;
+}
+
+/**
+ * Constructor
+ */
+MifConvConverterManager::MifConvConverterManager()
+{
+    
+}
+
+/**
+ *
+ */
+void MifConvConverterManager::Init()
+{
+    // Add bmp --> mbm converter:
+    MifConvBitmapConverter* bitmapConverter = new MifConvBitmapConverter();
+    iAllConverters.push_back(bitmapConverter);
+
+    // Add headerfile (mbg) converter:
+    MifConvBitmapHeaderConverter* headerConverter = new MifConvBitmapHeaderConverter();    
+    iAllConverters.push_back(headerConverter);
+
+    // Add svg --> svgb converter:
+    MifConvIconBinaryConverter* svgConverter = new MifConvIconBinaryConverter();
+    iAllConverters.push_back(svgConverter);
+
+    // Add mif converter:
+    MifConvMifConverter* mifConverter = new MifConvMifConverter();
+    iAllConverters.push_back(mifConverter);
+
+    // Add file converters for .BMP files:
+    MifConvFileConverterList bmpConverters;
+    bmpConverters.push_back(bitmapConverter);
+    bmpConverters.push_back(headerConverter);
+    bmpConverters.push_back(mifConverter);
+    iFileConverters.insert(std::make_pair(MifConvString(BMP_FILE_EXTENSION), bmpConverters));
+
+    // Add file converters for .SVG files:
+    MifConvFileConverterList svgConverters;
+    svgConverters.push_back(headerConverter);
+    svgConverters.push_back(svgConverter);
+    if( MifConvArgumentManager::Instance()->BooleanValue(MifConvDisableSvgCompression) )
+    {        
+        // SVG files will be added to mif-file without compression (i.e. don't use svgtbinencode for them).
+        svgConverters.push_back(mifConverter); 
+    }
+    iFileConverters.insert(std::make_pair(MifConvString(SVG_FILE_EXTENSION), svgConverters));
+
+    // Add file converters for .SVGB files:
+    MifConvFileConverterList svgbConverters;  
+    svgbConverters.push_back(headerConverter);
+    if( !MifConvArgumentManager::Instance()->BooleanValue(MifConvDisableSvgCompression) )
+    {     
+        // SVG files will be compressed first.
+        svgbConverters.push_back(mifConverter);
+    }
+    iFileConverters.insert(std::make_pair(MifConvString(SVGB_BINARY_FILE_EXTENSION), svgbConverters));
+    
+    // Initialize converters
+    for( MifConvFileConverterList::iterator i = iAllConverters.begin(); i != iAllConverters.end(); ++i )
+    {
+    	(*i)->Init();
+    }
+}
+
+/**
+ * Destructor
+ */
+MifConvConverterManager::~MifConvConverterManager()
+{
+    for( MifConvFileConverterList::iterator conv = iAllConverters.begin(); conv != iAllConverters.end(); ++conv )
+    {
+        delete *conv;    
+    }
+}
+
+/**
+ * Adds source files to converters and converts them
+ */
+void MifConvConverterManager::ProcessIcons()
+{
+    MifConvArgumentManager* argMgr = MifConvArgumentManager::Instance();
+    // Loop all the source files and append them to correct converters:
+    const MifConvSourceFileList& sourcefiles = argMgr->SourceFiles();
+    for( MifConvSourceFileList::const_iterator i = sourcefiles.begin(); i != sourcefiles.end(); ++i )
+	{        
+        MifConvFileConverterList& converters = GetConverters(*i);
+        for( MifConvFileConverterList::iterator converter = converters.begin(); converter != converters.end(); ++converter )
+        {            
+            (*converter)->AppendFile(*i);            
+        }
+    }
+
+    // Run all the converters:
+    for( MifConvFileConverterList::iterator conv = iAllConverters.begin(); conv != iAllConverters.end(); ++conv )
+    {
+        (*conv)->Convert();
+    }
+}
+
+/**
+ *
+ */
+void MifConvConverterManager::Cleanup(bool error)
+{
+    for( MifConvFileConverterList::iterator conv = iAllConverters.begin(); conv != iAllConverters.end(); ++conv )
+    {
+        try {
+            (*conv)->Cleanup(error);
+        }
+        catch(...) {
+        // Exception should not be thrown if cleaning after error situation
+            if( !error )
+                throw;
+        }
+    }           
+}
+
+/**
+ *
+ */
+MifConvFileConverterList& MifConvConverterManager::GetConverters(const MifConvSourceFile& source)
+{    
+    return GetConverters(source.Filename());
+}
+
+/**
+ *
+ */
+MifConvFileConverterList& MifConvConverterManager::GetConverters(const MifConvString& filename)
+{
+    MifConvString extension(MifConvUtil::FileExtension(filename));
+    FileConverterMap::iterator i = iFileConverters.find(extension);
+    if( i != iFileConverters.end() )
+    {
+        return i->second;
+    }
+    
+    return iDummyConverterList;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/src/mifconv_exception.cpp	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mifconv exception class.
+*
+*/
+
+
+#include "mifconv.h"
+#include "mifconv_exception.h"
+
+MifConvException::MifConvException()
+:
+iLine(0)
+{}
+
+MifConvException::MifConvException(const MifConvString& str, const MifConvString& file, int line)
+:
+iString(str),
+iFile(file),
+iLine(line)
+{}
+
+MifConvException::MifConvException(const MifConvException& rhs)
+:
+iString(rhs.iString),
+iFile(rhs.iFile),
+iLine(rhs.iLine)
+{}
+
+MifConvException::~MifConvException()
+{}
+
+void MifConvException::SetString(const MifConvString& str)
+{
+	iString = str;
+}
+const MifConvString& MifConvException::String() const
+{
+	return iString;
+}
+
+MifConvString& MifConvException::String()
+{
+	return iString;
+}
+
+void MifConvException::SetFile(const MifConvString& file)
+{
+	iFile = file;
+}
+
+const MifConvString& MifConvException::File() const
+{
+	return iFile;
+}
+
+void MifConvException::SetLine(int line)
+{
+	iLine = line;
+}
+
+int MifConvException::Line() const
+{
+	return iLine;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/src/mifconv_iconbinaryconverter.cpp	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,302 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mifconv icon binary converters class.
+*
+*/
+
+
+#include "mifconv.h"
+#include "mifconv_iconbinaryconverter.h"
+#include "mifconv_util.h"
+#include "mifconv_exception.h"
+#include "mifconv_convertermanager.h"
+#include "mifconv_argumentmanager.h"
+#include <errno.h>
+#include <algorithm> 
+
+const MifConvString SVGTBINENCODE_DEFAULT_PATH(EPOC_TOOLS_PATH);
+
+/**
+ *
+ */
+MifConvIconBinaryConverter::MifConvIconBinaryConverter()
+{
+}
+
+/**
+ *
+ */
+MifConvIconBinaryConverter::~MifConvIconBinaryConverter()
+{
+}
+
+/**
+ *
+ */
+void MifConvIconBinaryConverter::Init()
+{
+}
+
+/**
+ *
+ */
+void MifConvIconBinaryConverter::CleanupTargetFiles()
+{
+}
+
+/**
+ *
+ */
+void MifConvIconBinaryConverter::AppendFile( const MifConvSourceFile& sourcefile )
+{   
+	if( MifConvUtil::FileExtension( sourcefile.Filename() ) == SVG_FILE_EXTENSION &&
+        MifConvArgumentManager::Instance()->BooleanValue(MifConvDisableSvgCompression) == false)
+	{ 
+		iSourceFiles.push_back( sourcefile );
+
+        // Create temp directory:
+        if( iTempDir.length() == 0 )
+        {
+            InitTempFile();
+        }
+
+        // External SVGTBINENCODE converts .svg files to .svgb files. However, .svgb files
+        // shall be given to mif-converter to get them in mif-file:      
+                
+        // Create new string for .svgb file name: 
+        MifConvString tmpFile(sourcefile.Filename());
+        ConvertToBinaryFilename(tmpFile);
+        MifConvString tempBinFilename(iTempDir + MifConvUtil::FilenameWithoutExtension(tmpFile) + "." + SVGB_BINARY_FILE_EXTENSION);
+
+        // Get converters for .svgb files:
+        MifConvFileConverterList& additionalConverters = MifConvConverterManager::Instance()->GetConverters(tempBinFilename);
+
+        // Converters for .svg files:
+        MifConvFileConverterList& thisFilesConverters = MifConvConverterManager::Instance()->GetConverters( sourcefile.Filename() );
+
+        // Save temporary binary filename for later deleting:
+        iTempFilenames.push_back(tempBinFilename);
+
+        // Add temporary file to converters:
+        for( MifConvFileConverterList::iterator c = additionalConverters.begin(); c != additionalConverters.end(); ++c )
+        {
+            // We have to make sure that we don't add same file twice to same converter. So, let's take first a list of
+            // .svg file converters and compare them to the .svgb file converters. Don't add temporary file to converters
+            // that are found from both of the lists.
+            MifConvFileConverterList::iterator c2 = std::find(thisFilesConverters.begin(), thisFilesConverters.end(), *c );
+            if( c2 == thisFilesConverters.end() )
+            {
+                // .svgb converter not found from .svg converters -> add temporary file to .svgb converter:
+                MifConvSourceFile svgbFile(sourcefile);
+                svgbFile.SetFilename(tempBinFilename);
+                (*c)->AppendFile(svgbFile);                
+            }            
+        }
+	}
+}
+
+/**
+ *
+ */
+void MifConvIconBinaryConverter::Convert()
+{    
+    if( iSourceFiles.size() > 0 && MifConvArgumentManager::Instance()->BooleanValue(MifConvDisableSvgCompression) == false )
+    {
+	    ConvertToSvgb();
+    }
+}
+
+/**
+ *
+ */
+void MifConvIconBinaryConverter::Cleanup(bool err)
+{    
+	CleanupTempFiles();
+	if( err )
+	{
+	    CleanupTargetFiles();
+	}
+}
+
+/**
+ *
+ */
+void MifConvIconBinaryConverter::ConvertToSvgb()
+{    
+    RunExtConverter();
+}
+
+/**
+ *
+ */
+void MifConvIconBinaryConverter::InitTempFile()
+{    
+    MifConvArgumentManager* argMgr = MifConvArgumentManager::Instance();
+    // Construct temp file name
+    // If temp directory is given in command line arguments, use it:    
+    iTempDir = MifConvUtil::DefaultTempDirectory();
+    const MifConvString& tempDirArg = argMgr->StringValue(MifConvTempPathArg);
+    if( tempDirArg.length() > 0 )
+    {
+        iTempDir = tempDirArg;
+    }
+
+    if( iTempDir.length() > 0 && iTempDir.at(iTempDir.length()-1) != DIR_SEPARATOR2 )
+    {
+        iTempDir.append(DIR_SEPARATOR);
+    }
+
+    // Generate new temp-filename:
+    iTempDir.append(MifConvUtil::TemporaryFilename());
+
+    // append tmp at as postfix
+    // this is needed because the generated name can contain a single period '.'
+    // character as the last character which is eaten away when the directory created.
+    iTempDir.append(MifConvString("tmp"));
+
+    MifConvUtil::EnsurePathExists(iTempDir);
+
+    iTempDir.append(DIR_SEPARATOR);
+}
+
+/**
+ *
+ */
+void MifConvIconBinaryConverter::ConvertToBinaryFilename( MifConvString& input )
+{
+    MifConvUtil::ReplaceChar(input, DIR_SEPARATOR2, '_');
+    MifConvUtil::ReplaceChar(input, INCORRECT_DIR_SEPARATOR2, '_');
+    MifConvUtil::ReplaceChar(input, ':', '_');
+    MifConvUtil::ReplaceChar(input, ' ', '_');
+}
+
+/**
+ *
+ */
+void MifConvIconBinaryConverter::RunExtConverter()
+{      
+    MifConvArgumentManager* argMgr = MifConvArgumentManager::Instance();
+   
+    // Build svgtbinencode command    
+    MifConvString extConverterCommand("\""); // Open the " mark
+    MifConvString versionArgument;
+    MifConvString sourceArgument;    
+        
+    const MifConvString& extConverterPath = argMgr->StringValue(MifConvSvgencodePathArg);
+    const MifConvString& defaultExtConverterPath = GetDefaultExtConverterPath();
+    if( extConverterPath.length() > 0 )
+    {
+        extConverterCommand += extConverterPath; // If the path is given, use it.
+    }
+    else
+    {
+        extConverterCommand += defaultExtConverterPath; // Use default path
+    }
+
+    // Ensure that the last char of the path is dir-separator:
+    if( extConverterCommand.length() > 1 && extConverterCommand.at(extConverterCommand.length()-1) != DIR_SEPARATOR2 )
+        extConverterCommand += DIR_SEPARATOR;
+
+    // Then add SVGTBINENCODE executable call and close the " mark
+    extConverterCommand += SVGTBINENCODE_EXECUTABLE_NAME + MifConvString("\" ");
+   
+    // If SVGTBINENCODE version is given, use it also:
+    const MifConvString& extConverterVersion = argMgr->StringValue(MifConvSvgtVersionArg);
+    if( extConverterVersion.length() > 0 )
+    {        
+        versionArgument = SVGTBINENCODE_OPTION_PREFIX +
+            MifConvString(SVGTBINENCODE_VERSION_PARAMETER) + " " + extConverterVersion;
+        extConverterCommand += versionArgument + " ";
+    }
+   
+    // Run converter for each of the source files:
+    for( MifConvSourceFileList::iterator i = iSourceFiles.begin(); i != iSourceFiles.end(); ++i )
+    {        
+        // Build temp filename by replacing dir separator and ':' chars with '_':
+        MifConvString tmpFileName(i->Filename());
+        ConvertToBinaryFilename(tmpFileName);
+
+        // Copy source file to temp directory:
+        MifConvString to(iTempDir + tmpFileName);        
+        if( MifConvUtil::CopyFile(i->Filename(), to) == false )
+        {
+            THROW_ERROR_COMMON("File copy failed: " + to, MifConvString(__FILE__), __LINE__ );
+        }
+        iTempFilenames.push_back(to);
+        // It seems that system() function does not work if the command consists of two separate parts 
+        // enclosed with quotation marks. If the whole string is enclosed with quotation marks then it works...
+        // For example: command '"\epoc32\tools\bmconv" "somefile"' does not work while command
+        // '""\epoc32\tools\bmconv" "somefile""' does.
+        if( system(MifConvString("\""+extConverterCommand+"\""+to+"\"\"").c_str()) < 0 )
+        {
+            int ernro = errno;  // The error number must check straight away before any next system command
+            
+            MifConvString errStr("Executing SVGTBINENCODE failed");
+            if( ernro )
+            {
+                errStr += ", system error = " + MifConvUtil::ToString(ernro);      // Possible system error.
+            }            
+            THROW_ERROR_COMMON(errStr, MifConvString(__FILE__), __LINE__ );
+        }
+    }
+}
+
+/**
+ *
+ */
+void MifConvIconBinaryConverter::CleanupTempFiles()
+{
+    for( MifConvStringList::iterator i = iTempFilenames.begin(); i != iTempFilenames.end(); ++i )
+    {        
+        if( remove( i->c_str() ) != 0 )
+        {            
+            perror( "Error deleting file (svg conversion)" );
+        }
+    }
+    if( iTempDir.length() > 0 && MifConvUtil::RemoveDirectory( iTempDir ) != 0 )
+    {        
+        perror( "Error deleting temporary directory (svg conversion)" );
+    }
+}
+
+/**
+ *
+ */
+const MifConvString& MifConvIconBinaryConverter::GetDefaultExtConverterPath()
+{   
+    if( iDefaultExtConverterPath.length() == 0 )
+    {        
+        // Check if the EPOCROOT is given
+        MifConvString epocRoot(MifConvArgumentManager::Instance()->EpocRoot());
+        if( epocRoot.length() > 0 )
+        {
+            iDefaultExtConverterPath += epocRoot;
+        }
+
+        // Ensure that the last char of the path is dir-separator:
+        if( iDefaultExtConverterPath.length() > 0 )
+        {
+            if( iDefaultExtConverterPath.at(iDefaultExtConverterPath.length()-1) != DIR_SEPARATOR2 )
+            {
+                iDefaultExtConverterPath += DIR_SEPARATOR;
+            }        
+            iDefaultExtConverterPath += SVGTBINENCODE_DEFAULT_PATH;
+        }
+    }
+        
+    return iDefaultExtConverterPath;
+}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/src/mifconv_mifconverter.cpp	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,295 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mifconv MIF converters class.
+*
+*/
+
+
+#include "mifconv.h"
+#include "mifconv_mifconverter.h"
+#include "mifconv_util.h"
+#include "mifconv_exception.h"
+#include "mifconv_argumentmanager.h"
+
+// File versions:
+// V1 - first version.
+// V2 - stores information if icon location (MIF/MBM) inside the MIF file (bitmap offsets array).
+// This way, icon IDs in MBG header can be always the same regardless of which icons are in MIF
+// file and which in MBM file.
+static const int KFileVersion(2);
+static const int KIconVersion(1);
+
+static const int FileHeaderSizeInBytes = 4*4;
+static const int IconHeaderSizeInBytes = 4*8;
+static const int KUidAvkonMultiIconFile(0x034232342);
+static const int KUidAvkonMultiIcon(0x034232343);
+
+//static const int IconFormatType_BMP(0);
+//static const int IconFormatType_SVG(1);
+
+static const unsigned int svgbSignatureLow (0x03FA56CC); //66737868
+static const unsigned int svgbSignatureHigh(0x03FA56CF); //66737871
+
+static const unsigned int nvgSignatureLow (0x0067766E); //('n'+'v'+'g'+0)
+static const unsigned int nvgSignatureHigh(0xFF67766E); //('n'+'v'+'g'+255)
+
+/**
+ *
+ */
+MifConvMifConverter::MifConvMifConverter()
+{
+    MifConvArgumentManager* argMgr = MifConvArgumentManager::Instance();
+    iTargetFilename = argMgr->TargetFile();
+}
+
+/**
+ *
+ */
+MifConvMifConverter::~MifConvMifConverter()
+{
+    // Delete file contents
+    for( StringPtrVector::iterator i = iContentPointers.begin(); i != iContentPointers.end(); ++i )
+    {
+        delete[] *i;
+    }
+}
+
+/**
+ *
+ */
+void MifConvMifConverter::Init()
+{
+    CleanupTargetFiles();
+}
+
+/**
+ *
+ */
+void MifConvMifConverter::CleanupTargetFiles()
+{
+	if( MifConvUtil::FileExists(iTargetFilename) )
+	{
+        // Try to remove file MIFCONV_MAX_REMOVE_TRIES times, no exception in case of failure:
+	    MifConvUtil::RemoveFile(iTargetFilename, MIFCONV_MAX_REMOVE_TRIES, true);
+	}
+}
+
+/**
+ *
+ */
+void MifConvMifConverter::AppendFile( const MifConvSourceFile& sourcefile )
+{     
+	if( MifConvUtil::FileExtension( sourcefile.Filename() ) == BMP_FILE_EXTENSION ||
+        MifConvUtil::FileExtension( sourcefile.Filename() ) == SVG_FILE_EXTENSION ||
+        MifConvUtil::FileExtension( sourcefile.Filename() ) == SVGB_BINARY_FILE_EXTENSION )
+	{        
+		iSourceFiles.push_back( sourcefile );
+	}
+}
+
+void MifConvMifConverter::Convert()
+{
+ 	ReadFileContents();
+    cout << "Writing mif: " << MifConvArgumentManager::Instance()->TargetFile() << endl;
+	ConvertToMif();
+}
+
+void MifConvMifConverter::ReadFileContents()
+{   
+    for( MifConvSourceFileList::iterator i = iSourceFiles.begin(); i != iSourceFiles.end(); ++i )
+    {        
+        // Just read the contents of the .svgb files
+        if( MifConvUtil::FileExtension( i->Filename() ) != BMP_FILE_EXTENSION )
+        {            
+            if( MifConvUtil::FileExists(i->Filename()) == false )
+            {
+                THROW_ERROR_COMMON("Unable to open file for reading! " + i->Filename(), MifConvString(__FILE__), __LINE__ );
+            }            
+            cout << "Loading file: " << i->Filename() << endl;
+            MifConvFileData retVal = MifConvUtil::FileContents(i->Filename());
+            iContentPointers.push_back(retVal.first); // Save pointer for deleting it later
+            i->SetContent(retVal.first, retVal.second);
+        }
+    }
+}
+
+
+void MifConvMifConverter::Cleanup(bool err)
+{
+	CleanupTempFiles();
+	if( err )
+	{
+	    CleanupTargetFiles();
+	}
+}
+
+void MifConvMifConverter::ConvertToMif()
+{  
+    try {
+        OpenTargetFile();
+    }
+    catch( MifConvException& e )
+    {
+        // If file creation/opening was not successful, give warning and return:
+        MifConvString debugStr("WARNING: Target file " + iTargetFilename + " cannot be opened for writing.");
+        cout <<  debugStr  << endl;
+        MifConvUtil::DebugLog(debugStr);
+        return;
+    }
+    WriteTargetHeader();
+    WriteIconArray();
+    WriteIcons();
+}
+
+void MifConvMifConverter::OpenTargetFile()
+{
+    iTargetFile.open( iTargetFilename.c_str(), ios::out|ios::binary );
+
+    if (!iTargetFile.is_open())
+    {
+        // Create path if it does not exist.
+        MifConvUtil::EnsurePathExists(iTargetFilename, true);
+        iTargetFile.clear();
+        iTargetFile.open( iTargetFilename.c_str(), ios::out|ios::binary );
+    }
+    if (!iTargetFile.is_open())
+    {
+        THROW_ERROR_COMMON("Cannot write to file! " + iTargetFilename, MifConvString(__FILE__), __LINE__);
+    }
+}
+
+void MifConvMifConverter::WriteTargetHeader()
+    {
+    size_t arraySize = iSourceFiles.size() * 2;
+    int offset = FileHeaderSizeInBytes;
+    iTargetFile.write( (char*) &KUidAvkonMultiIconFile, 4 );
+    iTargetFile.write( (char*) &KFileVersion, 4 );
+    iTargetFile.write( (char*) &offset, 4 );
+    iTargetFile.write( (char*) &arraySize, 4 );
+    }
+
+void MifConvMifConverter::CleanupTempFiles()
+{
+}
+
+void MifConvMifConverter::WriteIcons()
+{    
+    for( MifConvSourceFileList::iterator i = iSourceFiles.begin(); i != iSourceFiles.end(); ++i )
+    {
+        if( i->ContentLength() > 0 )
+        {
+            WriteIconHeader(*i);
+            WriteIconData(*i);
+        }
+    }
+}
+
+MifConvDefs::IconFormatType MifConvMifConverter::ReadIconBinaryType(const MifConvSourceFile& src)
+{
+    MifConvDefs::IconFormatType ret = MifConvDefs::IconFormatType_SVG;
+    
+    if( src.ContentLength() >= 4 )
+    {
+        const char* iconData = src.Content();
+        
+        if( iconData[0] == 'n' &&
+            iconData[1] == 'v' &&
+            iconData[2] == 'g' )
+        {
+            ret = MifConvDefs::IconFormatType_NVG;
+        }
+    }
+    
+    return ret;
+}
+
+void MifConvMifConverter::WriteIconHeader(const MifConvSourceFile& src)
+{
+    int type = 0;
+    if( MifConvUtil::FileExtension(src.Filename()) == BMP_FILE_EXTENSION )
+        type = MifConvDefs::IconFormatType_BMP;
+    else
+        type = ReadIconBinaryType(src);
+        //type = IconFormatType_SVG;
+
+    int animated = (int) src.IsAnimated();
+    int dataLen = src.ContentLength();
+    int depth = src.DisplayMode();
+    int mask = src.MaskDisplayMode();
+    int dataoffset = IconHeaderSizeInBytes; // 8 = number of writes in this method.
+
+    iTargetFile.write((char*)&KUidAvkonMultiIcon, 4); // 1
+    iTargetFile.write((char*)&KIconVersion, 4);       // 2
+    iTargetFile.write((char*)&dataoffset, 4);         // 3
+    iTargetFile.write((char*)&dataLen, 4);        // 4
+    iTargetFile.write((char*)&type, 4);          // 5
+    iTargetFile.write((char*)&depth, 4);         // 6
+    iTargetFile.write((char*)&animated, 4);      // 7
+    iTargetFile.write((char*)&mask, 4);     // 8
+}
+
+void MifConvMifConverter::WriteIconData(const MifConvSourceFile& src)
+{
+    if( src.Content() )
+    {        
+        iTargetFile.write(src.Content(), src.ContentLength());
+    }
+}
+
+/**
+* 
+*/
+void MifConvMifConverter::WriteIconArray()
+{
+    int offset = (int) FileHeaderSizeInBytes +  (int)iSourceFiles.size()*4*2*2;
+    MifConvSourceFileList::iterator i = iSourceFiles.begin();
+
+    int mbmIndex = 0;
+    int zero = 0;
+
+    for( ; i != iSourceFiles.end(); ++i )
+    {
+        // MIF icon
+        if( MifConvUtil::FileExtension(i->Filename()) != BMP_FILE_EXTENSION )
+        {            
+            int length = i->ContentLength() + IconHeaderSizeInBytes;
+            iTargetFile.write( (char*) &offset, 4 );
+            iTargetFile.write( (char*) &length, 4 );
+            // same information for the mask...
+            iTargetFile.write( (char*) &offset, 4 );
+            iTargetFile.write( (char*) &length, 4 );
+
+            offset += length;            
+        }
+        // MBM icon
+        else
+        {
+            iTargetFile.write( (char*) &mbmIndex, 4 );
+            iTargetFile.write( (char*) &zero, 4 );
+
+            // Masked MBM icon -> There is own MBM index for the mask.
+            if(i->MaskDepth() != IconMaskDepth_Undefined )
+            {
+                mbmIndex--;
+            }
+
+            iTargetFile.write( (char*) &mbmIndex, 4 );
+            iTargetFile.write( (char*) &zero, 4 );
+
+            // MBM incides are coded as negative in the 'offset' field,
+            // so that they can be easily separated from the actual MIF offsets.
+            mbmIndex--;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/src/mifconv_sourcefile.cpp	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,179 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mifconv source file class.
+*
+*/
+
+
+#include "mifconv.h"
+#include "mifconv_sourcefile.h"
+#include "mifconv_util.h"
+#include "mifconv_exception.h"
+#include "mifconv_argument.h"
+#include "mifconv_argumentmanager.h"
+
+MifConvSourceFile::MifConvSourceFile()
+:
+iDepth(IconDepth_Undefined),
+iMaskDepth(IconMaskDepth_Undefined),
+iDisplayMode(DisplayMode_None),
+iMaskDisplayMode(DisplayMode_None),
+iAnimated(false),
+iContent(0),
+iContentLen(0)
+{
+}
+
+MifConvSourceFile::MifConvSourceFile( const MifConvSourceFile& src )
+:
+iFilename( src.Filename() ),
+iDepthString( src.DepthString() ),
+iMaskDepthString( src.MaskDepthString() ),
+iDepth(src.iDepth),
+iMaskDepth(src.iMaskDepth),
+iDisplayMode(src.iDisplayMode),
+iMaskDisplayMode(src.iMaskDisplayMode),
+iAnimated( src.IsAnimated() ),
+iMaskFilename( src.iMaskFilename ),
+iContent(src.iContent),
+iContentLen(src.iContentLen)
+{
+}
+
+MifConvSourceFile::~MifConvSourceFile()
+{}
+
+char* MifConvSourceFile::Content() const
+{
+    return iContent;
+}
+
+int MifConvSourceFile::ContentLength() const
+{
+    return iContentLen;
+}
+
+void MifConvSourceFile::SetContent(char* content, unsigned int len)
+{
+    iContent = content;
+    iContentLen = len;
+}
+
+const MifConvString& MifConvSourceFile::Filename() const
+{
+	return iFilename;
+}
+
+void MifConvSourceFile::SetAnimated( bool isAnimated )
+{
+    iAnimated = isAnimated;
+}
+
+void MifConvSourceFile::SetFilename( const MifConvString& filename )
+{
+	iFilename = filename;
+}
+
+void MifConvSourceFile::SetDisplayMode( IconDisplayMode mode)
+{
+    iDisplayMode = mode;
+}
+
+IconDisplayMode MifConvSourceFile::DisplayMode() const
+{
+    return iDisplayMode;
+}
+
+void MifConvSourceFile::SetMaskDisplayMode( IconDisplayMode mode)
+{
+    iMaskDisplayMode = mode;
+}
+
+IconDisplayMode MifConvSourceFile::MaskDisplayMode() const
+{
+    return iMaskDisplayMode;
+}
+
+IconDepth MifConvSourceFile::Depth() const
+{
+	return iDepth;
+}
+
+void MifConvSourceFile::SetDepth(IconDepth depth)
+{
+	iDepth = depth;
+}
+
+const MifConvString& MifConvSourceFile::DepthString() const
+{
+    return iDepthString;
+}
+
+IconMaskDepth MifConvSourceFile::MaskDepth() const
+{	
+    return iMaskDepth;
+}
+
+void MifConvSourceFile::SetMaskDepth(IconMaskDepth depth)
+{	
+    iMaskDepth = depth;
+}
+
+const MifConvString& MifConvSourceFile::MaskDepthString() const
+{
+   return iMaskDepthString;
+}
+
+bool MifConvSourceFile::IsAnimated() const 
+{
+    return iAnimated;
+}
+
+const MifConvString& MifConvSourceFile::BmpMaskFilename() const
+{
+    return iMaskFilename;
+}
+
+void MifConvSourceFile::SetBmpMaskFilename( const MifConvString& maskFilename )
+{
+	iMaskFilename = maskFilename;
+}
+
+void MifConvSourceFile::SetDepthString( const MifConvString& depth )
+{
+	iDepthString = depth;
+}
+
+void MifConvSourceFile::SetMaskDepthString( const MifConvString& mask )
+{
+	iMaskDepthString = mask;
+}
+
+void MifConvSourceFile::SetDepthAndMask( const MifConvString& depthAndMask )
+{   
+    size_t separatorIndex = depthAndMask.find(",");
+    
+    if( separatorIndex != MifConvString::npos )
+    {
+        iDepthString = MifConvString(depthAndMask.begin()+1, depthAndMask.begin()+separatorIndex);
+        iMaskDepthString = MifConvString(depthAndMask.begin()+separatorIndex+1, depthAndMask.end());        
+        iMaskDepth = MifConvArgumentManager::Instance()->ConvertToMaskDepth(iMaskDepthString);
+    }
+    else
+    {
+        iDepthString = MifConvString(depthAndMask.begin()+1, depthAndMask.end());
+    }
+    iDepth = MifConvArgumentManager::Instance()->ConvertToDepth(iDepthString); 
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxconversion/mifconv/src/mifconv_util.cpp	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,593 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mifconv utilities.
+*
+*/
+
+
+#include "mifconv.h"
+#include "mifconv_util.h"
+#include "mifconv_exception.h"
+#include "mifconv_argumentmanager.h"
+#include <sys/stat.h>   // for stat
+#ifdef WIN32
+    #include <direct.h>     // for _getcwd, _chdir, _mkdir
+#else
+    #include <unistd.h>
+#endif
+#include <stdlib.h>     // for _MAX_PATH
+#include <stdio.h>
+
+#ifndef _MAX_PATH
+#define _MAX_PATH   (260)
+#endif
+
+MifConvUtil::MifConvDebugMode MifConvUtil::iDebugMode = DebugMode_Unknown;
+MifConvString MifConvUtil::iDebugFile = "";
+MifConvString MifConvUtil::iTempDirectory = "";
+
+/**
+ *
+ */
+MifConvString MifConvUtil::FileExtension( const MifConvString& fileName )
+{	
+	size_t indexOfDot; // index of '.' character in the given string
+
+	// Find last occurence of the '.' character
+	if( ( indexOfDot = fileName.find_last_of('.') ) == MifConvString::npos )
+	{
+		// Not found, return empty string
+		return MifConvString("");
+	}
+
+	// Return the substring starting after the '.' character
+	return MifConvString( fileName.begin()+indexOfDot+1, fileName.end() );
+}
+
+/**
+ *
+ */
+MifConvString MifConvUtil::FilenameWithoutExtension( const MifConvString& fileName )
+{	
+	size_t indexOfDot; // index of '.' character in the given string
+
+	// Find last occurence of the '.' character
+	if( ( indexOfDot = fileName.find_last_of('.') ) == MifConvString::npos )
+	{
+		// Not found, return the whole name
+		return fileName;
+	}
+
+	// Return the substring preceding the last '.' character
+	return MifConvString( fileName.begin(), fileName.begin() + indexOfDot );
+}
+
+/**
+ *
+ */
+MifConvString MifConvUtil::FilenameWithoutPath( const MifConvString& fileName )
+{	
+	size_t indexOfDirSeparator; // index of directory separator in the given string
+
+	// Find last occurence of the '.' character
+	if( ( indexOfDirSeparator = fileName.find_last_of(DIR_SEPARATOR2) ) == MifConvString::npos )
+	{
+		// Not found, return the whole name
+		return fileName;
+	}
+
+	// Return the substring beginnig after the last directory separator
+	return MifConvString( fileName.begin()+indexOfDirSeparator+1, fileName.end() );
+}
+
+/**
+ *
+ */
+bool MifConvUtil::FileExists( const MifConvString& fileName )
+{
+  struct stat fileInfo;   
+  int retVal = 0; 
+
+  // Try to get file attributes to see if the file exists or not:
+  retVal = stat( fileName.c_str(), &fileInfo); 
+  return retVal == 0;
+}
+
+/**
+ *
+ */
+size_t MifConvUtil::FileSize( const MifConvString& fileName )
+{
+  struct stat fileInfo;   
+  int retVal = 0; 
+
+  // Try to get file attributes to see if the file exists or not:
+  retVal = stat( fileName.c_str(), &fileInfo); 
+  if( retVal != 0 )
+  {
+      THROW_ERROR_COMMON("File not found: " + fileName, MifConvString(__FILE__), __LINE__);
+  }
+
+  return fileInfo.st_size;
+}
+
+/**
+ *
+ */
+MifConvFileData MifConvUtil::FileContents( const MifConvString& fileName )
+{
+    unsigned int fileLen = (unsigned int) (MifConvUtil::FileSize(fileName)/sizeof(char));
+    
+    ifstream fs( fileName.c_str(), FILE_IN_BINARY_NOCREATE_FLAGS );
+    if (!fs.is_open())
+    {
+        THROW_ERROR_COMMON("Unable to open file for reading! " + fileName, MifConvString(__FILE__), __LINE__);
+    }
+    char* buffer = new char[fileLen];
+    fs.read(buffer, fileLen);
+    return MifConvFileData(buffer, fileLen);
+}
+
+/**
+ *
+ */
+void MifConvUtil::ReplaceChar( MifConvString& str, char replaceFrom, char replaceTo)
+{
+    if( str.length() > 0 )
+    {        
+        MifConvString::size_type index = 0;
+        while( (index = str.find(replaceFrom, index)) != MifConvString::npos )
+        {     
+            str.replace(index,1,1,replaceTo);
+        }
+    }
+}
+
+/**
+ *
+ */
+void MifConvUtil::SplitPath( const MifConvString& sourcePath, MifConvString& drive, MifConvString& path)
+    {    
+        if( sourcePath.length() > 0 )
+        {
+            size_t driveSeparatorPos = sourcePath.find(':');
+            if( driveSeparatorPos != MifConvString::npos )
+            {
+                drive = MifConvString(sourcePath.begin(), sourcePath.begin() + driveSeparatorPos );
+                path = MifConvString(sourcePath.begin() + driveSeparatorPos + 1, sourcePath.end() );
+            }
+            else
+            {
+                path = sourcePath;
+            }
+        }
+        else
+        {
+            drive = MifConvString("");
+            path = MifConvString("");
+        }
+}
+
+/**
+ *
+ */
+MifConvString MifConvUtil::CurrentPath()
+{
+    char temp[_MAX_PATH];
+#ifdef WIN32    
+    _getcwd(temp, _MAX_PATH);    
+#else
+    getcwd(temp, _MAX_PATH);
+#endif
+    return MifConvString(temp);
+}
+
+/**
+ *
+ */
+int MifConvUtil::CompareIgnoreCase( const MifConvString& lhs, const MifConvString& rhs )
+{
+    MifConvString lhsCopy(lhs);
+    MifConvString rhsCopy(rhs);
+
+    return ToLower(lhsCopy).compare(ToLower(rhsCopy));
+}
+
+/**
+ *
+ */
+MifConvString& MifConvUtil::ToLower( MifConvString& str )
+{
+    MifConvString::iterator it(str.begin());
+    for(; it != str.end(); ++it)
+    {
+        *it = (char) tolower((unsigned char)*it);
+    }
+    return str;
+}
+
+/**
+ *
+ */
+void MifConvUtil::EnsurePathExists( const MifConvString& destFileName, bool ignoreLast )
+    {
+    MifConvString currentPath;
+    MifConvString tmpDrive;    
+    MifConvString tmpPath;
+
+    // Parse a drive of a destination path; if any
+    SplitPath( destFileName, tmpDrive, tmpPath );
+
+    // Save current directory    
+    currentPath = CurrentPath();
+
+    // Change drive if needed:
+    if( tmpDrive.length() > 0 )
+    {        
+        tmpDrive += ":";
+        tmpDrive += DIR_SEPARATOR;
+        ChangeDirectory(tmpDrive);        
+    }
+
+    // Split desination path to separate directories:
+    MifConvStringList destDirList;
+
+    // Check if the root is given first and add it to dir list:
+    if( tmpPath.length() > 0 && tmpPath.at(0) == DIR_SEPARATOR2 )
+    {
+        destDirList.push_back(DIR_SEPARATOR);
+    }
+
+    // Add other directories to destination dir list:
+    SplitString( tmpPath, DIR_SEPARATOR, destDirList );
+
+    // Remove last component from the list if it should be ignored:
+    if( ignoreLast )
+    {
+        destDirList.pop_back();
+    }
+
+    unsigned int i = 0;
+    while( i < destDirList.size() )
+    {        
+        const MifConvString& dir = destDirList[i++];         
+        if( !FileExists(dir) )
+        {
+            if( !CreateDirectory( dir ) )
+            {
+                // Change back to original directory:
+                ChangeDirectory( currentPath );
+                THROW_ERROR_COMMON("Directory " + tmpPath + " cannot be created", MifConvString(__FILE__), __LINE__);
+            }
+        }
+        ChangeDirectory( dir );        
+    }
+
+    // Change back to original directory:
+    ChangeDirectory( currentPath );
+}
+
+/**
+ *
+ */
+void MifConvUtil::RemoveDuplicateDirSeparators( MifConvString& str )
+{    
+    MifConvString searchString(DIR_SEPARATOR);
+    searchString += DIR_SEPARATOR;
+    size_t pos = str.find(searchString);
+
+    while(pos != MifConvString::npos)
+    {
+        str.erase(pos, 1);
+        pos = str.find(searchString); 
+    }
+}
+
+/**
+ *
+ */
+bool MifConvUtil::CreateDirectory( const MifConvString& path )
+{    
+#ifdef WIN32
+    return _mkdir( path.c_str() ) == 0;
+#else
+    return mkdir( path.c_str(), 0777 ) == 0;
+#endif
+}
+
+/**
+ *
+ */
+void MifConvUtil::SplitString( const MifConvString& str, const MifConvString& separator, MifConvStringList& components )
+{
+    size_t beginPos = 0;
+    size_t endPos = 0;
+
+    while( (endPos = str.find(separator, beginPos)) != MifConvString::npos )
+    {
+        if( endPos - beginPos > 0 )
+        {
+            components.push_back( MifConvString( str.begin()+beginPos, str.begin()+endPos ) );            
+        }
+        beginPos = endPos+1;
+    }
+    if( str.begin()+beginPos != str.end() )
+    {
+        components.push_back( MifConvString(str.begin()+beginPos, str.end()) );
+    }
+}
+
+/**
+ *
+ */
+MifConvString MifConvUtil::UnadornedFilename( const MifConvString& filename )
+{    
+    MifConvStringList splitted;
+    SplitString(filename, DIR_SEPARATOR, splitted);
+
+    MifConvString tmp(splitted.back());
+    splitted.clear();
+    SplitString(tmp, INCORRECT_DIR_SEPARATOR, splitted);
+
+    tmp = splitted.back();
+    splitted.clear();
+    SplitString(tmp, FILE_EXTENSION_SEPARATOR, splitted);
+
+    MifConvString fixedname;
+    
+    if( splitted.size() > 0 )
+    {
+        fixedname = ToLower(splitted[0]);
+        if( fixedname.length() > 0 )
+        {
+            fixedname[0] = (char) toupper( fixedname[0] );
+        }
+    }
+    return fixedname;
+}
+
+/**
+ *
+ */
+void MifConvUtil::FindAndSetBitmapMaskFile( MifConvSourceFile& srcFile )
+{
+    if( srcFile.MaskDepth() == IconMaskDepth_Undefined )
+    {
+        return; // No mask file
+    }
+    MifConvString fileExtension(FileExtension( srcFile.Filename() ));
+
+    if( CompareIgnoreCase(fileExtension, BMP_FILE_EXTENSION) != 0 )
+    {
+        return;
+    }
+
+    MifConvString maskFilename(FilenameWithoutExtension(srcFile.Filename()));
+
+    if( srcFile.MaskDepth() == IconMaskDepth_1 )
+    {
+        maskFilename += "_mask.bmp";
+    }
+    else if( srcFile.MaskDepth() == IconMaskDepth_8 )
+    {
+        maskFilename += "_mask_soft.bmp";
+    }
+    else
+    {
+        THROW_ERROR_COMMON("Invalid mask depth\n", MifConvString(__FILE__), __LINE__);
+    }
+
+    if( !FileExists(maskFilename) )
+    {
+        cerr << endl << "*** WARNING! Missing bitmap: " << maskFilename << endl;
+    }
+
+    srcFile.SetBmpMaskFilename( maskFilename );
+}
+
+/**
+ *
+ */
+MifConvString MifConvUtil::TemporaryFilename()
+{
+    MifConvString tmp(tmpnam(NULL));
+    MifConvString::iterator i = tmp.begin();
+
+    if( *i == '.' )
+    {
+        ++i;
+    }
+
+    if( *i == DIR_SEPARATOR2 || *i == INCORRECT_DIR_SEPARATOR2 )
+    {
+        ++i;
+    }
+
+    return MifConvString(i, tmp.end());
+}
+
+/**
+ *
+ */
+bool MifConvUtil::CopyFile(const MifConvString& from, const MifConvString& to)
+{
+    bool retval = false;
+    ifstream in(from.c_str(), ios::binary);    
+    if( in )
+    {
+        ofstream out(to.c_str(), ios::binary);        
+        if( out )
+        {
+            out << in.rdbuf();
+            retval = out.good();
+            out.close();
+        }
+        in.close();
+    }
+    return retval;
+} 
+
+/**
+ *
+ */
+bool MifConvUtil::IsWhiteSpace(char c)
+{
+    return c == ' ' || c == '\n' || c == '\r' || c == '\t';
+}
+
+/**
+ *
+ */
+void MifConvUtil::ChangeDirectory( const MifConvString& dirName )
+{
+#ifdef WIN32
+    _chdir( dirName.c_str() );
+#else
+    chdir( dirName.c_str() );
+#endif
+}
+
+/**
+ *
+ */
+int MifConvUtil::RemoveDirectory( const MifConvString& dirName )
+{
+#ifdef WIN32
+    return _rmdir( dirName.c_str() );
+#else
+    return rmdir( dirName.c_str() );
+#endif
+}
+
+/**
+ *
+ */
+void MifConvUtil::RemoveFile( const MifConvString& fileName, int maxTries, bool noException )
+{
+    for( int i = 0; i < maxTries; ++i )
+    {    
+#ifdef WIN32
+        int ret = _unlink(fileName.c_str());
+#else
+        int ret = unlink(fileName.c_str());
+#endif
+        
+        if( ret == 0 )
+        {        
+            // Delete was successful
+            return;
+        }
+        
+        // Delete was not successful
+        if( i >= maxTries-1 )
+        {
+            // Max amount of tries exceeded -> print warning or throw an exception
+            if( noException )
+            {
+                MifConvString debugStr("WARNING: Cannot remove file " + fileName);
+                DebugLog(debugStr);
+            }
+            else
+            {
+                THROW_ERROR_COMMON("Cannot remove file " + fileName, MifConvString(__FILE__), __LINE__);
+            }
+        }       
+    }
+}
+
+/**
+ *
+ */
+MifConvString MifConvUtil::DebugFile()
+{
+    char* tmpPtr = getenv(MIFCONV_DEBUG_FILE_ENV.c_str());
+    if( tmpPtr )
+    {
+        return MifConvString(tmpPtr);        
+    }
+    return MifConvString();
+}
+
+/**
+ *
+ */
+void MifConvUtil::DebugLog(const MifConvString& debugStr)
+{
+    if( iDebugMode == DebugMode_Unknown )
+    {      
+        iDebugFile = MifConvUtil::DebugFile();
+        if( iDebugFile.length() > 0 )
+        {
+            iDebugMode = DebugMode_Debug;            
+        }
+        else
+        {
+            iDebugMode = DebugMode_NoDebug;
+        }
+    }
+
+    if( iDebugMode == DebugMode_Debug )
+    {
+        ios_base::openmode file_flags;
+        if( MifConvUtil::FileExists(iDebugFile) )
+        {                
+            file_flags = ios::out|ios::app;
+        }
+        else
+        {             
+            file_flags = ios::out|ios::trunc;
+        }
+        fstream debugLog(iDebugFile.c_str(), file_flags);
+        if(debugLog.is_open())
+        { 
+            debugLog << debugStr << endl;
+            debugLog.close();
+        }
+    }      
+}
+
+/**
+ *
+ */
+const MifConvString& MifConvUtil::DefaultTempDirectory()
+    {
+    if( iTempDirectory.length() == 0 )
+        {
+        char* tmpPtr = getenv(SBS_BUILD_DIR_ENV.c_str());
+        if( tmpPtr && MifConvString(tmpPtr).length() > 0 )
+            {
+            iTempDirectory = MifConvString(tmpPtr);
+            
+            if( iTempDirectory.at(iTempDirectory.length()-1) != DIR_SEPARATOR2 )
+                {                
+                iTempDirectory += DIR_SEPARATOR;
+                }
+            
+            iTempDirectory += EPOC_ICON_BUILD_PATH_POSTFIX + 
+                MifConvString(DIR_SEPARATOR) + 
+                MifConvString("temp");
+            }
+        else
+            {
+            iTempDirectory = MifConvArgumentManager::Instance()->EpocRoot() + 
+                EPOC_BUILD_PATH + 
+                MifConvString(DIR_SEPARATOR) + 
+                EPOC_ICON_BUILD_PATH_POSTFIX + 
+                MifConvString(DIR_SEPARATOR) + 
+                MifConvString("temp");
+            }
+        }
+    return iTempDirectory;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/group/bld.inf	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+
+    bld.inf Top-level build information for platformtools
+
+-----------------------------------------------------------------------------
+*/
+
+#include "../gfxconversion/group/bld.inf"
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/layers.sysdef.xml	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<!DOCTYPE SystemDefinition SYSTEM "sysdef_1_4_0.dtd" [
+  <!ENTITY layer_real_source_path "sf/mw/platformtools" >
+]>
+
+<SystemDefinition name="platformtools" schema="1.4.0">
+  <systemModel>
+    <layer name="mw_layer">
+      <module name="platformtools">
+        <unit unitID="tools.platformtools" mrp="" bldFile="&layer_real_source_path;/group" name="platformtools" />
+      </module>
+    </layer>
+  </systemModel>
+</SystemDefinition>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/package_definition.xml	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<SystemDefinition schema="3.0.0">
+  <package id="platformtools" name="Platform Tools">
+    <collection id="gfxconversion" name="Graphics Conversion">
+      <component id="bmconv_s60" filter="s60" name="S60 Bitmap Converter">
+			<!-- component need to be moved to appropriate location -->
+        <unit bldFile="/tools/platformtools/gfxconversion/bmconv_s60/group"/>
+      </component>
+      <component id="mifconv" filter="s60" name="Multi Icon File Converter">
+			<!-- component need to be moved to appropriate location -->
+        <unit bldFile="/tools/platformtools/gfxconversion/mifconv/group"/>
+      </component>
+    </collection>
+  </package>
+</SystemDefinition>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysdef_1_4_0.dtd	Tue Feb 02 01:11:11 2010 +0200
@@ -0,0 +1,86 @@
+ <!ELEMENT SystemDefinition (systemModel?, build?)>
+ <!ATTLIST SystemDefinition
+  name CDATA #REQUIRED
+  schema CDATA #REQUIRED>
+ <!ELEMENT systemModel (layer+)>
+ <!ELEMENT layer (logicalset* | module*)*>
+ <!ATTLIST layer
+  name CDATA #REQUIRED
+  levels CDATA #IMPLIED
+  span CDATA #IMPLIED>
+ <!ELEMENT logicalset (logicalsubset* | module* | unit* | package* | prebuilt*)*>
+ <!ATTLIST logicalset name CDATA #REQUIRED>
+ <!ELEMENT logicalsubset (module* | unit* | package* | prebuilt*)*>
+ <!ATTLIST logicalsubset name CDATA #REQUIRED>
+ <!ELEMENT module (component* | unit* | package* | prebuilt*)*>
+ <!ATTLIST module
+  name CDATA #REQUIRED
+  level CDATA #IMPLIED>
+ <!ELEMENT component (unit* | package* | prebuilt*)*>
+ <!ATTLIST component name CDATA #REQUIRED>
+ <!ELEMENT unit EMPTY>
+ <!ATTLIST unit
+  unitID ID #REQUIRED
+  name CDATA #REQUIRED
+  mrp CDATA #REQUIRED
+  filter CDATA #IMPLIED
+  bldFile CDATA #REQUIRED
+  priority CDATA #IMPLIED
+  contract CDATA #IMPLIED>
+ <!ELEMENT package EMPTY>
+ <!ATTLIST package
+  name CDATA #REQUIRED
+  mrp CDATA #REQUIRED
+  filter CDATA #IMPLIED
+  contract CDATA #IMPLIED>
+ <!ELEMENT prebuilt EMPTY>
+ <!ATTLIST prebuilt
+  name CDATA #REQUIRED
+  version CDATA #REQUIRED
+  late (Y|N) #IMPLIED
+  filter CDATA #IMPLIED
+  contract CDATA #IMPLIED>
+ <!ELEMENT build (option* | target+ | targetList+ | unitList+ | configuration+)*>
+ <!ELEMENT unitList (unitRef+)>
+ <!ATTLIST unitList
+  name ID #REQUIRED
+  description CDATA #REQUIRED>
+ <!ELEMENT unitRef EMPTY>
+ <!ATTLIST unitRef unit IDREF #REQUIRED>
+ <!ELEMENT targetList EMPTY>
+ <!ATTLIST targetList
+  name ID #REQUIRED
+  description CDATA #REQUIRED
+  target IDREFS #REQUIRED>
+ <!ELEMENT target EMPTY>
+ <!ATTLIST target
+  name ID #REQUIRED
+  abldTarget CDATA #REQUIRED
+  description CDATA #REQUIRED>
+ <!ELEMENT option EMPTY>
+ <!ATTLIST option
+  name ID #REQUIRED
+  abldOption CDATA #REQUIRED
+  description CDATA #REQUIRED
+  enable (Y | N | y | n) #REQUIRED>
+ <!ELEMENT configuration (unitListRef+ | layerRef+ | task+)*>
+ <!ATTLIST configuration
+  name ID #REQUIRED
+  description CDATA #REQUIRED
+  filter CDATA #REQUIRED>
+ <!ELEMENT task ( unitListRef* , (buildLayer | specialInstructions))>
+ <!ELEMENT unitListRef EMPTY>
+ <!ATTLIST unitListRef unitList IDREF #REQUIRED>
+ <!ELEMENT layerRef EMPTY>
+ <!ATTLIST layerRef layerName CDATA #REQUIRED>
+ <!ELEMENT buildLayer EMPTY>
+ <!ATTLIST buildLayer
+  command CDATA #REQUIRED
+  targetList IDREFS #IMPLIED
+  unitParallel (Y | N | y | n) #REQUIRED
+  targetParallel (Y | N | y | n) #IMPLIED>
+ <!ELEMENT specialInstructions EMPTY>
+ <!ATTLIST specialInstructions
+  name CDATA #REQUIRED
+  cwd CDATA #REQUIRED
+  command CDATA #REQUIRED>