29 #include <bitmaptransforms.h> |
29 #include <bitmaptransforms.h> |
30 |
30 |
31 class CImageDecoder; |
31 class CImageDecoder; |
32 class CFbsBitmap; |
32 class CFbsBitmap; |
33 |
33 |
|
34 /** |
|
35 * Interface to observer contain |
|
36 * ImageReadyCallBack function return error code and scaled/resized bitmap. |
|
37 */ |
34 class MImageReadyCallBack |
38 class MImageReadyCallBack |
35 { |
39 { |
36 public: |
40 public: |
37 virtual void ImageReadyCallBack(TInt error, const CFbsBitmap *bitmap ) = 0; |
41 virtual void ImageReadyCallBack(TInt error, const CFbsBitmap *bitmap) = 0; |
38 }; |
42 }; |
39 |
43 |
|
44 /** |
|
45 * Class to scaling graphic file/s. |
|
46 */ |
40 class CTsGraphicFileScalingHandler : public CActive |
47 class CTsGraphicFileScalingHandler : public CActive |
41 { |
48 { |
42 public: |
49 public: |
43 |
50 /** |
44 enum TCurrentOperation{ |
51 * Kind of graphic file scaling. |
|
52 * EIgnoreAspectRatio - the file is scaled to size, aspect ratio isn't preserving. |
|
53 * EKeepAspectRatio - the file is scaled to a rectangle as large as possible inside size |
|
54 * preserving the aspect ratio. |
|
55 * EKeepAspectRatioByExpanding - the file is scaled to a rectangle as small as possible outside size |
|
56 * preserving the aspect ratio. |
|
57 */ |
|
58 enum TKindOfScaling |
|
59 { |
|
60 EIgnoreAspectRatio = 0, |
|
61 EKeepAspectRatio = 1, |
|
62 EKeepAspectRatioByExpanding = 2, |
|
63 }; |
|
64 |
|
65 private: |
|
66 /** |
|
67 * Active object current operation. |
|
68 */ |
|
69 enum TCurrentOperation{ |
45 ENone = 0, |
70 ENone = 0, |
46 EConvertBitmapFromFile = 1, |
71 EConvertBitmapFromFile = 1, |
47 EScale = 2 |
72 EScale = 2 |
48 }; |
73 }; |
49 |
74 |
50 enum TKindOfScaling |
75 public: |
51 { |
76 /** |
52 EIgnoreAspectRatio = 0, |
77 * Destructor. |
53 EKeepAspectRatio = 1, |
78 */ |
54 EKeepAspectRatioByExpanding = 2, |
|
55 }; |
|
56 |
|
57 IMPORT_C ~CTsGraphicFileScalingHandler(); |
79 IMPORT_C ~CTsGraphicFileScalingHandler(); |
58 |
80 |
|
81 /** |
|
82 * All constructors initialise active object asynchronous operation |
|
83 * by calling ConstructL function. |
|
84 * 1st group - decoding and scaling. |
|
85 * 2nd group - scaling. |
|
86 */ |
|
87 |
|
88 /** |
|
89 * 1st group. |
|
90 * Exported from dll constructors for activation graphic file scaling. |
|
91 * aNotify - reference to observer implementation. |
|
92 * aFs - reference to file server session. |
|
93 * aFileName - path to graphic file. |
|
94 * aMimeType - mime type of graphic file. |
|
95 * aNewSize - new size of output graphic file. |
|
96 * aKindOfScaling - kind of graphic file scaling described above. |
|
97 */ |
59 IMPORT_C static CTsGraphicFileScalingHandler* NewL(MImageReadyCallBack &aNotify, |
98 IMPORT_C static CTsGraphicFileScalingHandler* NewL(MImageReadyCallBack &aNotify, |
60 RFs &aFs, |
99 RFs &aFs, |
61 const TDesC &aFileName, |
100 const TDesC &aFileName, |
62 const TDesC8& aMimeType, |
101 const TDesC8& aMimeType, |
63 const TSize &aNewSize, |
102 const TSize &aNewSize, |
67 const TDesC &aFileName, |
106 const TDesC &aFileName, |
68 const TDesC8& aMimeType, |
107 const TDesC8& aMimeType, |
69 const TSize &aNewSize, |
108 const TSize &aNewSize, |
70 TKindOfScaling aKindOfScaling = CTsGraphicFileScalingHandler::EIgnoreAspectRatio); |
109 TKindOfScaling aKindOfScaling = CTsGraphicFileScalingHandler::EIgnoreAspectRatio); |
71 |
110 |
|
111 /** |
|
112 * 2nd group. |
|
113 * Exported from dll constructors for activation graphic file scaling. |
|
114 * aNotify - reference to observer implementation. |
|
115 * aImputFbsBitmap - reference to pattern CFbsBitmap. |
|
116 * aNewSize - new size of output graphic file. |
|
117 * aKindOfScaling - kind of graphic file scaling described above. |
|
118 */ |
|
119 IMPORT_C static CTsGraphicFileScalingHandler* NewL(MImageReadyCallBack &aNotify, |
|
120 const CFbsBitmap &aImputFbsBitmap, |
|
121 const TSize &aNewSize, |
|
122 TKindOfScaling aKindOfScaling = CTsGraphicFileScalingHandler::EIgnoreAspectRatio); |
|
123 IMPORT_C static CTsGraphicFileScalingHandler* NewLC(MImageReadyCallBack &aNotify, |
|
124 const CFbsBitmap &aImputFbsBitmap, |
|
125 const TSize &aNewSize, |
|
126 TKindOfScaling aKindOfScaling = CTsGraphicFileScalingHandler::EIgnoreAspectRatio); |
|
127 |
72 protected: |
128 protected: |
|
129 /** |
|
130 * Cancels the wait for completion of an outstanding request. |
|
131 */ |
73 void DoCancel(); |
132 void DoCancel(); |
|
133 /** |
|
134 * Handles an active object’s request completion event. |
|
135 */ |
74 void RunL(); |
136 void RunL(); |
|
137 /** |
|
138 * Handles a leave occurring in the request completion event handler RunL(). |
|
139 */ |
75 TInt RunError(TInt); |
140 TInt RunError(TInt); |
76 |
141 |
77 private: |
142 private: |
|
143 /** |
|
144 * Functions construct active objest instance and made asynchronous operation/s. |
|
145 * Parameters - the same meaning as in appropriate NewL/NewLC functions. |
|
146 */ |
78 void ConstructL(RFs &aFs, const TDesC &aFileName, const TDesC8& aMimeType); |
147 void ConstructL(RFs &aFs, const TDesC &aFileName, const TDesC8& aMimeType); |
|
148 void ConstructL(const CFbsBitmap &aImputFbsBitmap); |
|
149 /** |
|
150 * Private constructor. |
|
151 * Parameters - the same meaning as in appropriate NewL/NewLC functions. |
|
152 */ |
79 CTsGraphicFileScalingHandler(MImageReadyCallBack &aNotify, |
153 CTsGraphicFileScalingHandler(MImageReadyCallBack &aNotify, |
80 const TSize &aNewSize, |
154 const TSize &aNewSize, |
81 TKindOfScaling aKindOfScaling = CTsGraphicFileScalingHandler::EIgnoreAspectRatio); |
155 TKindOfScaling aKindOfScaling = CTsGraphicFileScalingHandler::EIgnoreAspectRatio); |
82 TSize Scaling(); |
156 /** |
|
157 * Action to made before decoding graphic file operation. |
|
158 * Parameters - the same meaning as in appropriate NewL/NewLC functions. |
|
159 */ |
|
160 void DecodingOperationL(RFs &aFs, const TDesC &aFileName, const TDesC8& aMimeType); |
|
161 /** |
|
162 * Action to made before scaling graphic file operation. |
|
163 */ |
|
164 void ScalingOperationL(); |
|
165 /** |
|
166 * Algorithm to determine output bitmap (returned in ImageReadyCallBack) size |
|
167 * after scaling operation. |
|
168 */ |
|
169 TSize NewSizeToScalingOperation(); |
|
170 /** |
|
171 * Fix for TDisplayMode == EColor16MAP not supported by scaling operation! |
|
172 * ! ! ! ADD OTHER NOT SUPPORTED DISPLAY MODES ! ! ! |
|
173 */ |
|
174 void FixForDisplayModeNotSupportedByScalingOperation(); |
83 |
175 |
84 private: |
176 private: |
|
177 /** |
|
178 * Reference to observer implementation - return error code and output bitmap. |
|
179 */ |
85 MImageReadyCallBack &mNotify; |
180 MImageReadyCallBack &mNotify; |
|
181 /** |
|
182 * Pointer to decoder used by decoding graphic file algorithm. |
|
183 */ |
86 CImageDecoder *mImageDecoder; |
184 CImageDecoder *mImageDecoder; |
87 CFbsBitmap *mBitmapFromFile; |
185 /** |
88 CFbsBitmap *mBitmapOutput; |
186 * Pointer to input bitmap - before decoding/scaling operation/s. |
|
187 */ |
|
188 CFbsBitmap *mInputBitmap; |
|
189 /** |
|
190 * Pointer to output bitmap - returned in mNotify object. |
|
191 */ |
|
192 CFbsBitmap *mOutputBitmap; |
|
193 /** |
|
194 * Pointer to CBitmapScaler calss used by scaling graphic file algorithm. |
|
195 */ |
89 CBitmapScaler *mBitmapScaler; |
196 CBitmapScaler *mBitmapScaler; |
|
197 /** |
|
198 * New size of output graphic file. |
|
199 */ |
90 TSize mNewSize; |
200 TSize mNewSize; |
|
201 /** |
|
202 * Kind of graphic file scaling described above. |
|
203 */ |
91 TBool mKindOfScaling; |
204 TBool mKindOfScaling; |
92 |
205 /** |
|
206 * Active object current operation. |
|
207 */ |
93 TCurrentOperation mCurrentOperation; |
208 TCurrentOperation mCurrentOperation; |
94 }; |
209 }; |
95 |
210 |
96 #endif // TSGRAPHICFILESCALINGHANDLER_H |
211 #endif // TSGRAPHICFILESCALINGHANDLER_H |