imageeditorengine/inc/CJpegSave.h
changeset 1 edfc90759b9f
equal deleted inserted replaced
0:57d4cdd99204 1:edfc90759b9f
       
     1 /*
       
     2 * Copyright (c) 2010 Ixonos Plc.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - Initial contribution
       
    11 *
       
    12 * Contributors:
       
    13 * Ixonos Plc
       
    14 *
       
    15 * Description:  
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 //
       
    21 // Jpeg encoder class
       
    22 
       
    23 
       
    24 #ifndef __CJPEGSAVE_H__
       
    25 #define __CJPEGSAVE_H__
       
    26 
       
    27 #include <e32base.h>
       
    28 #include <f32file.h>
       
    29 
       
    30 #include "TBitmapHandle.h"
       
    31 #include "MJpegSave.h"
       
    32 
       
    33 class CFbsBitmap;
       
    34 class TSHuffman;
       
    35 
       
    36 class CJpegSave
       
    37 	: public CBase
       
    38 	, public MJpegSave
       
    39 	{
       
    40 	public:
       
    41 		static CJpegSave* NewL( RFs* aFs, RFile* aFile );
       
    42 		static CJpegSave* NewLC( RFs* aFs, RFile* aFile );
       
    43 		~CJpegSave();
       
    44 
       
    45 	private:
       
    46 		CJpegSave( RFs* aFs, RFile* aFile );
       
    47 		void ConstructL();
       
    48 
       
    49 	public: // MJpegSave
       
    50 		//void SaveL( const CFbsBitmap* aBitmap, const TDesC16& aFileName );
       
    51 		void StartSaveL( const TSize& aSize, TPtr8 aExif, TInt aSaveBufferSize, TInt aQuality );
       
    52 		void SaveBlock( const TBitmapHandle& aBitmap );
       
    53 		void FinalizeSave();
       
    54 		TPtrC8 Finalize();
       
    55 
       
    56 	private:
       
    57 		void WriteHuffman( TInt aValue );
       
    58 		void CreateHuffmanL( TSHuffman* aHuffman, const TUint8* aBits, const TUint8* aVal );
       
    59 		void WriteBits( TUint32 aValue, TInt aNumBits );
       
    60 		TInt WriteDct( TInt* aDct, TSHuffman* aDc, TSHuffman* aAc );
       
    61 		void Dct( TInt* aSource, TInt* aTarget );
       
    62 		void Rgb2Yuv( TUint32* aRgb, TInt aWidth, TInt* aY, TInt* aU, TInt* aV );
       
    63 		void MakeTables( TInt aQuality, TUint8* aY, TUint8* aUV );
       
    64 
       
    65 		void WriteSaveBuffer( const TUint8* aSrc, TInt aBytes );
       
    66 		void WriteSaveBuffer( TUint8 aValue );
       
    67 		void WriteSaveBuffer( TUint16 aValue );
       
    68 		void FlushSaveBuf();
       
    69 
       
    70 	private:
       
    71 
       
    72 		RFs* iFs;
       
    73 		RFile* iSaveFile;
       
    74 		TInt iSaveBufSize;
       
    75 		TUint8* iSaveBuf;
       
    76 		TInt iSaveBufPos;
       
    77 		TInt iSaveBufBitPos;
       
    78 		TUint8 iSaveByte;
       
    79 /*
       
    80 		TUint8* iBuffer;
       
    81 		TInt iBufPos;
       
    82 		TInt iBufBitPos;
       
    83 */
       
    84 		TSHuffman* iHuffman[ 4 ];
       
    85 		TSHuffman* iCurrentHuffman;
       
    86 		TUint8* iCurrentQuant;
       
    87 
       
    88 		TInt iDctMul[ 64 ][ 64 ];
       
    89 
       
    90 		TInt iDy;
       
    91 		TInt iDu;
       
    92 		TInt iDv;
       
    93 
       
    94 		TUint8 iYQuant[ 64 ];
       
    95 		TUint8 iUVQuant[ 64 ];
       
    96 
       
    97 	};
       
    98 
       
    99 #endif