|
1 /* |
|
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "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 * |
|
14 * Description: Utility for creating bitmaps from image files |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 /** |
|
22 * @internal reviewed 30/07/2007 by Simon Brooks |
|
23 */ |
|
24 |
|
25 #ifndef GLXTNIMAGEUTILITY_H |
|
26 #define GLXTNIMAGEUTILITY_H |
|
27 |
|
28 #include <e32base.h> |
|
29 #include <gdi.h> // For TDisplayMode |
|
30 |
|
31 class MIHLScaler; |
|
32 class CFbsBitmap; |
|
33 class CFbsBitGc; |
|
34 class CImageDecoder; |
|
35 class RFs; |
|
36 |
|
37 /** |
|
38 * Utility for creating bitmaps from image files |
|
39 * |
|
40 * @ingroup glx_thumbnail_creator |
|
41 */ |
|
42 NONSHARABLE_CLASS(CGlxtnImageUtility) : public CBase |
|
43 { |
|
44 public: |
|
45 CGlxtnImageUtility(RFs& aFs); |
|
46 ~CGlxtnImageUtility(); |
|
47 |
|
48 void Cancel(); |
|
49 |
|
50 /** |
|
51 * Reduce target size to same aspect ratio as source image. |
|
52 */ |
|
53 void AdjustSize(TSize& aTargetSize, const TSize& aSourceSize); |
|
54 |
|
55 /** |
|
56 * Start asynchronous decoding process for a high quality thumbnail. |
|
57 * @param aStatus Request status for the asynchronous operation. |
|
58 * @param aFileName Full path of image file. |
|
59 * @param aTargetSize Size for the image - modified by this function to |
|
60 * preserve the aspect ratio. |
|
61 * @param aMode Display mode for the image. |
|
62 */ |
|
63 CFbsBitmap* DecodeImageL(TRequestStatus& aStatus, const TDesC& aFileName, |
|
64 RArray<TSize>& aTargetSizes, TDisplayMode aMode); |
|
65 |
|
66 /** |
|
67 * Free resources used by decoding. |
|
68 */ |
|
69 void FreeDecoder(); |
|
70 |
|
71 /** |
|
72 * Get the original size of the image decoded. |
|
73 */ |
|
74 const TSize& OriginalSize() const; |
|
75 |
|
76 /** |
|
77 * Start asynchronous filtering process for a high quality thumbnail. |
|
78 * @param aStatus Request status for the asynchronous operation. |
|
79 * @param aSource Source image bitmap. |
|
80 * @param aFilteredSource Filtered image bitmap. |
|
81 * @param aTarget Target thumbnail bitmap. |
|
82 */ |
|
83 void FilterImageL(TRequestStatus* aStatus, CFbsBitmap* aSource, CFbsBitmap*& aFilteredSource, CFbsBitmap* aTarget); |
|
84 |
|
85 /** |
|
86 * Start asynchronous scaling process for a high quality thumbnail. |
|
87 * @param aStatus Request status for the asynchronous operation. |
|
88 * @param aSrcBitmap Source image bitmap. |
|
89 * @param aSrcRect Source image rectangle. |
|
90 * @param aDstBitmap Destination thumbnail bitmap. |
|
91 * @param aDstRect Destination image rectangle. |
|
92 */ |
|
93 void ScaleImageL(TRequestStatus& aStatus, CFbsBitmap& aSrcBitmap, const TRect& aSrcRect, CFbsBitmap& aDstBitmap, const TRect& aDstRect); |
|
94 |
|
95 /** |
|
96 * Start asynchronous scaling process for a high quality thumbnail. |
|
97 * @param aStatus Request status for the asynchronous operation. |
|
98 * @param aSource Source image bitmap. |
|
99 * @param aFilteredSource Filtered Source image bitmap. |
|
100 * @param aTarget Target thumbnail bitmap. |
|
101 */ |
|
102 void ScaleImage64kL(TRequestStatus* aStatus, CFbsBitmap* aSource, CFbsBitmap* aFilteredSource, CFbsBitmap* aTarget); |
|
103 |
|
104 private: |
|
105 |
|
106 void ScaleColor64K( TUint16* aSrc, TInt aSrcStride, TInt aSrcCols, TInt aSrcRows, |
|
107 TInt aX, TInt aY, TInt aW, TInt aH, |
|
108 TUint16* aDst, TInt aDstStride, TInt aDstCols, TInt aDstRows ); |
|
109 |
|
110 void FilterL( CFbsBitmap* aSource, CFbsBitmap*& aFilteredSource, TInt aFilterPercent ); |
|
111 |
|
112 void FIRFiltering( |
|
113 TUint16* aDst, TUint aDstStridep, TUint aDstCols, TUint aDstRows ); |
|
114 |
|
115 void FIRFiltering4( |
|
116 TUint16* aDst, TUint aDstStridep, TUint aDstCols, TUint aDstRows ); |
|
117 |
|
118 void FIRFiltering8( |
|
119 TUint16* aDst, TUint aDstStridep, TUint aDstCols, TUint aDstRows ); |
|
120 /* |
|
121 * Get the orientation of the file |
|
122 * This API reads the Exif tag in an image and returns the orientation of that Image |
|
123 */ |
|
124 TUint16 GetOrientationL(const TDesC& aFileName) ; |
|
125 /* |
|
126 * Get the Rotation Angle and Mirroring status of the image so as to set it on the decoder |
|
127 * This API calculates the rotation angle and the Mirroring status required by the decoder |
|
128 * @param aOrientation Orientation of the image. |
|
129 * @param aRotAngle Rotation angle to be set on the image decoder. |
|
130 * @param aFlipStatus Mirroring status for the decoder if 1 then mirroring should be set. |
|
131 * Internally it also sets the iOriginalSize to the required size |
|
132 */ |
|
133 void GetRotationParameters(TUint16 aOrientation, TInt& aRotAngle, TBool& aFlipStatus) ; |
|
134 private: |
|
135 // File server session |
|
136 RFs& iFs; |
|
137 // Decoder used to read image from file |
|
138 CImageDecoder* iDecoder; |
|
139 // Bitmap scaler |
|
140 MIHLScaler* iScaler; |
|
141 /** Size of the image in the file being decoded */ |
|
142 TSize iOriginalSize; |
|
143 CFbsBitmap* iImage; |
|
144 TUint16* iAddress; |
|
145 CFbsBitGc* iBitGc; |
|
146 }; |
|
147 |
|
148 #endif // GLXTNIMAGEUTILITY_H |