|
1 /* |
|
2 * Copyright (c) 2005 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: Image loader and scaler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CCAIMAGELOADER_H |
|
20 #define CCAIMAGELOADER_H |
|
21 |
|
22 #include <f32file.h> |
|
23 #include "MCAChatObserver.h" |
|
24 #include "MCAContentProcessor.h" |
|
25 |
|
26 // FORWARD CLASS DECLERATIONS |
|
27 class MCAChatInterface; |
|
28 class CCAPictureMessage; |
|
29 class CImageDecoder; |
|
30 class CBitmapScaler; |
|
31 class CFbsBitmap; |
|
32 class CImageEncoder; |
|
33 class MCAImpsFactory; |
|
34 |
|
35 // CLASS DECLARATION |
|
36 |
|
37 /** |
|
38 * Image loader and scaler |
|
39 * |
|
40 * @lib CAEngine.dll |
|
41 * @since 3.0 |
|
42 */ |
|
43 class CCAImageLoader : public CActive, public MCAContentProcessor |
|
44 { |
|
45 public: // Construction |
|
46 |
|
47 /** |
|
48 * Construction |
|
49 */ |
|
50 static CCAImageLoader* NewL( MCAChatInterface& aChatInterface, |
|
51 MCAImpsFactory& aImpsFactory ); |
|
52 |
|
53 /** |
|
54 * Destruction |
|
55 */ |
|
56 ~CCAImageLoader(); |
|
57 |
|
58 private: // Construction |
|
59 |
|
60 /** |
|
61 * Constructor |
|
62 */ |
|
63 CCAImageLoader( MCAChatInterface& aChatInterface, |
|
64 MCAImpsFactory& aImpsFactory ); |
|
65 |
|
66 /** |
|
67 * Constructor |
|
68 */ |
|
69 void ConstructL(); |
|
70 |
|
71 private: // From CActive |
|
72 |
|
73 /** |
|
74 * @see CActive |
|
75 */ |
|
76 void RunL(); |
|
77 |
|
78 /** |
|
79 * @see CActive |
|
80 */ |
|
81 void DoCancel(); |
|
82 |
|
83 /** |
|
84 * @see CActive. |
|
85 */ |
|
86 TInt RunError( TInt aError ); |
|
87 |
|
88 private: // From MCAContentProcessor |
|
89 |
|
90 /** |
|
91 * @see MCAContentProcessor |
|
92 */ |
|
93 void RequestProcessingL( MCAMessage& aMessage ); |
|
94 |
|
95 /** |
|
96 * @see MCAContentProcessor |
|
97 */ |
|
98 void StartProcessingL( MCAMessage& aMessage ); |
|
99 |
|
100 /** |
|
101 * @see MCAContentProcessor |
|
102 */ |
|
103 void CancelProcessing( MCAMessage& aMessage ); |
|
104 |
|
105 /** |
|
106 * @see MCAContentProcessor |
|
107 */ |
|
108 void RemoveProcessingL( MCAMessage& aMessage ); |
|
109 |
|
110 private: // New helper methods |
|
111 |
|
112 /** |
|
113 * LaunchProcessing if needed. |
|
114 */ |
|
115 void LaunchProcessingL(); |
|
116 |
|
117 /** |
|
118 * Get new size after decoding. |
|
119 * Scale to nearest (larger or equal) size with ratio 1:1, 1:2, 1:4 or 1:8 |
|
120 * directly when decoding. |
|
121 * |
|
122 * @param aSize Size of original image |
|
123 * @param aTargetSize Size of target image |
|
124 * @param aAnyRatio Set this to ETrue if the decoder is cabable of scaling to any ratio |
|
125 * @return New size of decoded image |
|
126 */ |
|
127 TSize DecodeSize( const TSize& aSize, const TSize& aTargetSize, |
|
128 TBool aAnyRatio ); |
|
129 |
|
130 /** |
|
131 * Get new size after scaling. If scale not needed return EFalse |
|
132 * Scaled size will be 320x240 if width > height or 240x320 if |
|
133 * height > width. |
|
134 * |
|
135 * @param aSize Original size of image |
|
136 * @param aNewSize New size of scaled image |
|
137 * @return ETrue if scale needed. |
|
138 */ |
|
139 TBool ScaleSize( const TSize& aSize, TSize& aNewSize ); |
|
140 |
|
141 /** |
|
142 * Notify observer for completion and remove message from array |
|
143 */ |
|
144 void CompleteRequestL(); |
|
145 |
|
146 /** |
|
147 * Reset current operation and remove all pending messages from stack. |
|
148 * @param aReason reson for reseting |
|
149 */ |
|
150 void ResetProcessingL( TInt aReason ); |
|
151 |
|
152 /** |
|
153 * Deletes and cancels all processing units ( decoder, encoder etc ). |
|
154 */ |
|
155 void ClearState(); |
|
156 |
|
157 |
|
158 private: // Data |
|
159 |
|
160 /// File system access |
|
161 RFs iFs; |
|
162 |
|
163 // Decoder for image. |
|
164 CImageDecoder* iDecoder; |
|
165 CBitmapScaler* iScaler; |
|
166 CImageEncoder* iEncoder; |
|
167 |
|
168 /// Interface to access containers |
|
169 MCAChatInterface& iChatInterface; |
|
170 |
|
171 /// Array of images to operate. |
|
172 RPointerArray< MCAMessage > iMessages; |
|
173 |
|
174 /// Processing on/off. |
|
175 TBool iProcessing; |
|
176 |
|
177 /// Bitmap. Owns. |
|
178 CFbsBitmap* iBitmap; |
|
179 |
|
180 /// Current message in process |
|
181 MCAMessage* iCurrentMessage; |
|
182 |
|
183 /// Target size for bitmap |
|
184 TSize iTargetSize; |
|
185 |
|
186 /// Thumbnail size for bitmap |
|
187 TSize iThumbSize; |
|
188 |
|
189 /// Owns. |
|
190 HBufC8* iContent; |
|
191 |
|
192 // Interface to MCAImpsFactory. Not owned. |
|
193 MCAImpsFactory& iImpsFactory; |
|
194 |
|
195 // See IMVariant.hrh, flag depends on |
|
196 // feature EIMFeatSendNotScalable. |
|
197 TBool iSendNotScalable; |
|
198 }; |
|
199 |
|
200 #endif // CCAIMAGELOADER_H |
|
201 |
|
202 // End of File |