00001 /* 00002 * Copyright © 2008 Nokia Corporation. 00003 */ 00004 00005 #ifndef __IMAGECONVERTER_H__ 00006 #define __IMAGECONVERTER_H__ 00007 00008 #include <e32std.h> 00009 #include <e32base.h> 00010 #include <f32file.h> 00011 #include <ImageConversion.h> 00012 #include <aknglobalnote.h> 00013 00014 class CFbsBitmap; 00015 class CBitmapRotator; 00016 class CBitmapScaler; 00017 00018 class MConverterController 00019 { 00020 public: 00021 virtual void NotifyCompletion( TInt aErr, const TDesC& aMsg ) = 0; 00022 virtual TBool IsAnimating() = 0; 00023 }; 00024 00025 // states for this engine 00026 enum TState 00027 { 00028 EIdle = 0, 00029 EDecoding, 00030 EEncoding, 00031 ERotating, 00032 EScaling 00033 }; 00034 00035 class CImageConverterEngine : public CActive 00036 { 00037 00038 public: 00039 // rotation directions 00040 enum TDirection 00041 { 00042 EClockwise90 = 0, 00043 EAntiClockwise90 00044 }; 00045 00046 public: // contructors/destructors 00047 00048 /* 00049 * NewL 00050 * 00051 * Create a CImageConverterEngine object and return a pointer to it. 00052 * 00053 * Params: 00054 * aController Pointer to a MConverterController interface. 00055 * The engine uses NotifyCompletion callback from this interface 00056 * to notify the controller about completions of coding or 00057 * encoding requests. 00058 * 00059 * Returns: 00060 * A pointer to the created engine 00061 * 00062 */ 00063 static CImageConverterEngine* NewL( MConverterController* aController ); 00064 00065 ~CImageConverterEngine(); 00066 00067 public: // interface methods 00068 00069 /* 00070 * StartToDecodeL 00071 * 00072 * Starts to decode an image from a file. When completed calls 00073 * NotifyCompletion, from iController. 00074 * 00075 * Params: 00076 * aFileName Full path and filename of the image to be decoded. 00077 * 00078 * Returns: 00079 * Nothing 00080 */ 00081 void StartToDecodeL( TFileName& aFileName ); 00082 00083 /* 00084 * StartToEncodeL 00085 * 00086 * Starts to encode an image to a file. When completed calls 00087 * NotifyCompletion, from iController. 00088 * 00089 * Params: 00090 * aFileName Full path and filename to the image to be encoded. 00091 * 00092 * Returns: 00093 * Nothing 00094 */ 00095 void StartToEncodeL( TFileName& aFileName, 00096 TUid aImageType, TUid aImageSubType ); 00097 00098 /* 00099 * GetImageInfoL 00100 * 00101 * Gets frame 0 info strings. An image has to be decoded before 00102 * call to this method, otherwise will return NULL. 00103 * 00104 * Params: 00105 * None 00106 * 00107 * Returns: 00108 * CFrameInfoStrings* See Symbian OS documentation for 00109 * reference. 00110 */ 00111 CFrameInfoStrings* GetImageInfoL(); 00112 00113 /* 00114 * GetEncoderImageTypesL 00115 * 00116 * Gets descriptions of supported (encoding) image types. 00117 * 00118 * Params: 00119 * aImageTypeArray Reference to an array to be filled. 00120 * See Symbian OS documentation for reference. 00121 * 00122 * Returns: 00123 * Nothing 00124 */ 00125 static void GetEncoderImageTypesL( 00126 RImageTypeDescriptionArray& aImageTypeArray ); 00127 00128 /* 00129 * Rotate 00130 * 00131 * Rotates the image to the given direction. 00132 * 00133 * Params: 00134 * aDirection The direction to rotate to. 00135 * 00136 * Returns: 00137 * Nothing 00138 */ 00139 void Rotate( TDirection aDirection ); 00140 00141 /* 00142 * Scale 00143 * 00144 * Scales the image to the given percentage of the current size. 00145 * 00146 * Params: 00147 * aPercent The new size relative to the current size 00148 * (e.g. 110 will increase the size by 10 %). 00149 * 00150 * Returns: 00151 * Nothing 00152 */ 00153 TInt Scale( TInt aPercent ); 00154 00155 /* 00156 * GetBitmap 00157 * 00158 * Returns a pointer to the decoded image. 00159 * 00160 * Params: 00161 * None 00162 * 00163 * Returns: 00164 * A pointer to the encoded image 00165 */ 00166 CFbsBitmap* GetBitmap(); 00167 00168 void ShowProgress(); 00169 void CancelProgress(); 00170 00171 TBool CanDownScaleMore(); 00172 00173 inline TState EngineState(){return iState;}; 00174 00175 protected: // implementation of CActive 00176 void DoCancel(); 00177 void RunL(); 00178 TInt RunError(TInt aError); 00179 00180 private: // internal methods 00181 CImageConverterEngine( MConverterController* aController ); 00182 void ConstructL(); 00183 TBool FitToScreen(); 00184 void DoFitToScreen(); 00185 00186 00187 private: // internal data 00188 /* 00189 * Access to the decoded image, 00190 * images are also encoded from this bitmap. 00191 */ 00192 CFbsBitmap* iBitmap; // decoded image 00193 MConverterController* iController; // ui controller 00194 RFs iFs; // for opening/saving images from/to files 00195 CImageDecoder* iImageDecoder; // decoder from ICL API 00196 CImageEncoder* iImageEncoder; // encoder from ICL API 00197 CBitmapRotator* iRotator; 00198 CBitmapScaler* iScaler; 00199 TState iState; 00200 CAknGlobalNote* iGlobalNote; 00201 TInt iNoteId; 00202 TFileName iFilename; 00203 TInt iScaleDownCounter; 00204 }; 00205 00206 #endif // #ifndef __IMAGECONVERTER_H__
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.