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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // This is the public client API for the Image Processor Library
24 #ifndef __IMAGE_PROCESSOR_H__
25 #define __IMAGE_PROCESSOR_H__
29 #include <icl/imagecodecdata.h>
43 Image processor namespace for image manipulation and processing.
45 namespace ImageProcessor
47 class MImgProcessorObserver;
48 class CImageProcessorImpl;
61 This class provides functions to process images. Those operations can be divided in two groups:
63 - geometrical operations.
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.
69 The image processor will decode and render an image:
72 - compressed images (JPEG, GIF, PNG etc)
73 - uncompressed images (CFbsBitmap and general pixel buffers e.g. YUV 4:2:0 Interleaved etc)
76 - compressed images (JPEG, GIF, PNG etc)
77 - uncompressed images (CFbsBitmap and general pixel buffers e.g. YUV 4:2:0 Interleaved etc)
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.
83 Images may be overlaid onto the main source image.
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.
88 class CImgProcessor : public CBase
92 Flags to control how the image is processed.
99 /** Effects, geometric operations and rendering are applied synchronously.
100 The default is asynchronously.
102 EOptionSyncProcessing = 0x01,
103 /** The Exif data from the source image is parsed and transferred to the
106 EOptionExifMetadataProcessing = 0x02
110 Flags to control the operations or transforms on an image.
116 EOperationNone = 0x0,
118 /** Rotate 90 degrees clockwise.
120 EOperationRotate90 = 0x1,
122 /** Rotate 180 degrees clockwise.
124 EOperationRotate180 = 0x2,
126 /** Rotate 270 degrees clockwise.
128 EOperationRotate270 = 0x4,
130 /** Horizontal flip (mirror over horizontal axis).
132 EOperationMirrorHorizontalAxis = 0x8,
134 /** Horizontal flip (mirror over horizontal axis) then rotate 90 degrees clockwise.
136 EOperationMirrorHorizontalAxisRotate90 = 0x10,
138 /** Vertical flip (mirror over vertical axis).
140 EOperationMirrorVerticalAxis = 0x20,
142 /** Vertical flip (mirror over vertical axis) then rotate 90 degrees clockwise.
144 EOperationMirrorVerticalAxisRotate90 = 0x40
148 Possible states for the image processor.
152 /** Image processor not initalized.
155 /** Image processor initalizing.
158 /** Image processor initalized.
164 /** Image processor processing an image.
167 /** Preview initializing.
169 EPreviewInitializing,
170 /** Preview Rendering.
173 /** Count of valid states (boundary marker - not a true state).
179 Events occurring during processing.
183 /** The image processor is initializing.
185 EEventInitializing = 0,
186 /** The image processor has finished initializing.
188 EEventInitializingComplete,
189 /** Processing is in progress.
192 /** Processing is complete.
194 EEventProcessingComplete,
195 /** Rendering is in progress.
198 /** Event rendering is complete.
200 EEventRenderingComplete,
201 /** The preview is initializing.
203 EEventPreviewInitializing,
204 /** The preview has finished initializing.
206 EEventPreviewInitializingComplete,
207 /** The preview rendering is in progress.
209 EEventPreviewRendering,
210 /** The preview rendering is complete.
212 EEventPreviewRenderingComplete
216 IMPORT_C static CImgProcessor* NewL(RFs& aFileServerSession, MImgProcessorObserver& aObserver, TUid aImageProcessorPluginUid=KNullUid);
218 IMPORT_C void SupportedEffectsL(RArray<TUid>& aEffects) const;
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;
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;
230 IMPORT_C TUint64 SupportedOptions() const;
231 IMPORT_C TUint SupportedOperations() const;
233 IMPORT_C TUint64 Options() const;
234 IMPORT_C TState State() const;
235 IMPORT_C TSize CurrentSizeL() const;
236 IMPORT_C TRgb BackgroundColorL() const;
238 IMPORT_C TProgressInfo* ProgressInfoL();
239 IMPORT_C TInputInfo* InputInfoL();
240 IMPORT_C TOutputInfo* OutputInfoL();
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;
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);
249 IMPORT_C void SetBackgroundColorL(const TRgb& aColor);
251 IMPORT_C void SetInputRectL(const TRect& aRect);
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);
261 IMPORT_C void SetOptionsL(TUint64 aOptions);
262 IMPORT_C void ApplyOperationL(CImgProcessor::TOperation aOperation);
264 IMPORT_C void InputUpdatedL();
266 IMPORT_C void ResetL();
268 IMPORT_C void InitializeL();
269 IMPORT_C void InitializeL(TUint64 aOptions);
271 IMPORT_C void ProcessL();
272 IMPORT_C void ProcessL(const TSize& aSize, TBool aMaintainAspectRatio);
273 IMPORT_C void Cancel();
275 IMPORT_C TEffect* EffectL(TUid aEffect);
277 IMPORT_C TBool CanUndoL() const;
278 IMPORT_C void UndoL();
279 IMPORT_C void UndoAllL();
281 IMPORT_C TBool CanRedoL() const;
282 IMPORT_C void RedoL();
283 IMPORT_C void RedoAllL();
285 IMPORT_C TPreview* PreviewL(TInt aPreviewId);
287 IMPORT_C TOverlay* OverlayL();
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);
295 IMPORT_C TAny* Extension(TUid aExtension);
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;
303 IMPORT_C ~CImgProcessor();
307 void ConstructL(RFs& aFileServerSession,MImgProcessorObserver& aObserver, TUid aPluginUid);
310 CImageProcessorImpl* iImplementation;
315 #endif //__IMAGE_PROCESSOR_H__