|
1 /* |
|
2 * Copyright (c) 2007 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: Implementation of CMPXImageUtilSync. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32std.h> |
|
21 #include <mpxlog.h> |
|
22 |
|
23 #include "mpximageutil.h" |
|
24 #include "mpximageutilsync.h" |
|
25 |
|
26 // CONSTANTS |
|
27 |
|
28 // ============================ MEMBER FUNCTIONS =============================== |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // Two-phased constructor. |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CMPXImageUtilSync* CMPXImageUtilSync::NewL() |
|
35 { |
|
36 MPX_FUNC("CMPXImageUtil::NewL"); |
|
37 CMPXImageUtilSync* self = new ( ELeave ) CMPXImageUtilSync(); |
|
38 CleanupStack::PushL( self ); |
|
39 self->ConstructL(); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // C++ constructor can NOT contain any code, that might leave. |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CMPXImageUtilSync::CMPXImageUtilSync() : |
|
49 CActive( EPriorityStandard ) |
|
50 { |
|
51 MPX_FUNC( "CMPXImageUtilSync::CMPXImageUtilSync" ); |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // Symbian 2nd phase constructor can leave. |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 void CMPXImageUtilSync::ConstructL() |
|
59 { |
|
60 MPX_FUNC( "CMPXImageUtilSync::ConstructL" ); |
|
61 CActiveScheduler::Add(this); |
|
62 |
|
63 iImageUtil = CMPXImageUtil::NewL(); |
|
64 iActiveSchedulerWait = new ( ELeave ) CActiveSchedulerWait(); |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // Destructor |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 CMPXImageUtilSync::~CMPXImageUtilSync() |
|
72 { |
|
73 MPX_FUNC( "CMPXImageUtilSync::~CMPXImageUtilSync" ); |
|
74 delete iImageUtil; |
|
75 delete iActiveSchedulerWait; |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // Decodes an JPG synchronously |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 CFbsBitmap* CMPXImageUtilSync::DecodeL( |
|
83 const TDesC8& aJPGData, |
|
84 TSize aSize, |
|
85 TDisplayMode aDisplayMode /* = EColor64K */) |
|
86 { |
|
87 MPX_FUNC( "CMPXImageUtilSync::DecodeL" ); |
|
88 |
|
89 iBitmap = new ( ELeave ) CFbsBitmap(); |
|
90 |
|
91 iImageUtil->Decode( iStatus, aJPGData, *iBitmap, aSize, aDisplayMode ); |
|
92 SetActive(); |
|
93 |
|
94 // block waiting for completion |
|
95 iActiveSchedulerWait->Start(); |
|
96 User::LeaveIfError( iError ); |
|
97 |
|
98 // transfer the ownership |
|
99 CFbsBitmap* bmp = iBitmap; |
|
100 |
|
101 iBitmap = NULL; |
|
102 return bmp; |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // Decodes an JPG synchronously |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 CFbsBitmap* CMPXImageUtilSync::DecodeL( |
|
110 const TDesC& aSourceJPGFile, |
|
111 TSize aSize, |
|
112 TDisplayMode aDisplayMode /* = EColor64K */) |
|
113 { |
|
114 MPX_FUNC( "CMPXImageUtilSync::DecodeL" ); |
|
115 |
|
116 iBitmap = new ( ELeave ) CFbsBitmap(); |
|
117 |
|
118 iImageUtil->Decode( iStatus, aSourceJPGFile, *iBitmap, aSize, aDisplayMode ); |
|
119 SetActive(); |
|
120 |
|
121 // block waiting for completion |
|
122 iActiveSchedulerWait->Start(); |
|
123 User::LeaveIfError( iError ); |
|
124 |
|
125 // transfer the ownership |
|
126 CFbsBitmap* bmp = iBitmap; |
|
127 |
|
128 iBitmap = NULL; |
|
129 return bmp; |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // CMPXImageUtilSync::EncodeL |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 HBufC8* CMPXImageUtilSync::EncodeL( |
|
137 const CFbsBitmap& aSourceBMP) |
|
138 { |
|
139 MPX_FUNC( "CMPXImageUtilSync::EncodeL" ); |
|
140 |
|
141 iImageUtil->Encode( iStatus, aSourceBMP, iData ); |
|
142 SetActive(); |
|
143 |
|
144 // block waiting for completion |
|
145 iActiveSchedulerWait->Start(); |
|
146 User::LeaveIfError( iError ); |
|
147 |
|
148 // transfer the ownership |
|
149 HBufC8* dataTmp = iData; |
|
150 iData = NULL; |
|
151 return dataTmp; |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CMPXImageUtilSync::ScaleL |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 CFbsBitmap* CMPXImageUtilSync::ScaleL( |
|
159 CFbsBitmap& aSourceBMP, |
|
160 TSize aSize, |
|
161 TDisplayMode aDisplayMode /* = EColor64K */) |
|
162 { |
|
163 MPX_FUNC( "CMPXImageUtilSync::ScaleL" ); |
|
164 |
|
165 iBitmap = new ( ELeave ) CFbsBitmap(); |
|
166 |
|
167 iImageUtil->Scale( iStatus, aSourceBMP, *iBitmap, aSize, aDisplayMode ); |
|
168 SetActive(); |
|
169 |
|
170 // block waiting for completion |
|
171 iActiveSchedulerWait->Start(); |
|
172 User::LeaveIfError( iError ); |
|
173 |
|
174 // transfer the ownership |
|
175 CFbsBitmap* bmp = iBitmap; |
|
176 |
|
177 iBitmap = NULL; |
|
178 return bmp; |
|
179 } |
|
180 |
|
181 // ----------------------------------------------------------------------------- |
|
182 // CMPXImageUtilSync::DoCancel |
|
183 // ----------------------------------------------------------------------------- |
|
184 // |
|
185 void CMPXImageUtilSync::DoCancel() |
|
186 { |
|
187 MPX_FUNC( "CMPXImageUtilSync::DoCancel" ); |
|
188 iImageUtil->CancelRequest(); |
|
189 } |
|
190 |
|
191 // ----------------------------------------------------------------------------- |
|
192 // CMPXImageUtilSync::RunL |
|
193 // ----------------------------------------------------------------------------- |
|
194 // |
|
195 void CMPXImageUtilSync::RunL() |
|
196 { |
|
197 MPX_FUNC( "CMPXImageUtilSync::RunL" ); |
|
198 iActiveSchedulerWait->AsyncStop(); |
|
199 } |
|
200 |
|
201 // ----------------------------------------------------------------------------- |
|
202 // CMPXImageUtilSync::RunError |
|
203 // ----------------------------------------------------------------------------- |
|
204 // |
|
205 TInt CMPXImageUtilSync::RunError( |
|
206 TInt aError) |
|
207 { |
|
208 MPX_FUNC( "CMPXImageUtilSync::RunL" ); |
|
209 |
|
210 iError = aError; |
|
211 iActiveSchedulerWait->AsyncStop(); |
|
212 |
|
213 return KErrNone; |
|
214 } |
|
215 |
|
216 // End of File |