1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 // |
7 // |
8 // Initial Contributors: |
8 // Initial Contributors: |
9 // Nokia Corporation - initial contribution. |
9 // Nokia Corporation - initial contribution. |
10 // |
10 // |
11 // Contributors: |
11 // Contributors: |
12 // |
12 // |
13 // Description: |
13 // Description: |
|
14 // This is the public client API for the Image Processor Library |
|
15 // |
14 // |
16 // |
15 |
17 |
16 #ifndef ___IMAGEPROCESSOR_H__ |
18 /** |
17 #define ___IMAGEPROCESSOR_H__ |
19 @file |
18 |
20 @publishedAll |
|
21 @released |
|
22 */ |
|
23 |
|
24 #ifndef __IMAGE_PROCESSOR_H__ |
|
25 #define __IMAGE_PROCESSOR_H__ |
|
26 |
|
27 #include <e32base.h> |
19 #include <gdi.h> |
28 #include <gdi.h> |
20 #include <fbs.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; |
21 |
39 |
22 /** |
40 /** |
23 @internalTechnology |
41 @publishedAll |
|
42 @released |
|
43 Image processor namespace for image manipulation and processing. |
24 */ |
44 */ |
25 enum TImageBitmapUtilPanic |
45 namespace ImageProcessor |
26 { |
46 { |
27 ECorrupt |
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; |
28 }; |
311 }; |
29 |
312 |
30 /** |
313 } // ImageProcessor |
31 @publishedAll |
314 |
32 @released |
315 #endif //__IMAGE_PROCESSOR_H__ |
33 |
|
34 Interface to colour conversion classes for various display modes. |
|
35 Manages the mapping between RGB/Greyscale values and the index |
|
36 into the color palette for the given display mode. |
|
37 */ |
|
38 class TColorConvertor |
|
39 { |
|
40 public: |
|
41 IMPORT_C static TColorConvertor* NewL(TDisplayMode aDisplayMode); |
|
42 |
|
43 /** |
|
44 Returns the colour index corresponding to the supplied RGB value. |
|
45 Operates in the context of the current display mode. |
|
46 |
|
47 This is a virtual function that each derived class must implement. |
|
48 |
|
49 @param aColor |
|
50 The colour in RGB format. |
|
51 |
|
52 @return The colour index. |
|
53 */ |
|
54 virtual TInt ColorIndex(TRgb aColor) const = 0; |
|
55 |
|
56 /** |
|
57 Returns the RGB value corresponding to the supplied colour index. |
|
58 Operates in the context of the current display mode. |
|
59 |
|
60 This is a virtual function that each derived class must implement. |
|
61 |
|
62 @param aColorIndex |
|
63 The colour in RGB format. |
|
64 |
|
65 @return The RGB value. |
|
66 */ |
|
67 virtual TRgb Color(TInt aColorIndex) const = 0; |
|
68 |
|
69 /** |
|
70 Gets an array of colour indices from a corresponding array of RGB values. |
|
71 Operates in the context of the current display mode. |
|
72 |
|
73 This is a virtual function that each derived class must implement. |
|
74 |
|
75 @param aIndexBuffer |
|
76 A pointer to the first element in destination array. |
|
77 @param aColorBuffer |
|
78 A pointer to the first element in the source array. |
|
79 @param aCount |
|
80 The number of elements to get. |
|
81 */ |
|
82 virtual void ColorToIndex(TInt* aIndexBuffer,TRgb* aColorBuffer,TInt aCount) const = 0; |
|
83 |
|
84 inline static TInt RgbToMonochrome(TRgb aRgb); |
|
85 }; |
|
86 |
|
87 |
|
88 /** |
|
89 @publishedAll |
|
90 @released |
|
91 |
|
92 Bitmap utility class. |
|
93 */ |
|
94 class TImageBitmapUtil |
|
95 { |
|
96 public: |
|
97 IMPORT_C TImageBitmapUtil(); |
|
98 IMPORT_C void Begin(); |
|
99 IMPORT_C TBool Begin(const TPoint& aPosition); |
|
100 IMPORT_C void End(); |
|
101 IMPORT_C void SetBitmapL(CFbsBitmap* aBitmap); |
|
102 IMPORT_C void SetPixel(TUint32 aPixelIndex); |
|
103 IMPORT_C void SetPixels(TUint32* aPixelIndex,TInt aNumberOfPixels); |
|
104 IMPORT_C TBool SetPos(const TPoint& aPosition); |
|
105 |
|
106 private: |
|
107 union TDataPointer |
|
108 { |
|
109 TUint32* iWordPos; |
|
110 TUint8* iBytePos; |
|
111 }; |
|
112 private: |
|
113 CFbsBitmap* iBitmap; |
|
114 TSize iSize; |
|
115 TPoint iPosition; |
|
116 TDataPointer iData; |
|
117 TDataPointer iBase; |
|
118 TInt iBpp; |
|
119 TInt iBppShift; |
|
120 TInt iPixelShift; |
|
121 TInt iPixelsPerWord; |
|
122 TInt iBitShift; |
|
123 TInt iScanlineWordLength; |
|
124 TUint32 iMask; |
|
125 TBool iWordAccess; |
|
126 }; |
|
127 |
|
128 |
|
129 class CImageProcessor; |
|
130 class CImageProcessorExtension; |
|
131 |
|
132 /** |
|
133 @publishedAll |
|
134 @released |
|
135 |
|
136 Utility class providing static factory functions for creating instances of |
|
137 CImageProcessor derived classes. |
|
138 */ |
|
139 class ImageProcessorUtility |
|
140 { |
|
141 public: |
|
142 IMPORT_C static TInt ReductionFactor(const TSize& aOriginalSize,const TSize& aReducedSize); |
|
143 IMPORT_C static CImageProcessor* NewImageProcessorL(const CFbsBitmap& aBitmap,const TSize& aImageSize,TDisplayMode aImageDisplayMode, TBool aDisableErrorDiffusion); |
|
144 IMPORT_C static CImageProcessor* NewImageProcessorL(const CFbsBitmap& aBitmap,TInt aReductionFactor,TDisplayMode aImageDisplayMode, TBool aDisableErrorDiffusion); |
|
145 IMPORT_C static CImageProcessorExtension* ImageProcessorUtility::NewImageProcessorExtensionL(const CFbsBitmap& aBitmap,TInt aReductionFactor,TDisplayMode aImageDisplayMode, TBool aDisableErrorDiffusion); |
|
146 |
|
147 private: |
|
148 TBool static UseErrorDiffuser(const TDisplayMode& aBitmapDisplayMode, const TDisplayMode& aImageDisplayMode); |
|
149 TBool static IsMonochrome(const TDisplayMode& aBitmapDisplayMode, const TDisplayMode& aImageDisplayMode); |
|
150 }; |
|
151 |
|
152 |
|
153 |
|
154 /** |
|
155 @publishedAll |
|
156 @released |
|
157 |
|
158 Interface to image processing classes. |
|
159 */ |
|
160 class CImageProcessor : public CBase |
|
161 { |
|
162 public: |
|
163 // Setup |
|
164 |
|
165 /** |
|
166 Initialises internal data structures prior to conversion. |
|
167 |
|
168 This is a virtual function that each derived class must implement. |
|
169 |
|
170 @param aBitmap |
|
171 A reference to a fully constucted bitmap with the required |
|
172 display mode and size. |
|
173 @param aImageRect |
|
174 The region of the image to convert. |
|
175 */ |
|
176 virtual void PrepareL(CFbsBitmap& aBitmap,const TRect& aImageRect) = 0; |
|
177 |
|
178 /** |
|
179 Initialises internal data structures prior to the manipulation of the specified pixel block. |
|
180 |
|
181 This overloaded version allows specification of a block size |
|
182 for those formats which support blocked pixel data eg. JPEG |
|
183 |
|
184 This is a virtual function that each derived class must implement. |
|
185 |
|
186 @param aBitmap |
|
187 A reference to a fully constucted bitmap with the required |
|
188 display mode and size. |
|
189 @param aImageRect |
|
190 The region of the image to convert. |
|
191 @param aRgbBlockSize |
|
192 The size of the block to use. |
|
193 */ |
|
194 virtual void PrepareL(CFbsBitmap& aBitmap,const TRect& aImageRect,const TSize& aRgbBlockSize) = 0; |
|
195 |
|
196 /** |
|
197 Sets the number of pixels by which to increment the current position in |
|
198 the Y-axis. This is used when rendering images supporting interlacing. |
|
199 eg GIF |
|
200 |
|
201 This is a virtual function that each derived class must implement. |
|
202 |
|
203 @param aYInc |
|
204 The number of pixels. |
|
205 */ |
|
206 virtual void SetYPosIncrement(TInt aYInc) = 0; |
|
207 |
|
208 /** |
|
209 Sets the number times the current line should be repeated. The lines |
|
210 are repeated in the same direction as set by SetYPosIncrement(). This |
|
211 is used to fill blank lines when rendering interlaced images. eg GIF. |
|
212 @param aLineRepeat The number of times the current line should be repeated |
|
213 */ |
|
214 virtual void SetLineRepeat(TInt aLineRepeat) = 0; |
|
215 |
|
216 /** |
|
217 Sets the pixel padding to the value specified by aNumberOfPixels. |
|
218 |
|
219 This is a virtual function that each derived class must implement. |
|
220 |
|
221 @param aNumberOfPixels |
|
222 The number of pixels to use for padding. |
|
223 */ |
|
224 virtual void SetPixelPadding(TInt aNumberOfPixels) = 0; |
|
225 |
|
226 // Color pixel writing |
|
227 |
|
228 /** |
|
229 Sets the pixel at the current position to aColor. |
|
230 |
|
231 This is a virtual function that each derived class must implement. |
|
232 |
|
233 @post |
|
234 The current position is updated. |
|
235 |
|
236 @param aColor |
|
237 The RGB value to set the current pixel to. |
|
238 |
|
239 @return A boolean indicating if the operation was successful. ETrue if the operation succeeded, |
|
240 otherwise EFalse. |
|
241 */ |
|
242 virtual TBool SetPixel(TRgb aColor) = 0; |
|
243 |
|
244 /** |
|
245 Sets aCount number of pixels to the value given by aColor, starting at |
|
246 the current position. |
|
247 |
|
248 This is a virtual function that each derived class must implement. |
|
249 |
|
250 @post |
|
251 On success, the current position is updated. |
|
252 |
|
253 @param aColor |
|
254 The RGB value to set the pixels to. |
|
255 @param aCount |
|
256 The number of pixels to set. |
|
257 |
|
258 @return A boolean indicating if the operation was successful. ETrue if the operation succeeded, |
|
259 otherwise EFalse. |
|
260 */ |
|
261 virtual TBool SetPixelRun(TRgb aColor,TInt aCount) = 0; |
|
262 |
|
263 /** |
|
264 Updates the bitmap with colour information from the array of colour values. |
|
265 |
|
266 Uses the array of colour values supplied by aColorBuffer, whose length |
|
267 is specified by aBufferLength, to update successive pixels with values in the |
|
268 buffer, starting at the current position. |
|
269 |
|
270 This is a virtual function that each derived class must implement. |
|
271 |
|
272 @post |
|
273 The current position is updated. |
|
274 |
|
275 @param aColorBuffer |
|
276 A pointer to the first element in the array. |
|
277 @param aBufferLength |
|
278 The number of elements in the array. |
|
279 |
|
280 @return A boolean indicating if the operation was successful. ETrue if the operation succeeded, |
|
281 otherwise EFalse. |
|
282 */ |
|
283 virtual TBool SetPixels(TRgb* aColorBuffer,TInt aBufferLength) = 0; |
|
284 |
|
285 /** |
|
286 Sets the current pixel block using the data supplied in aColorBuffer. |
|
287 |
|
288 Note: |
|
289 For use with image types that support blocking of pixels eg JPEG. |
|
290 |
|
291 This is a virtual function that each derived class must implement. |
|
292 |
|
293 @param aColorBuffer |
|
294 A pointer to a buffer representing a block of pixel color values. |
|
295 |
|
296 @return A boolean indicating if the operation was successful. ETrue if the operation succeeded, |
|
297 otherwise EFalse. |
|
298 */ |
|
299 virtual TBool SetPixelBlock(TRgb* aColorBuffer) = 0; |
|
300 |
|
301 // Monochrome pixel writing |
|
302 |
|
303 /** |
|
304 Sets the pixel at the current position to aGray256. |
|
305 |
|
306 This is a virtual function that each derived class must implement. |
|
307 |
|
308 @post |
|
309 The current position is updated. |
|
310 |
|
311 @param aGray256 |
|
312 The greyscale value to set the current pixel to. |
|
313 |
|
314 @return A boolean indicating if the operation was successful. ETrue if the operation succeeded, |
|
315 otherwise EFalse. |
|
316 */ |
|
317 virtual TBool SetMonoPixel(TInt aGray256) = 0; |
|
318 |
|
319 /** |
|
320 Sets the number of pixels specified by aCount to the value given by aGray256, starting at |
|
321 the current position. |
|
322 |
|
323 This is a virtual function that each derived class must implement. |
|
324 |
|
325 @post |
|
326 The current position is updated. |
|
327 |
|
328 @param aGray256 |
|
329 The greyscale value to set the pixels to. |
|
330 @param aCount |
|
331 The number of pixels to set. |
|
332 |
|
333 @return A boolean indicating if the operation was successful. ETrue if the operation succeeded, |
|
334 otherwise EFalse. |
|
335 */ |
|
336 virtual TBool SetMonoPixelRun(TInt aGray256,TInt aCount) = 0; |
|
337 |
|
338 /** |
|
339 Updates the bitmap with greyscale information from the array of greyscale values. |
|
340 |
|
341 The array of values supplied by aGray256Buffer, whose length |
|
342 is specified in aBufferLength, is used to update successive pixels with the |
|
343 greyscales values. |
|
344 |
|
345 This is a virtual function that each derived class must implement. |
|
346 |
|
347 @post |
|
348 The current position is updated. |
|
349 |
|
350 @param aGray256Buffer |
|
351 A pointer to the first element in the array of greyscale values. |
|
352 @param aBufferLength |
|
353 The number of elements in the array. |
|
354 |
|
355 @return A boolean indicating if the operation was successful. ETrue if the operation succeeded, |
|
356 otherwise EFalse. |
|
357 */ |
|
358 virtual TBool SetMonoPixels(TUint32* aGray256Buffer,TInt aBufferLength) = 0; |
|
359 |
|
360 /** |
|
361 Sets a specified number of pixels to the specified greyscale value. |
|
362 |
|
363 For image types which support blocking of pixels eg JPEG, the current |
|
364 pixel block is set using the data supplied in aGray256Buffer. |
|
365 |
|
366 This is a virtual function that each derived class must implement. |
|
367 |
|
368 @param aGray256Buffer |
|
369 A pointer to a buffer representing a block of pixel color values. |
|
370 |
|
371 @return A boolean indicating if the operation was successful. ETrue if the operation succeeded, |
|
372 otherwise EFalse. |
|
373 */ |
|
374 virtual TBool SetMonoPixelBlock(TUint32* aGray256Buffer) = 0; |
|
375 |
|
376 // Processor flow control |
|
377 |
|
378 /** |
|
379 Sets the current position in the bitmap to aPosition. |
|
380 |
|
381 This is a virtual function that each derived class must implement. |
|
382 |
|
383 @param aPosition |
|
384 A reference to TPoint object defining the position to move to. |
|
385 |
|
386 @return A boolean indicating if the operation was successful. ETrue if the operation succeeded, |
|
387 otherwise EFalse. |
|
388 */ |
|
389 virtual TBool SetPos(const TPoint& aPosition) = 0; |
|
390 |
|
391 /** |
|
392 Commits the changes made to the current bitmap by flushing the buffer. |
|
393 |
|
394 This is a virtual function that each derived class must implement. |
|
395 |
|
396 @post |
|
397 The current position is updated. |
|
398 |
|
399 @return A boolean indicating if the operation was successful. ETrue if the operation succeeded, |
|
400 otherwise EFalse. |
|
401 */ |
|
402 virtual TBool FlushPixels() = 0; |
|
403 |
|
404 private: |
|
405 // Future proofing |
|
406 IMPORT_C virtual void ReservedVirtual1(); |
|
407 IMPORT_C virtual void ReservedVirtual2(); |
|
408 IMPORT_C virtual void ReservedVirtual3(); |
|
409 IMPORT_C virtual void ReservedVirtual4(); |
|
410 }; |
|
411 |
|
412 /** |
|
413 @publishedAll |
|
414 @released |
|
415 |
|
416 Flag used to determine the type of transformation which is the result of |
|
417 single or multiple transformation operations requested via calls to |
|
418 COperationExtension::AddOperationL. |
|
419 |
|
420 8 unique orientations: |
|
421 |
|
422 @code |
|
423 normal 90 180 270 |
|
424 00 10 01 00 11 01 10 11 |
|
425 01 11 11 10 10 00 00 01 |
|
426 |
|
427 V flip 90 180 270 |
|
428 10 00 11 10 =Hflip =Hflip+90 |
|
429 11 01 01 00 |
|
430 |
|
431 H flip 90 180 270 |
|
432 01 11 00 01 =Vflip =Vflip+90 |
|
433 00 10 10 11 |
|
434 @endcode |
|
435 |
|
436 @see COperationExtension::AddOperationL |
|
437 */ |
|
438 enum TTransformOptions |
|
439 { |
|
440 /** Normal Decode |
|
441 */ |
|
442 EDecodeNormal = 0x11011000, |
|
443 |
|
444 /** Rotate 90 degrees. |
|
445 */ |
|
446 EDecodeRotate90 = 0x10110001, |
|
447 |
|
448 /** Rotate 180 degrees. |
|
449 */ |
|
450 EDecodeRotate180 = 0x00100111, |
|
451 |
|
452 /** Rotate 270 degrees. |
|
453 */ |
|
454 EDecodeRotate270 = 0x01001110, |
|
455 |
|
456 /** Horizontal flip. |
|
457 */ |
|
458 EDecodeHorizontalFlip = 0x10001101, |
|
459 |
|
460 /** Horizontal flip and rotate 90 degrees. |
|
461 */ |
|
462 EDecodeHorizontalFlipRotate90 = 0x11100100, |
|
463 |
|
464 /** Vertical flip. |
|
465 */ |
|
466 EDecodeVerticalFlip = 0x01110010, |
|
467 |
|
468 /** Vertical flip and rotate 90 degrees. |
|
469 */ |
|
470 EDecodeVerticalFlipRotate90 = 0x00011011 |
|
471 }; |
|
472 |
|
473 |
|
474 /** |
|
475 @publishedAll |
|
476 @released |
|
477 |
|
478 Class that provides support for Framework Extensions. |
|
479 |
|
480 @see CImageProcessor |
|
481 @see CImageReadCodec |
|
482 @see CImageDecoderPlugin |
|
483 */ |
|
484 class CImageProcessorExtension : public CImageProcessor |
|
485 { |
|
486 public: |
|
487 IMPORT_C virtual ~CImageProcessorExtension(); |
|
488 IMPORT_C void SetClippingRect(const TRect& aRect); |
|
489 IMPORT_C void SetScaling(TInt aScalingCoeff); |
|
490 IMPORT_C void SetScaling(const TSize& aDesiredSize); |
|
491 IMPORT_C void SetOperation(TTransformOptions aOperation); |
|
492 IMPORT_C void SetInitialScanlineSkipPadding(TInt aNumberOfScanlines); |
|
493 |
|
494 protected: |
|
495 IMPORT_C CImageProcessorExtension(); |
|
496 |
|
497 protected: |
|
498 /** Clipping rectangle */ |
|
499 TRect iClippingRect; |
|
500 /** Scaling coefficient */ |
|
501 TInt iScalingCoeff; |
|
502 /** Desired size after scaling */ |
|
503 TSize iDesiredSize; |
|
504 /** Operations to apply to image */ |
|
505 TTransformOptions iOperation; |
|
506 /** Position in destination at which start rendering */ |
|
507 TPoint iStartPosition; |
|
508 /** Position in destination at which rendering is complete */ |
|
509 TPoint iEndPosition; |
|
510 /** An initial one-off number of scanlines to be skipped */ |
|
511 TInt iNumberOfScanlinesToSkip; |
|
512 }; |
|
513 |
|
514 inline TInt TColorConvertor::RgbToMonochrome(TRgb aRgb) |
|
515 { |
|
516 TInt value = aRgb.Internal(); |
|
517 TInt r = value&0xFF0000; |
|
518 TInt g = value&0xFF00; |
|
519 value = (value&0xFF)<<16; // blue<<16 |
|
520 value += r<<1; // + (red<<16)*2 |
|
521 value += g<<(16+2-8); // + (green<<16)*4 |
|
522 value += g<<(16+0-8); // + (green<<16) |
|
523 return value>>(16+3); // total/8 |
|
524 } |
|
525 |
|
526 #endif //___IMAGEPROCESSOR_H__ |
|