25 #include <f32file.h> |
25 #include <f32file.h> |
26 #include <AknIconUtils.h> // MAknIconFileProvider |
26 #include <AknIconUtils.h> // MAknIconFileProvider |
27 |
27 |
28 // Forward declarations |
28 // Forward declarations |
29 class CFbsBitmap; |
29 class CFbsBitmap; |
30 class CBitmapScaler; |
|
31 class CImageDecoder; |
|
32 class TAknsItemID; |
30 class TAknsItemID; |
33 class CWmUnitTest; |
31 class CWmUnitTest; |
34 class MSvgError; |
32 class MSvgError; |
35 |
33 |
36 // Class declaration |
34 // Class declaration |
37 /** |
35 /** |
38 * MConverterObserver |
|
39 * To notify when image is converted |
|
40 */ |
|
41 NONSHARABLE_CLASS( MConverterObserver ) |
|
42 { |
|
43 public: |
|
44 virtual void NotifyCompletion( TInt aError ) = 0; |
|
45 }; |
|
46 |
|
47 // Class declaration |
|
48 /** |
|
49 * CWmImageConverter |
36 * CWmImageConverter |
50 * Image converter |
37 * Image converter |
51 */ |
38 */ |
52 NONSHARABLE_CLASS ( CWmImageConverter ) : public CActive, |
39 NONSHARABLE_CLASS ( CWmImageConverter ) : public MAknIconFileProvider |
53 public MAknIconFileProvider |
|
54 { |
40 { |
55 /** states for this converter */ |
|
56 enum TState |
|
57 { |
|
58 EIdle = 0, |
|
59 EDecoding, |
|
60 EScalingBitmap, |
|
61 EScalingMask, |
|
62 EFailed |
|
63 }; |
|
64 |
|
65 public: //contructors/destructors |
41 public: //contructors/destructors |
66 /** |
42 /** |
67 * Two-phased constructor. |
43 * Two-phased constructor. |
68 * @param aObserver observer |
44 * @param aObserver observer |
69 */ |
45 */ |
70 static CWmImageConverter* NewL( MConverterObserver* aObserver ); |
46 static CWmImageConverter* NewL(); |
71 |
47 |
72 /** Destructor */ |
48 /** Destructor */ |
73 ~CWmImageConverter(); |
49 ~CWmImageConverter(); |
74 |
50 |
75 public: // interface methods |
51 public: // interface methods |
76 |
52 |
77 /** |
53 /** |
78 * Parses icon string and prepares logo image. |
54 * Parses icon string and prepares logo image. |
79 * |
55 * |
80 * @param aWidth wanted widht |
56 * @param aIconSize wanted size |
81 * @param aHeight wanted height |
|
82 * @param aIconStr str containing logo icon |
57 * @param aIconStr str containing logo icon |
|
58 * @param aBitmap bitmap to create. Empty if fails |
|
59 * @param aMask mask to create. Empty if fails |
83 * Supported values: |
60 * Supported values: |
84 * - skin(<major id> <minor id>):mif(<path> <bitmapid> <maskid>) |
61 * - skin(<major id> <minor id>):mif(<path> <bitmapid> <maskid>) |
85 * - mif(<path> <bitmapid> <maskid>) |
62 * - mif(<path> <bitmapid> <maskid>) |
86 * - uid(<application uid>) |
63 * - uid(<application uid>) |
87 * - <file name>.<png/svg> |
64 * - <file name>.<png/svg> |
88 * |
65 * |
89 * @return Error code |
66 * @return Error code |
90 */ |
67 */ |
91 TInt HandleIconString( TInt aWidth, TInt aHeight, const TDesC& aIconStr ); |
68 TInt HandleIconString( |
92 |
69 const TSize& aIconSize, |
93 /** |
70 const TDesC& aIconStr, |
94 * Returns converted bitmap. Caller takes ownership |
71 CFbsBitmap*& aBitmap, |
|
72 CFbsBitmap*& aMask ); |
|
73 |
|
74 /** |
|
75 * Parses icon string and resizes given bitmaps if needed. |
|
76 * Errors are ignored and previos size image will be used. |
95 * |
77 * |
96 * @return CFbsBitmap |
78 * @param aIconSize wanted size |
97 */ |
79 * @param aIconStr icon string to find out what to resize |
98 CFbsBitmap* Bitmap(); |
80 * @param aBitmap bitmap to resize |
|
81 * @param aMask mask to resize |
|
82 */ |
|
83 void UpdateImageSize( |
|
84 const TSize& aSize, |
|
85 const TDesC& aIconStr, |
|
86 CFbsBitmap& aBitmap, |
|
87 CFbsBitmap& aMask ); |
99 |
88 |
100 /** |
|
101 * Returns converted mask. Caller takes ownership |
|
102 * |
|
103 * @return CFbsBitmap |
|
104 */ |
|
105 CFbsBitmap* Mask(); |
|
106 |
|
107 /** |
|
108 * sets the size for decoding |
|
109 * @param aSize the logo size |
|
110 */ |
|
111 void SetLogoSize( const TSize& aSize ); |
|
112 |
|
113 /** supported image conversion methods */ |
|
114 enum TConversionMethod |
|
115 { |
|
116 EUnrecognized, // we could not recognise the icon string |
|
117 EUidIcon, // App.UID-coded icon |
|
118 ESvgIcon, // Icon from SVG-file |
|
119 ESkinIcon, // Icon from SKIN id |
|
120 EMifIcon, // Icon from MIF file, known graphic index |
|
121 ESkinAndMifIcon, // Icon from SKIN and MIF combination |
|
122 EImageIcon, // Icon from image file (jpeg or png) |
|
123 }; |
|
124 |
|
125 /** |
|
126 * The type of currently converted image. |
|
127 * This method can be used to check if correct conversion was used. |
|
128 * @return conversion method used for current image |
|
129 */ |
|
130 TConversionMethod ConversionMethod(); |
|
131 |
|
132 /** |
|
133 * Image convertion status |
|
134 * |
|
135 * @return ETrue if processing image, false otherwise. |
|
136 */ |
|
137 TBool IsProcessing(); |
|
138 |
|
139 protected: // implementation of CActive |
|
140 /** |
|
141 * Implements cancellation of an outstanding request. |
|
142 * |
|
143 * @see CActive::DoCancel |
|
144 */ |
|
145 void DoCancel(); |
|
146 |
|
147 /** |
|
148 * Handles an active object's request completion event. |
|
149 * |
|
150 * @see CActive::RunL |
|
151 */ |
|
152 void RunL(); |
|
153 |
|
154 /** |
|
155 * RunError |
|
156 * |
|
157 * @see CActive::RunError |
|
158 */ |
|
159 TInt RunError(TInt aError); |
|
160 |
|
161 private: |
89 private: |
162 CWmImageConverter(); |
90 CWmImageConverter(); |
163 void ConstructL( MConverterObserver* aObserver ); |
91 void ConstructL(); |
164 void CheckSvgErrorL( MSvgError* aError ); |
|
165 void HandleIconStringL( TInt aWidth, TInt aHeight, |
|
166 const TDesC& aIconStr ); |
|
167 |
92 |
168 private: |
93 private: |
|
94 void CheckSvgErrorL( MSvgError* aError ); |
|
95 void HandleIconStringL( const TSize& aIconSize, const TDesC& aIconStr ); |
169 |
96 |
170 TBool DoesScaleBitmapUseFallBack( CFbsBitmap* aSrcBitmap ); |
|
171 void ScaleBitmapL( const TSize& aSize, |
|
172 CFbsBitmap* aTrgBitmap, |
|
173 CFbsBitmap* aSrcBitmap ); |
|
174 void ScaleBitmap( TInt aWidth, TInt aHeight ); |
|
175 void ScaleMask( TInt aWidth, TInt aHeight ); |
|
176 void CreateIconFromUidL( const TUid& aUid ); |
97 void CreateIconFromUidL( const TUid& aUid ); |
177 void CreateIconFromSvgL( const TDesC& aFileName ); |
98 void CreateIconFromSvgL( const TDesC& aFileName ); |
178 void CreateIconFromOtherL( const TDesC& aFileName ); |
99 void CreateIconFromOtherL( const TDesC& aFileName ); |
179 void CreateSkinOrMifIconL( |
100 void CreateSkinOrMifIconL( |
180 const TAknsItemID& aItemId, TInt aBitmapId, |
101 const TAknsItemID& aItemId, TInt aBitmapId, |