imageeditor/ImageEditorManager/inc/ImageEditorImageHandler.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 #ifndef IMAGEEDITORIMAGEHANDLER_HPP
       
    22 #define IMAGEEDITORIMAGEHANDLER_HPP
       
    23 
       
    24 //	INCLUDES
       
    25 #include <e32base.h>
       
    26 
       
    27 //	FORWARD DECLARATIONS
       
    28 class CImageDecoder;
       
    29 class CImageEncoder;
       
    30 class CFbsBitmap;
       
    31 class MImageHandlerObserver;
       
    32 class TRequestStatus;
       
    33 class CFileExtensionMIMEType;
       
    34 class CFrameImageData;
       
    35 
       
    36 
       
    37 /*	CLASS: CImageEditorImageHandler
       
    38 *
       
    39 *   CImageEditorImageHandler represents image handling unit in Image Editor.
       
    40 *	It includes functionality to asynchronously load and save images. Also,
       
    41 *	it provides other image managing functionality.
       
    42 *
       
    43 */
       
    44 class CImageEditorImageHandler : public CBase
       
    45 {
       
    46 
       
    47 public:
       
    48 
       
    49 /** @name Methods:*/
       
    50 //@{
       
    51 
       
    52 	enum TImageFormat
       
    53 	{
       
    54 		EImageFormatInvalid,
       
    55 		EImageFormatBmp,
       
    56 		EImageFormatJpg,
       
    57 		EImageFormatMbm,
       
    58 		EImageFormatGif,
       
    59 		EImageFormatPng,
       
    60 		EImageFormatTiff,
       
    61 		EImageFormatMax
       
    62 	};
       
    63 
       
    64 /** @name Methods:*/
       
    65 //@{
       
    66 
       
    67 	/** NewL factory method, pops cleanupstack
       
    68 	*
       
    69 	*	@param -
       
    70 	*	@return pointer to created CImageEditorImageHandler object
       
    71 	*/
       
    72 	IMPORT_C static CImageEditorImageHandler * NewL ();
       
    73 
       
    74 	/** Destructor
       
    75 	*
       
    76 	*	@param -
       
    77 	*	@return -
       
    78 	*/
       
    79 	IMPORT_C virtual ~CImageEditorImageHandler ();
       
    80 
       
    81 	/** LoadImageAsync
       
    82 	*
       
    83 	*	Loads image asyncronically. Calls RunL method of an active object
       
    84 	*	when loading complete.
       
    85 	*
       
    86 	*	@param aFileName - name of the image file to be loaded
       
    87 	*	@param aBitmap - bitmap to which image is loaded, must be created
       
    88 	*	@param aStatus - status indicator
       
    89 	*	and set to wanted size and displaymode
       
    90 	*	@return -
       
    91 	*/
       
    92 	IMPORT_C void LoadImageAsyncL (
       
    93 		const TDesC &		aFileName,
       
    94 		CFbsBitmap *&		aBitmap,
       
    95 		TRequestStatus *	aStatus
       
    96 		);
       
    97 
       
    98 	/** ContinueLoading
       
    99 	*
       
   100 	*	Continues loading of image data, if KErrUnderflow occurs.
       
   101 	*
       
   102 	*	@param aStatus - request status
       
   103 	*	@return -
       
   104 	*/
       
   105 	IMPORT_C void ContinueLoading (TRequestStatus *	aStatus);
       
   106 
       
   107     /** SaveImageAsync
       
   108 	*
       
   109 	*	Saves image asyncronically. Calls RunL method of an active object
       
   110 	*	when saving complete.
       
   111 	*
       
   112 	*	@param aFileName - saved image name
       
   113 	*	@param aBitmap - bitmap to be saved
       
   114 	*	@param aImageQuality - JPEG image quality (0,100)
       
   115 	*	@param aStatus - status indicator
       
   116 	*	@return -
       
   117 	*/
       
   118 	IMPORT_C void SaveImageAsyncL (
       
   119 		const TDesC	&		aFileName,
       
   120 		const CFbsBitmap &	aBitmap,
       
   121 		const TInt			aImageQuality,
       
   122 		TRequestStatus *	aStatus
       
   123 		);
       
   124 
       
   125 	/** GetJpegQualityFactorL
       
   126 	*
       
   127 	*	Gets the JPEG quality factor.
       
   128 	*
       
   129 	*	@param aFileName - saved image name
       
   130 	*	@return - the quality factor
       
   131 	*/
       
   132     IMPORT_C  TInt GetJpegQualityFactorL (const TDesC & aFileName);
       
   133 
       
   134 	/** RenameImage
       
   135 	*
       
   136 	*	Renames image. 
       
   137 	*
       
   138 	*	@param aFileNameSrc - source image name
       
   139 	*	@param aFileNameDst - destination image name
       
   140 	*	@return KErrNone if no errors, system wide error code otherwise
       
   141 	*/
       
   142 	IMPORT_C TInt RenameImage (
       
   143 		const TDesC	&		aFileNameSrc,
       
   144 		const TDesC	&		aFileNameDst
       
   145 		) const;
       
   146 
       
   147 	/** DeleteImage
       
   148 	*
       
   149 	*	Deletes image. 
       
   150 	*
       
   151 	*	@param aFileName - image name to be deleted
       
   152 	*	@return KErrNone if no errors, system wide error code otherwise
       
   153 	*/
       
   154 	IMPORT_C TInt DeleteImage (const TDesC & aFileName) const;
       
   155 
       
   156 	/** CleanupConverters 
       
   157 	*
       
   158 	*	Cancels the asynchronous requests and cleans up image converters.
       
   159 	*
       
   160 	*	@param -
       
   161 	*	@return -
       
   162 	*/
       
   163 	IMPORT_C void CleanupConverters ();
       
   164 
       
   165 	/** IsRajpegImageL
       
   166 	*
       
   167 	*	Checks whether an image is a RAJPEG image or not.
       
   168 	*
       
   169 	*	@param aFileName - file name
       
   170 	*	@return ETrue if RAJPEG image, EFalse otherwise
       
   171 	*/
       
   172 	IMPORT_C TBool IsRajpegImageL (const TDesC & aFileName) const;
       
   173 
       
   174 	/** IsJpegIntact
       
   175 	*
       
   176 	*	Verifies JPEG image content.
       
   177 	*
       
   178 	*	@param aFileName - file name
       
   179 	*	@return ETrue if intact, EFalse if broken
       
   180 	*/
       
   181 	IMPORT_C TBool IsJpegIntact (const TDesC & aFileName);
       
   182 
       
   183 //@}
       
   184 
       
   185 protected:
       
   186 
       
   187 /** @name Methods:*/
       
   188 //@{
       
   189 
       
   190 //@}
       
   191 
       
   192 /** @name Members:*/
       
   193 //@{
       
   194 
       
   195 //@}
       
   196 
       
   197 private:
       
   198 
       
   199 /** @name Methods:*/
       
   200 //@{
       
   201 
       
   202 	/** Default constructor
       
   203 	*
       
   204 	*	@param -
       
   205 	*	@return -
       
   206 	*/
       
   207 	CImageEditorImageHandler ();
       
   208 
       
   209 	/** Second phase constructor, may leave
       
   210 	*
       
   211 	*	@param -
       
   212 	*	@return -
       
   213 	*/
       
   214 	void ConstructL ();
       
   215 
       
   216 	/** GetMIMETypeLC
       
   217 	*
       
   218 	*	Finds and create CFileExtensionMIMEType type based on file extension.
       
   219 	*
       
   220 	*	@param aFileName - image file name
       
   221 	*	@return MIME type instance
       
   222 	*/
       
   223 	CFileExtensionMIMEType * GetMIMETypeL (const TDesC & aFileName);
       
   224 
       
   225 	/*	GetFrameImageDataL
       
   226 	*
       
   227 	*   Gets CFrameImageData instance.
       
   228 	*
       
   229 	*   @param aExt - image name extension
       
   230 	*   @param aQuality - JPEG quality
       
   231 	*   @return CFrameImageData instance
       
   232 	*/
       
   233 	CFrameImageData * GetFrameImageDataL (
       
   234 		const TDesC &		aExt,
       
   235 		const TInt			aQuality
       
   236 		) const;
       
   237 
       
   238 	/** Copy constructor, disabled
       
   239 	*/
       
   240 	CImageEditorImageHandler (const CImageEditorImageHandler & rhs);
       
   241 
       
   242 	/** Assignment operator, disabled 
       
   243 	*/
       
   244 	CImageEditorImageHandler & operator= (const CImageEditorImageHandler & rhs);
       
   245 
       
   246 //@}
       
   247 
       
   248 /** @name Members:*/
       
   249 //@{
       
   250 	/// Image decoder instance (used in loading)
       
   251 	CImageDecoder * iImageDecoder;
       
   252 
       
   253 	/// Image encoder instance (used in saving)
       
   254 	CImageEncoder * iImageEncoder;
       
   255 //@}
       
   256 
       
   257 };
       
   258 
       
   259 
       
   260 #endif
       
   261 
       
   262 // End of File