epoc32/include/imageprocessor/imageprocessor.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // This is the public client API for the Image Processor Library
    15 // 
    16 //
    17 
    18 /**
    19  @file
    20  @publishedAll 
    21  @released 
    22 */
    23 
    24 #ifndef __IMAGE_PROCESSOR_H__
    25 #define __IMAGE_PROCESSOR_H__
    26 
    27 #include <e32base.h>
    28 #include <gdi.h>
    29 #include <icl/imagecodecdata.h>
    30 
    31 class RFs;
    32 class RFile;
    33 class TMMSource;
    34 class CFbsBitmap;
    35 class CImageFrame;
    36 class TSize;
    37 class TRgb;
    38 class CImagePanorama;
    39 
    40 /**
    41 @publishedAll 
    42 @released
    43 Image processor namespace for image manipulation and processing.
    44 */
    45 namespace ImageProcessor
    46 	{
    47 	class MImgProcessorObserver;
    48 	class CImageProcessorImpl;
    49 	
    50 	class TEffect;
    51 	class TPreview;
    52 	class TOverlay;
    53 	class TProgressInfo;
    54 	class TInputInfo;
    55 	class TOutputInfo;
    56 
    57 /**
    58 @publishedAll 
    59 @released
    60 
    61 This class provides functions to process images. Those operations can be divided in two groups:
    62 - effects.
    63 - geometrical operations.
    64 
    65 Good examples of effects could be the Sepia effect applying shades of brown to an image, or the solarize effect 
    66 that consists in reversing the tones of a picture and make it look like a negative.
    67 Good examples of geometrical operations could be Rotation or Flip.
    68 
    69 The image processor will decode and render an image:
    70 
    71 Inputs can be
    72 - compressed images (JPEG, GIF, PNG etc)
    73 - uncompressed images (CFbsBitmap and general pixel buffers e.g. YUV 4:2:0 Interleaved etc)
    74 
    75 Outputs can be 
    76 - compressed images (JPEG, GIF, PNG etc)
    77 - uncompressed images (CFbsBitmap and general pixel buffers e.g. YUV 4:2:0 Interleaved etc)
    78 
    79 An intermediate generally low resolution uncompressed image providing a preview representation of the 
    80 output of the processing is provided allowing applications to display the results of the operations 
    81 applied without needing to fully render the image. Multiple previews are allowed.
    82 
    83 Images may be overlaid onto the main source image.
    84 
    85 The source image can be changed and the current effects and geometric oprations will be re-applied to the
    86 new image. The previews will be updated.
    87 */
    88 class CImgProcessor : public CBase
    89 	{
    90 public:   
    91 	/**
    92 	Flags to control how the image is processed.
    93 	*/
    94 	enum TOptions
    95 		{
    96 		/** No flag set 
    97 		*/
    98 		EOptionNone = 0x00,
    99 		/** Effects, geometric operations and rendering are applied synchronously. 
   100 		The default is asynchronously.
   101 		*/
   102 		EOptionSyncProcessing = 0x01,
   103 		/** The Exif data from the source image is parsed and transferred to the 
   104 		destination image.
   105         */
   106 		EOptionExifMetadataProcessing = 0x02
   107 		};
   108 
   109 	/**
   110 	Flags to control the operations or transforms on an image.
   111 	*/
   112 	enum TOperation
   113 		{
   114 		/** No operation.
   115 		*/
   116 		EOperationNone = 0x0,
   117 
   118         /** Rotate 90 degrees clockwise.
   119         */
   120         EOperationRotate90 = 0x1,
   121 
   122         /** Rotate 180 degrees clockwise.
   123         */
   124         EOperationRotate180 = 0x2,
   125 
   126         /** Rotate 270 degrees clockwise.
   127         */
   128         EOperationRotate270 = 0x4,
   129 
   130         /** Horizontal flip (mirror over horizontal axis).
   131         */
   132         EOperationMirrorHorizontalAxis = 0x8,
   133 
   134         /** Horizontal flip (mirror over horizontal axis) then rotate 90 degrees clockwise.
   135         */
   136         EOperationMirrorHorizontalAxisRotate90 = 0x10,
   137 
   138         /** Vertical flip (mirror over vertical axis).
   139         */
   140         EOperationMirrorVerticalAxis     = 0x20,
   141 
   142         /** Vertical flip (mirror over vertical axis) then rotate 90 degrees clockwise.
   143         */
   144         EOperationMirrorVerticalAxisRotate90 = 0x40
   145 		};
   146       
   147 	/**
   148 	Possible states for the image processor. 
   149 	*/
   150 	enum TState
   151 		{
   152         /** Image processor not initalized.
   153         */
   154 		EUninitialized = 0,
   155         /** Image processor initalizing.
   156         */
   157 		EInitializing,
   158         /** Image processor initalized.
   159         */
   160 		EInitialized,
   161         /** Effect active.
   162         */
   163 		EEffectActive,
   164         /** Image processor processing an image.
   165         */
   166 		EProcessing,
   167         /** Preview initializing.
   168         */
   169 		EPreviewInitializing,
   170         /** Preview Rendering.
   171         */
   172 		EPreviewRendering,
   173         /** Count of valid states (boundary marker - not a true state).
   174         */
   175 		EStatesCount
   176 		};
   177 
   178 	/**
   179 	Events occurring during processing. 
   180 	*/
   181 	enum TEvent
   182 		{
   183         /** The image processor is initializing.
   184         */
   185 		EEventInitializing = 0, 
   186         /** The image processor has finished initializing.
   187         */
   188 		EEventInitializingComplete,
   189         /** Processing is in progress.
   190         */
   191 		EEventProcessing,	
   192         /** Processing is complete.
   193         */
   194 		EEventProcessingComplete,
   195         /** Rendering is in progress.
   196         */
   197 		EEventRendering,
   198         /** Event rendering is complete.
   199         */
   200 		EEventRenderingComplete,
   201         /** The preview is initializing.
   202         */
   203 		EEventPreviewInitializing,
   204         /** The preview has finished initializing.
   205         */
   206 		EEventPreviewInitializingComplete,
   207         /** The preview rendering is in progress.
   208         */
   209 		EEventPreviewRendering,
   210         /** The preview rendering is complete.
   211         */
   212 		EEventPreviewRenderingComplete
   213 		};
   214    
   215 public:   
   216 	IMPORT_C static CImgProcessor* NewL(RFs& aFileServerSession, MImgProcessorObserver& aObserver, TUid aImageProcessorPluginUid=KNullUid);
   217 	
   218 	IMPORT_C void SupportedEffectsL(RArray<TUid>& aEffects) const;
   219 	
   220 	IMPORT_C void SupportedInputFormatsL(RArray<TUid>& aFormats) const;
   221 	IMPORT_C void SupportedInputSubFormatsL(TUid aFormat, RArray<TUid>& aSubFormats) const;
   222 	IMPORT_C void SupportedInputImageFrameFormatsL(RArray<TUid>& aFormats) const;
   223 	IMPORT_C void SupportedInputDisplayModesL(RArray<TDisplayMode>& aDisplayModes) const;
   224 	
   225 	IMPORT_C void SupportedOutputFormatsL(RArray<TUid>& aFormats) const;
   226 	IMPORT_C void SupportedOutputSubFormatsL(TUid aFormat, RArray<TUid>& aSubFormats) const;
   227 	IMPORT_C void SupportedOutputImageFrameFormatsL(RArray<TUid>& aFormats) const;
   228 	IMPORT_C void SupportedOutputDisplayModesL(RArray<TDisplayMode>& aDisplayModes) const;
   229 
   230 	IMPORT_C TUint64 SupportedOptions() const;
   231 	IMPORT_C TUint SupportedOperations() const;
   232 
   233 	IMPORT_C TUint64 Options() const;
   234 	IMPORT_C TState State() const;
   235 	IMPORT_C TSize CurrentSizeL() const;
   236 	IMPORT_C TRgb BackgroundColorL() const;
   237 
   238 	IMPORT_C TProgressInfo* ProgressInfoL();
   239 	IMPORT_C TInputInfo* InputInfoL();
   240 	IMPORT_C TOutputInfo* OutputInfoL();
   241 	
   242 	IMPORT_C TInt CalculatePixelBufferSizeL(TSize aSizeInPixels, TDisplayMode aDisplayMode, TUint32 aScanLineLength = 0) const;
   243 	IMPORT_C TInt CalculatePixelBufferSizeL(TSize aSizeInPixels, const TUid& aFormat, TUint32 aScanLineLength = 0) const;
   244 
   245 	IMPORT_C void CreateInputL(CFbsBitmap& aBitmap);
   246 	IMPORT_C void CreateInputL(CImageFrame& aPixelBuffer);
   247 	IMPORT_C void CreateInputL(const TSize& aSize, const TRgb& aColor);
   248 
   249 	IMPORT_C void SetBackgroundColorL(const TRgb& aColor);
   250 	
   251 	IMPORT_C void SetInputRectL(const TRect& aRect);
   252 	
   253 	IMPORT_C void SetInputL(const TDesC& aFilename, const TUid& aFormat = KNullUid, const TUid& aSubFormat = KNullUid);
   254 	IMPORT_C void SetInputL(RFile& aFile, const TUid& aFormat = KNullUid, const TUid& aSubFormat = KNullUid);
   255 	IMPORT_C void SetInputL(TMMSource& aDrmFile, const TUid& aFormat = KNullUid, const TUid& aSubFormat = KNullUid);
   256 	IMPORT_C void SetInputL(const TDesC8& aBuffer, const TUid& aFormat = KNullUid, const TUid& aSubFormat = KNullUid);
   257 	IMPORT_C void SetInputL(const CFbsBitmap& aBitmap, const CFbsBitmap* aMask = NULL);
   258 	IMPORT_C void SetInputL(const CImageFrame& aPixelBuffer);
   259 	IMPORT_C void SetInputL(CImagePanorama& aPanorama);
   260 
   261 	IMPORT_C void SetOptionsL(TUint64 aOptions);
   262 	IMPORT_C void ApplyOperationL(CImgProcessor::TOperation aOperation);
   263 
   264 	IMPORT_C void InputUpdatedL();
   265 	
   266 	IMPORT_C void ResetL();
   267 
   268 	IMPORT_C void InitializeL();
   269 	IMPORT_C void InitializeL(TUint64 aOptions);
   270    
   271 	IMPORT_C void ProcessL();
   272 	IMPORT_C void ProcessL(const TSize& aSize, TBool aMaintainAspectRatio);
   273 	IMPORT_C void Cancel();
   274 
   275 	IMPORT_C TEffect* EffectL(TUid aEffect);
   276 
   277 	IMPORT_C TBool CanUndoL() const;
   278 	IMPORT_C void UndoL();
   279 	IMPORT_C void UndoAllL();
   280 	
   281 	IMPORT_C TBool CanRedoL() const;
   282 	IMPORT_C void RedoL();
   283 	IMPORT_C void RedoAllL();
   284 
   285 	IMPORT_C TPreview* PreviewL(TInt aPreviewId);
   286 
   287 	IMPORT_C TOverlay* OverlayL();
   288 	
   289 	IMPORT_C void SetOutputL(const TDesC& aFilename, const TUid& aFormat = KImageTypeJPGUid, const TUid& aSubFormat = KNullUid);
   290 	IMPORT_C void SetOutputL(RFile& aFile, const TUid& aFormat = KImageTypeJPGUid, const TUid& aSubFormat = KNullUid);
   291 	IMPORT_C void SetOutputL(RBuf8& aBuffer, const TUid& aFormat = KImageTypeJPGUid, const TUid& aSubFormat = KNullUid);
   292 	IMPORT_C void SetOutputL(CImageFrame& aPixelBuffer);
   293 	IMPORT_C void SetOutputL(CFbsBitmap& aBitmap, CFbsBitmap* aMask = NULL);
   294 
   295 	IMPORT_C TAny* Extension(TUid aExtension);
   296 
   297 	// framework utility functions
   298 	IMPORT_C void ConvertMimeTypeToUidL(const TDesC8& aMimeType, TUid& aFormat, TUid& aSubFormat) const;
   299 	IMPORT_C void ConvertFileExtensionToUidL(const TDesC& aFileExtension, TUid& aFormat, TUid& aSubFormat) const;
   300 	IMPORT_C void ConvertUidToMimeTypeL(TDes8& aMimeType, const TUid& aFormat, const TUid& aSubFormat) const;
   301 	IMPORT_C void ConvertUidToFileExtensionL(TDes& aFileExtension, const TUid& aFormat, const TUid& aSubFormat) const;
   302 
   303 	IMPORT_C ~CImgProcessor();
   304 
   305 private:
   306 	CImgProcessor();
   307 	void ConstructL(RFs& aFileServerSession,MImgProcessorObserver& aObserver, TUid aPluginUid);
   308 
   309 private:
   310 	CImageProcessorImpl* iImplementation;
   311 	};
   312 
   313 	} // ImageProcessor
   314 
   315 #endif //__IMAGE_PROCESSOR_H__