|
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
|
2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> |
|
3 <title>TB10.1 Example Applications: examples/Multimedia/ICL/ICLExample/iclencodeexample.cpp Source File</title> |
|
4 <link href="doxygen.css" rel="stylesheet" type="text/css"> |
|
5 <link href="tabs.css" rel="stylesheet" type="text/css"> |
|
6 </head><body> |
|
7 <!-- Generated by Doxygen 1.5.3 --> |
|
8 <h1>examples/Multimedia/ICL/ICLExample/iclencodeexample.cpp</h1><a href="iclencodeexample_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// iclencodeexample.cpp</span> |
|
9 <a name="l00002"></a>00002 <span class="comment">// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).</span> |
|
10 <a name="l00003"></a>00003 <span class="comment">// All rights reserved.</span> |
|
11 <a name="l00004"></a>00004 <span class="comment">// This component and the accompanying materials are made available</span> |
|
12 <a name="l00005"></a>00005 <span class="comment">// under the terms of "Eclipse Public License v1.0"</span> |
|
13 <a name="l00006"></a>00006 <span class="comment">// which accompanies this distribution, and is available</span> |
|
14 <a name="l00007"></a>00007 <span class="comment">// at the URL "http://www.eclipse.org/legal/epl-v10.html".</span> |
|
15 <a name="l00008"></a>00008 <span class="comment">//</span> |
|
16 <a name="l00009"></a>00009 <span class="comment">// Initial Contributors:</span> |
|
17 <a name="l00010"></a>00010 <span class="comment">// Nokia Corporation - initial contribution.</span> |
|
18 <a name="l00011"></a>00011 <span class="comment">//</span> |
|
19 <a name="l00012"></a>00012 <span class="comment">// Contributors:</span> |
|
20 <a name="l00013"></a>00013 <span class="comment">//</span> |
|
21 <a name="l00014"></a>00014 <span class="comment">// Description:</span> |
|
22 <a name="l00015"></a>00015 <span class="comment">// </span> |
|
23 <a name="l00016"></a>00016 <span class="comment">//</span> |
|
24 <a name="l00017"></a>00017 |
|
25 <a name="l00018"></a>00018 |
|
26 <a name="l00039"></a>00039 <span class="preprocessor">#include "<a class="code" href="iclexample_8h.html">iclexample.h</a>"</span> |
|
27 <a name="l00040"></a>00040 <span class="preprocessor">#include <gifscaler.h></span> |
|
28 <a name="l00041"></a>00041 <span class="preprocessor">#include <imagetransform.h></span> |
|
29 <a name="l00042"></a>00042 |
|
30 <a name="l00053"></a><a class="code" href="class_c_icl_example.html#d62bffc043397eb7306cfb0d1bf427df">00053</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#d62bffc043397eb7306cfb0d1bf427df">CIclExample::EncodeBitmapToDescriptorL</a>(<span class="keyword">const</span> TDesC& aFileName) |
|
31 <a name="l00054"></a>00054 { |
|
32 <a name="l00055"></a>00055 HBufC8* encodedImageDescriptor = NULL; |
|
33 <a name="l00056"></a>00056 |
|
34 <a name="l00057"></a>00057 <span class="comment">// Create the encoder, passing a buffer to store the encoded image</span> |
|
35 <a name="l00058"></a>00058 CImageEncoder* encoder = CImageEncoder::DataNewL(encodedImageDescriptor, CImageEncoder::EOptionNone,KImageTypeGIFUid); |
|
36 <a name="l00059"></a>00059 CleanupStack::PushL(encoder); |
|
37 <a name="l00060"></a>00060 |
|
38 <a name="l00061"></a>00061 <span class="comment">// Create a CFbsBitmap to store the source bitmap to encode</span> |
|
39 <a name="l00062"></a>00062 CFbsBitmap* sourceBitmap = <span class="keyword">new</span>(ELeave) CFbsBitmap; |
|
40 <a name="l00063"></a>00063 CleanupStack::PushL(sourceBitmap); |
|
41 <a name="l00064"></a>00064 |
|
42 <a name="l00065"></a>00065 User::LeaveIfError(sourceBitmap->Create(TSize(20,30), EColor16M)); |
|
43 <a name="l00066"></a>00066 User::LeaveIfError(sourceBitmap->Load(aFileName)); |
|
44 <a name="l00067"></a>00067 |
|
45 <a name="l00068"></a>00068 <span class="comment">// See Note 1</span> |
|
46 <a name="l00069"></a>00069 <a class="code" href="class_c_active_listener.html">CActiveListener</a>* activeListener = <a class="code" href="class_c_icl_example.html#6cb9b9dbd3a9e04e6ad4f144e6e2a8d9">CreateAndInitializeActiveListenerLC</a>(); |
|
47 <a name="l00070"></a>00070 |
|
48 <a name="l00071"></a>00071 <span class="comment">// Convert the image</span> |
|
49 <a name="l00072"></a>00072 encoder->Convert(&activeListener->iStatus, *sourceBitmap); |
|
50 <a name="l00073"></a>00073 |
|
51 <a name="l00074"></a>00074 <span class="comment">// See Note 2</span> |
|
52 <a name="l00075"></a>00075 CActiveScheduler::Start(); |
|
53 <a name="l00076"></a>00076 User::LeaveIfError(activeListener->iStatus.Int());<span class="comment">// encode complete either display the image or report an error.</span> |
|
54 <a name="l00077"></a>00077 |
|
55 <a name="l00078"></a>00078 |
|
56 <a name="l00079"></a>00079 CleanupStack::PopAndDestroy(3); <span class="comment">// encoder, sourceBitmap and activeListener</span> |
|
57 <a name="l00080"></a>00080 |
|
58 <a name="l00081"></a>00081 |
|
59 <a name="l00082"></a>00082 <span class="comment">// We can use the descriptor here</span> |
|
60 <a name="l00083"></a>00083 |
|
61 <a name="l00084"></a>00084 <span class="comment">// And as we took ownership back, we need to push into the cleanup stack to make sure no</span> |
|
62 <a name="l00085"></a>00085 <span class="comment">// memory leaks take place if any leave later</span> |
|
63 <a name="l00086"></a>00086 |
|
64 <a name="l00087"></a>00087 CleanupDeletePushL(encodedImageDescriptor); |
|
65 <a name="l00088"></a>00088 |
|
66 <a name="l00089"></a>00089 |
|
67 <a name="l00090"></a>00090 <span class="comment">// Just verifying the presence of some output. </span> |
|
68 <a name="l00091"></a>00091 |
|
69 <a name="l00092"></a>00092 RFile file; |
|
70 <a name="l00093"></a>00093 |
|
71 <a name="l00094"></a>00094 User::LeaveIfError(file.Replace(iFs, _L(<span class="stringliteral">"c:\\ICLExample\\encodeddescriptor.mbm"</span>), EFileWrite)); |
|
72 <a name="l00095"></a>00095 CleanupClosePushL(file); |
|
73 <a name="l00096"></a>00096 |
|
74 <a name="l00097"></a>00097 User::LeaveIfError(file.Write(*encodedImageDescriptor)); |
|
75 <a name="l00098"></a>00098 |
|
76 <a name="l00099"></a>00099 CleanupStack::PopAndDestroy(&file); |
|
77 <a name="l00100"></a>00100 |
|
78 <a name="l00101"></a>00101 |
|
79 <a name="l00102"></a>00102 CleanupStack::PopAndDestroy(encodedImageDescriptor); |
|
80 <a name="l00103"></a>00103 } |
|
81 <a name="l00104"></a>00104 |
|
82 <a name="l00105"></a>00105 |
|
83 <a name="l00116"></a><a class="code" href="class_c_icl_example.html#e104f588c16e81bfbfe09e6cfc43ef16">00116</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#e104f588c16e81bfbfe09e6cfc43ef16">CIclExample::EncodeImageWithThumbnailL</a>(<span class="keyword">const</span> TDesC& aFileName) |
|
84 <a name="l00117"></a>00117 { |
|
85 <a name="l00118"></a>00118 HBufC8* encodedImageDescriptor = NULL; |
|
86 <a name="l00119"></a>00119 |
|
87 <a name="l00120"></a>00120 <span class="comment">// Create the encoder, passing a buffer to store the encoded image</span> |
|
88 <a name="l00121"></a>00121 CImageEncoder* encoder = CImageEncoder::DataNewL(encodedImageDescriptor, CImageEncoder::EOptionNone, KImageTypeJPGUid); |
|
89 <a name="l00122"></a>00122 CleanupStack::PushL(encoder); |
|
90 <a name="l00123"></a>00123 |
|
91 <a name="l00124"></a>00124 <span class="comment">// Set the image type to thumbnail </span> |
|
92 <a name="l00125"></a>00125 encoder->SetThumbnail(ETrue); |
|
93 <a name="l00126"></a>00126 |
|
94 <a name="l00127"></a>00127 <span class="comment">// Create a bitmap to access the thumbnail</span> |
|
95 <a name="l00128"></a>00128 CFbsBitmap* sourceBitmap = <span class="keyword">new</span>(ELeave) CFbsBitmap; |
|
96 <a name="l00129"></a>00129 CleanupStack::PushL(sourceBitmap); |
|
97 <a name="l00130"></a>00130 |
|
98 <a name="l00131"></a>00131 User::LeaveIfError(sourceBitmap->Create(TSize(250,200), EColor16M)); |
|
99 <a name="l00132"></a>00132 User::LeaveIfError(sourceBitmap->Load(aFileName)); |
|
100 <a name="l00133"></a>00133 |
|
101 <a name="l00134"></a>00134 <span class="comment">// See Note 1</span> |
|
102 <a name="l00135"></a>00135 <a class="code" href="class_c_active_listener.html">CActiveListener</a>* activeListener = <a class="code" href="class_c_icl_example.html#6cb9b9dbd3a9e04e6ad4f144e6e2a8d9">CreateAndInitializeActiveListenerLC</a>(); |
|
103 <a name="l00136"></a>00136 |
|
104 <a name="l00137"></a>00137 <span class="comment">// Convert the image</span> |
|
105 <a name="l00138"></a>00138 encoder->Convert(&activeListener->iStatus, *sourceBitmap); |
|
106 <a name="l00139"></a>00139 |
|
107 <a name="l00140"></a>00140 <span class="comment">// See Note 2</span> |
|
108 <a name="l00141"></a>00141 CActiveScheduler::Start(); |
|
109 <a name="l00142"></a>00142 User::LeaveIfError(activeListener->iStatus.Int()); <span class="comment">// access to thumbnail complete either display the image or report an error.</span> |
|
110 <a name="l00143"></a>00143 |
|
111 <a name="l00144"></a>00144 |
|
112 <a name="l00145"></a>00145 CleanupStack::PopAndDestroy(3); <span class="comment">// encoder, sourceBitmap and activeListener</span> |
|
113 <a name="l00146"></a>00146 |
|
114 <a name="l00147"></a>00147 |
|
115 <a name="l00148"></a>00148 <span class="comment">// We can use the descriptor here</span> |
|
116 <a name="l00149"></a>00149 |
|
117 <a name="l00150"></a>00150 <span class="comment">// And as we took ownership back, we need to push into the cleanup stack to make sure no</span> |
|
118 <a name="l00151"></a>00151 <span class="comment">// memory leaks take place if any leave later</span> |
|
119 <a name="l00152"></a>00152 |
|
120 <a name="l00153"></a>00153 CleanupDeletePushL(encodedImageDescriptor); |
|
121 <a name="l00154"></a>00154 |
|
122 <a name="l00155"></a>00155 |
|
123 <a name="l00156"></a>00156 <span class="comment">// Just verifying the presence of some output.</span> |
|
124 <a name="l00157"></a>00157 |
|
125 <a name="l00158"></a>00158 RFile file; |
|
126 <a name="l00159"></a>00159 |
|
127 <a name="l00160"></a>00160 User::LeaveIfError(file.Replace(iFs, _L(<span class="stringliteral">"c:\\ICLExample\\encodedbitmapwiththumbnail.mbm"</span>), EFileWrite)); |
|
128 <a name="l00161"></a>00161 CleanupClosePushL(file); |
|
129 <a name="l00162"></a>00162 |
|
130 <a name="l00163"></a>00163 User::LeaveIfError(file.Write(*encodedImageDescriptor)); |
|
131 <a name="l00164"></a>00164 |
|
132 <a name="l00165"></a>00165 CleanupStack::PopAndDestroy(&file); |
|
133 <a name="l00166"></a>00166 |
|
134 <a name="l00167"></a>00167 |
|
135 <a name="l00168"></a>00168 CleanupStack::PopAndDestroy(encodedImageDescriptor); |
|
136 <a name="l00169"></a>00169 } |
|
137 <a name="l00170"></a>00170 |
|
138 <a name="l00171"></a>00171 |
|
139 <a name="l00183"></a><a class="code" href="class_c_icl_example.html#dc8169ae5510b9b6d5e55c28e08574c5">00183</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#dc8169ae5510b9b6d5e55c28e08574c5">CIclExample::SettingExifMetadataL</a>(<span class="keyword">const</span> TDesC& aFileName) |
|
140 <a name="l00184"></a>00184 { |
|
141 <a name="l00185"></a>00185 HBufC8* encodedImageDescriptor = NULL; |
|
142 <a name="l00186"></a>00186 |
|
143 <a name="l00187"></a>00187 <span class="comment">// Create the encoder, passing a buffer to store the encoded image</span> |
|
144 <a name="l00188"></a>00188 CJPEGExifEncoder* exifEncoder = <span class="keyword">static_cast<</span>CJPEGExifEncoder*<span class="keyword">></span>(CImageEncoder::DataNewL(encodedImageDescriptor, CImageEncoder::EOptionNone, KImageTypeJPGUid)); |
|
145 <a name="l00189"></a>00189 CleanupStack::PushL(exifEncoder); |
|
146 <a name="l00190"></a>00190 |
|
147 <a name="l00191"></a>00191 <span class="comment">// Create a MExifMetadata object and initialize it with the metadata associated with CJPEGexifEncoder </span> |
|
148 <a name="l00192"></a>00192 MExifMetadataWriter* metaData = exifEncoder->ExifMetadata(); |
|
149 <a name="l00193"></a>00193 |
|
150 <a name="l00194"></a>00194 <span class="comment">// Create a TExifWriterUtility object to write the metadata in to the image</span> |
|
151 <a name="l00195"></a>00195 TExifWriterUtility exifWriteUtility(metaData); |
|
152 <a name="l00196"></a>00196 |
|
153 <a name="l00197"></a>00197 HBufC8* buf8ParamWriteVersion = KBuf8ParamWriteVersion().AllocLC(); |
|
154 <a name="l00198"></a>00198 |
|
155 <a name="l00199"></a>00199 User::LeaveIfError(exifWriteUtility.SetImageDescription(buf8ParamWriteVersion)); |
|
156 <a name="l00200"></a>00200 |
|
157 <a name="l00201"></a>00201 CleanupStack::PopAndDestroy(buf8ParamWriteVersion); |
|
158 <a name="l00202"></a>00202 |
|
159 <a name="l00203"></a>00203 |
|
160 <a name="l00204"></a>00204 <span class="comment">// Create a bitmap </span> |
|
161 <a name="l00205"></a>00205 CFbsBitmap* sourceBitmap = <span class="keyword">new</span>(ELeave) CFbsBitmap; |
|
162 <a name="l00206"></a>00206 CleanupStack::PushL(sourceBitmap); |
|
163 <a name="l00207"></a>00207 |
|
164 <a name="l00208"></a>00208 User::LeaveIfError(sourceBitmap->Create(TSize(250,200), EColor16M)); |
|
165 <a name="l00209"></a>00209 User::LeaveIfError(sourceBitmap->Load(aFileName)); |
|
166 <a name="l00210"></a>00210 |
|
167 <a name="l00211"></a>00211 <span class="comment">// See Note 1</span> |
|
168 <a name="l00212"></a>00212 <a class="code" href="class_c_active_listener.html">CActiveListener</a>* activeListener = <a class="code" href="class_c_icl_example.html#6cb9b9dbd3a9e04e6ad4f144e6e2a8d9">CreateAndInitializeActiveListenerLC</a>(); |
|
169 <a name="l00213"></a>00213 |
|
170 <a name="l00214"></a>00214 <span class="comment">// Convert the image</span> |
|
171 <a name="l00215"></a>00215 exifEncoder->Convert(&activeListener->iStatus, *sourceBitmap); |
|
172 <a name="l00216"></a>00216 |
|
173 <a name="l00217"></a>00217 <span class="comment">// See Note 2</span> |
|
174 <a name="l00218"></a>00218 CActiveScheduler::Start(); |
|
175 <a name="l00219"></a>00219 User::LeaveIfError(activeListener->iStatus.Int()); |
|
176 <a name="l00220"></a>00220 |
|
177 <a name="l00221"></a>00221 |
|
178 <a name="l00222"></a>00222 CleanupStack::PopAndDestroy(3); <span class="comment">// encoder, sourceBitmap and activeListener</span> |
|
179 <a name="l00223"></a>00223 |
|
180 <a name="l00224"></a>00224 |
|
181 <a name="l00225"></a>00225 <span class="comment">// We can use the descriptor here</span> |
|
182 <a name="l00226"></a>00226 |
|
183 <a name="l00227"></a>00227 <span class="comment">// And as we took ownership back, we need to push into the cleanup stack to make sure no</span> |
|
184 <a name="l00228"></a>00228 <span class="comment">// memory leaks take place if any leave later</span> |
|
185 <a name="l00229"></a>00229 |
|
186 <a name="l00230"></a>00230 CleanupDeletePushL(encodedImageDescriptor); |
|
187 <a name="l00231"></a>00231 |
|
188 <a name="l00232"></a>00232 |
|
189 <a name="l00233"></a>00233 <span class="comment">// Just verifying the presence of some output.</span> |
|
190 <a name="l00234"></a>00234 |
|
191 <a name="l00235"></a>00235 RFile file; |
|
192 <a name="l00236"></a>00236 |
|
193 <a name="l00237"></a>00237 User::LeaveIfError(file.Replace(iFs, _L(<span class="stringliteral">"c:\\ICLExample\\settingexifdescriptor.mbm"</span>), EFileWrite)); |
|
194 <a name="l00238"></a>00238 CleanupClosePushL(file); |
|
195 <a name="l00239"></a>00239 |
|
196 <a name="l00240"></a>00240 User::LeaveIfError(file.Write(*encodedImageDescriptor)); |
|
197 <a name="l00241"></a>00241 |
|
198 <a name="l00242"></a>00242 CleanupStack::PopAndDestroy(&file); |
|
199 <a name="l00243"></a>00243 |
|
200 <a name="l00244"></a>00244 |
|
201 <a name="l00245"></a>00245 CleanupStack::PopAndDestroy(encodedImageDescriptor); |
|
202 <a name="l00246"></a>00246 } |
|
203 <a name="l00247"></a>00247 |
|
204 <a name="l00248"></a>00248 |
|
205 <a name="l00256"></a><a class="code" href="class_c_icl_example.html#52e7ceb0f0468de45b9b493350db2af4">00256</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#52e7ceb0f0468de45b9b493350db2af4">CIclExample::RotateBitmapL</a>(<span class="keyword">const</span> TDesC& aFileName) |
|
206 <a name="l00257"></a>00257 { |
|
207 <a name="l00258"></a>00258 <span class="comment">// Create a CBitmapRotator object and push it on the cleanup stack </span> |
|
208 <a name="l00259"></a>00259 CBitmapRotator* rotator = CBitmapRotator::NewL(); |
|
209 <a name="l00260"></a>00260 CleanupStack::PushL(rotator); |
|
210 <a name="l00261"></a>00261 |
|
211 <a name="l00262"></a>00262 <span class="comment">// Create a source bitmap </span> |
|
212 <a name="l00263"></a>00263 CFbsBitmap* sourceBitmap = <span class="keyword">new</span>(ELeave) CFbsBitmap; |
|
213 <a name="l00264"></a>00264 CleanupStack::PushL(sourceBitmap); |
|
214 <a name="l00265"></a>00265 |
|
215 <a name="l00266"></a>00266 User::LeaveIfError(sourceBitmap->Create(TSize(15,20), EColor16M)); |
|
216 <a name="l00267"></a>00267 User::LeaveIfError(sourceBitmap->Load(aFileName)); |
|
217 <a name="l00268"></a>00268 |
|
218 <a name="l00269"></a>00269 <span class="comment">// See Note 1</span> |
|
219 <a name="l00270"></a>00270 <a class="code" href="class_c_active_listener.html">CActiveListener</a>* activeListener = <a class="code" href="class_c_icl_example.html#6cb9b9dbd3a9e04e6ad4f144e6e2a8d9">CreateAndInitializeActiveListenerLC</a>(); |
|
220 <a name="l00271"></a>00271 |
|
221 <a name="l00272"></a>00272 <span class="comment">// Rotate the bitmap through the specified angle</span> |
|
222 <a name="l00273"></a>00273 rotator->Rotate(&activeListener->iStatus, *sourceBitmap, CBitmapRotator::ERotation180DegreesClockwise); |
|
223 <a name="l00274"></a>00274 |
|
224 <a name="l00275"></a>00275 <span class="comment">// See Note 2</span> |
|
225 <a name="l00276"></a>00276 CActiveScheduler::Start(); |
|
226 <a name="l00277"></a>00277 User::LeaveIfError(activeListener->iStatus.Int()); |
|
227 <a name="l00278"></a>00278 |
|
228 <a name="l00279"></a>00279 <span class="comment">// Just verifying the presence of some output.</span> |
|
229 <a name="l00280"></a>00280 sourceBitmap->Save(_L(<span class="stringliteral">"c:\\ICLExample\\rotatedbitmap.mbm"</span>)); |
|
230 <a name="l00281"></a>00281 |
|
231 <a name="l00282"></a>00282 |
|
232 <a name="l00283"></a>00283 CleanupStack::PopAndDestroy(3); <span class="comment">// rotator, sourceBitmap and activeListener</span> |
|
233 <a name="l00284"></a>00284 } |
|
234 <a name="l00285"></a>00285 |
|
235 <a name="l00286"></a>00286 |
|
236 <a name="l00295"></a><a class="code" href="class_c_icl_example.html#b5cd4b4ee195f9ff7cc635e559603d0a">00295</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#b5cd4b4ee195f9ff7cc635e559603d0a">CIclExample::ScaleBitmapL</a>(<span class="keyword">const</span> TDesC& aFileName) |
|
237 <a name="l00296"></a>00296 { |
|
238 <a name="l00297"></a>00297 <span class="comment">// Create a source bitmap object and push it on to the cleanup stack</span> |
|
239 <a name="l00298"></a>00298 CFbsBitmap* sourceBitmap = <span class="keyword">new</span>(ELeave) CFbsBitmap; |
|
240 <a name="l00299"></a>00299 CleanupStack::PushL(sourceBitmap); |
|
241 <a name="l00300"></a>00300 |
|
242 <a name="l00301"></a>00301 User::LeaveIfError(sourceBitmap->Create(TSize(100,100), EGray2)); |
|
243 <a name="l00302"></a>00302 User::LeaveIfError(sourceBitmap->Load(aFileName)); |
|
244 <a name="l00303"></a>00303 |
|
245 <a name="l00304"></a>00304 <span class="comment">// Create a destination bitmap object and push it on to the cleanup stack</span> |
|
246 <a name="l00305"></a>00305 CFbsBitmap* destBitmap = <span class="keyword">new</span>(ELeave) CFbsBitmap; |
|
247 <a name="l00306"></a>00306 CleanupStack::PushL(destBitmap); |
|
248 <a name="l00307"></a>00307 |
|
249 <a name="l00308"></a>00308 User::LeaveIfError(destBitmap->Create(TSize(20,30), EColor16M)); |
|
250 <a name="l00309"></a>00309 |
|
251 <a name="l00310"></a>00310 <span class="comment">// Scale the bitmap with old algorithm</span> |
|
252 <a name="l00311"></a>00311 <span class="comment">// Create a CBitmapScaler object and push it on to the cleanup stack</span> |
|
253 <a name="l00312"></a>00312 CBitmapScaler* scaler = CBitmapScaler::NewL(); |
|
254 <a name="l00313"></a>00313 CleanupStack::PushL(scaler); |
|
255 <a name="l00314"></a>00314 |
|
256 <a name="l00315"></a>00315 <span class="comment">// See Note 1</span> |
|
257 <a name="l00316"></a>00316 <a class="code" href="class_c_active_listener.html">CActiveListener</a>* activeListener = <a class="code" href="class_c_icl_example.html#6cb9b9dbd3a9e04e6ad4f144e6e2a8d9">CreateAndInitializeActiveListenerLC</a>(); |
|
258 <a name="l00317"></a>00317 |
|
259 <a name="l00318"></a>00318 <span class="comment">// Scale the bitmap using low memory and medium quality algorithm</span> |
|
260 <a name="l00319"></a>00319 scaler->UseLowMemoryAlgorithm(ETrue); |
|
261 <a name="l00320"></a>00320 scaler->SetQualityAlgorithm(CBitmapScaler::EMediumQuality); |
|
262 <a name="l00321"></a>00321 |
|
263 <a name="l00322"></a>00322 <span class="comment">// Call the scale() function of CBitmapScaler to perform the scaling operation with optional selection of low memory </span> |
|
264 <a name="l00323"></a>00323 scaler->Scale(&activeListener->iStatus, *sourceBitmap, *destBitmap, EFalse); |
|
265 <a name="l00324"></a>00324 |
|
266 <a name="l00325"></a>00325 <span class="comment">// See Note 2</span> |
|
267 <a name="l00326"></a>00326 CActiveScheduler::Start(); |
|
268 <a name="l00327"></a>00327 User::LeaveIfError(activeListener->iStatus.Int());<span class="comment">// scale complete either display the image or report an error.</span> |
|
269 <a name="l00328"></a>00328 |
|
270 <a name="l00329"></a>00329 <span class="comment">// Just verifying the presence of some output. Descriptor can also be used instead</span> |
|
271 <a name="l00330"></a>00330 |
|
272 <a name="l00331"></a>00331 destBitmap->Save(_L(<span class="stringliteral">"c:\\ICLExample\\scaledbitmap.mbm"</span>)); |
|
273 <a name="l00332"></a>00332 |
|
274 <a name="l00333"></a>00333 |
|
275 <a name="l00334"></a>00334 CleanupStack::PopAndDestroy(4); <span class="comment">// activeListener, scaler, destBitmap and sourceBitmap</span> |
|
276 <a name="l00335"></a>00335 } |
|
277 <a name="l00336"></a>00336 |
|
278 <a name="l00337"></a>00337 |
|
279 <a name="l00348"></a><a class="code" href="class_c_icl_example.html#437f4725accedc8e924ee6c897ed0498">00348</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#437f4725accedc8e924ee6c897ed0498">CIclExample::SetSourceDestinationandResizeL</a>(<span class="keyword">const</span> TDesC& aFileName) |
|
280 <a name="l00349"></a>00349 { |
|
281 <a name="l00350"></a>00350 HBufC8* desData = NULL; |
|
282 <a name="l00351"></a>00351 |
|
283 <a name="l00352"></a>00352 <span class="comment">// Create CImageTransform object and push it on to the cleanup stack</span> |
|
284 <a name="l00353"></a>00353 CImageTransform* imageTransform = CImageTransform::NewL(iFs); |
|
285 <a name="l00354"></a>00354 CleanupStack::PushL(imageTransform); |
|
286 <a name="l00355"></a>00355 |
|
287 <a name="l00356"></a>00356 imageTransform->SetSourceFilenameL(aFileName); |
|
288 <a name="l00357"></a>00357 imageTransform->SetDestDataL(desData); |
|
289 <a name="l00358"></a>00358 imageTransform->SetDestSizeInPixelsL(TSize(160, 120), ETrue); |
|
290 <a name="l00359"></a>00359 imageTransform->SetupL(); |
|
291 <a name="l00360"></a>00360 |
|
292 <a name="l00361"></a>00361 <span class="comment">// See Note 1</span> |
|
293 <a name="l00362"></a>00362 <a class="code" href="class_c_active_listener.html">CActiveListener</a>* activeListener = <a class="code" href="class_c_icl_example.html#6cb9b9dbd3a9e04e6ad4f144e6e2a8d9">CreateAndInitializeActiveListenerLC</a>(); |
|
294 <a name="l00363"></a>00363 |
|
295 <a name="l00364"></a>00364 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span> |
|
296 <a name="l00365"></a>00365 imageTransform->Transform(activeListener->iStatus); |
|
297 <a name="l00366"></a>00366 |
|
298 <a name="l00367"></a>00367 <span class="comment">// See Note 2</span> |
|
299 <a name="l00368"></a>00368 CActiveScheduler::Start(); |
|
300 <a name="l00369"></a>00369 <span class="comment">// destData ownership is on CLI side if something goes wrong</span> |
|
301 <a name="l00370"></a>00370 User::LeaveIfError(activeListener->iStatus.Int()); |
|
302 <a name="l00371"></a>00371 |
|
303 <a name="l00372"></a>00372 |
|
304 <a name="l00373"></a>00373 CleanupStack::PopAndDestroy(2); <span class="comment">// imageTransform and activeListener</span> |
|
305 <a name="l00374"></a>00374 |
|
306 <a name="l00375"></a>00375 |
|
307 <a name="l00376"></a>00376 <span class="comment">// We can use the destination data here</span> |
|
308 <a name="l00377"></a>00377 |
|
309 <a name="l00378"></a>00378 <span class="comment">// And as we took ownership back, we need to push into the cleanup stack to make sure no</span> |
|
310 <a name="l00379"></a>00379 <span class="comment">// memory leaks take place if any leave later</span> |
|
311 <a name="l00380"></a>00380 |
|
312 <a name="l00381"></a>00381 CleanupDeletePushL(desData); |
|
313 <a name="l00382"></a>00382 |
|
314 <a name="l00383"></a>00383 |
|
315 <a name="l00384"></a>00384 <span class="comment">// Just verifying the presence of some output.</span> |
|
316 <a name="l00385"></a>00385 |
|
317 <a name="l00386"></a>00386 RFile file; |
|
318 <a name="l00387"></a>00387 |
|
319 <a name="l00388"></a>00388 User::LeaveIfError(file.Replace(iFs, _L(<span class="stringliteral">"c:\\ICLExample\\destdata.mbm"</span>), EFileWrite)); |
|
320 <a name="l00389"></a>00389 CleanupClosePushL(file); |
|
321 <a name="l00390"></a>00390 |
|
322 <a name="l00391"></a>00391 User::LeaveIfError(file.Write(*desData)); |
|
323 <a name="l00392"></a>00392 |
|
324 <a name="l00393"></a>00393 CleanupStack::PopAndDestroy(&file); |
|
325 <a name="l00394"></a>00394 |
|
326 <a name="l00395"></a>00395 |
|
327 <a name="l00396"></a>00396 CleanupStack::PopAndDestroy(desData); |
|
328 <a name="l00397"></a>00397 } |
|
329 <a name="l00398"></a>00398 |
|
330 <a name="l00399"></a>00399 |
|
331 <a name="l00412"></a><a class="code" href="class_c_icl_example.html#cba98bc6b971306f2e568413caae443d">00412</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#cba98bc6b971306f2e568413caae443d">CIclExample::SettingWithUseOfPreserveImageDataL</a>(<span class="keyword">const</span> TDesC& aFileName1,<span class="keyword">const</span> TDesC& aFileName2) |
|
332 <a name="l00413"></a>00413 { |
|
333 <a name="l00414"></a>00414 TPtr8 imageFromFilePtr = LoadImageIntoMemoryLC(aFileName1); |
|
334 <a name="l00415"></a>00415 |
|
335 <a name="l00416"></a>00416 <span class="comment">// Create CImageTransform object and push it on to the cleanup stack</span> |
|
336 <a name="l00417"></a>00417 CImageTransform* imageTransform = CImageTransform::NewL(iFs); |
|
337 <a name="l00418"></a>00418 CleanupStack::PushL(imageTransform); |
|
338 <a name="l00419"></a>00419 |
|
339 <a name="l00420"></a>00420 imageTransform->SetSourceDataL(imageFromFilePtr); |
|
340 <a name="l00421"></a>00421 imageTransform->SetDestFilenameL(aFileName2); |
|
341 <a name="l00422"></a>00422 imageTransform->SetDestSizeInPixelsL(TSize(160, 120), ETrue); |
|
342 <a name="l00423"></a>00423 imageTransform->SetPreserveImageData(ETrue); |
|
343 <a name="l00424"></a>00424 imageTransform->SetupL(); |
|
344 <a name="l00425"></a>00425 |
|
345 <a name="l00426"></a>00426 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span> |
|
346 <a name="l00427"></a>00427 <span class="comment">// See Note 1</span> |
|
347 <a name="l00428"></a>00428 <a class="code" href="class_c_active_listener.html">CActiveListener</a>* activeListener = <a class="code" href="class_c_icl_example.html#6cb9b9dbd3a9e04e6ad4f144e6e2a8d9">CreateAndInitializeActiveListenerLC</a>(); |
|
348 <a name="l00429"></a>00429 |
|
349 <a name="l00430"></a>00430 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span> |
|
350 <a name="l00431"></a>00431 imageTransform->Transform(activeListener->iStatus); |
|
351 <a name="l00432"></a>00432 |
|
352 <a name="l00433"></a>00433 <span class="comment">// See Note 2</span> |
|
353 <a name="l00434"></a>00434 CActiveScheduler::Start(); |
|
354 <a name="l00435"></a>00435 User::LeaveIfError(activeListener->iStatus.Int()); |
|
355 <a name="l00436"></a>00436 |
|
356 <a name="l00437"></a>00437 |
|
357 <a name="l00438"></a>00438 CleanupStack::PopAndDestroy(3); <span class="comment">// activeListener, imageTransform and imageInMemory</span> |
|
358 <a name="l00439"></a>00439 } |
|
359 <a name="l00440"></a>00440 |
|
360 <a name="l00441"></a>00441 |
|
361 <a name="l00452"></a><a class="code" href="class_c_icl_example.html#13e9de7f38143107e3ddf23808a822c3">00452</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#13e9de7f38143107e3ddf23808a822c3">CIclExample::AddThumbnailToJpegFileL</a>(<span class="keyword">const</span> TDesC& aSrcFileName, <span class="keyword">const</span> TDesC& aDesFileName) |
|
362 <a name="l00453"></a>00453 { |
|
363 <a name="l00454"></a>00454 <span class="comment">// Create a CImageTransform object and push it on to the cleanup stack</span> |
|
364 <a name="l00455"></a>00455 CImageTransform* imageTransform = NULL; |
|
365 <a name="l00456"></a>00456 |
|
366 <a name="l00457"></a>00457 imageTransform = CImageTransform::NewL(iFs); |
|
367 <a name="l00458"></a>00458 CleanupStack::PushL(imageTransform); |
|
368 <a name="l00459"></a>00459 |
|
369 <a name="l00460"></a>00460 imageTransform->SetSourceFilenameL(aSrcFileName); |
|
370 <a name="l00461"></a>00461 imageTransform->SetDestFilenameL(aDesFileName); |
|
371 <a name="l00462"></a>00462 imageTransform->SetDestSizeInPixelsL(TSize(160, 120), ETrue); |
|
372 <a name="l00463"></a>00463 imageTransform->SetOptionsL(CImageTransform::EThumbnail); |
|
373 <a name="l00464"></a>00464 imageTransform->SetupL(); |
|
374 <a name="l00465"></a>00465 |
|
375 <a name="l00466"></a>00466 <span class="comment">// encode the image to add thumbnail</span> |
|
376 <a name="l00467"></a>00467 <span class="comment">// See Note 1</span> |
|
377 <a name="l00468"></a>00468 <a class="code" href="class_c_active_listener.html">CActiveListener</a>* activeListener = <a class="code" href="class_c_icl_example.html#6cb9b9dbd3a9e04e6ad4f144e6e2a8d9">CreateAndInitializeActiveListenerLC</a>(); |
|
378 <a name="l00469"></a>00469 |
|
379 <a name="l00470"></a>00470 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span> |
|
380 <a name="l00471"></a>00471 imageTransform->Transform(activeListener->iStatus); |
|
381 <a name="l00472"></a>00472 |
|
382 <a name="l00473"></a>00473 <span class="comment">// See Note 2</span> |
|
383 <a name="l00474"></a>00474 CActiveScheduler::Start(); |
|
384 <a name="l00475"></a>00475 User::LeaveIfError(activeListener->iStatus.Int()); |
|
385 <a name="l00476"></a>00476 |
|
386 <a name="l00477"></a>00477 |
|
387 <a name="l00478"></a>00478 CleanupStack::PopAndDestroy(2); <span class="comment">// activeListener and imageTransform</span> |
|
388 <a name="l00479"></a>00479 } |
|
389 <a name="l00480"></a>00480 |
|
390 <a name="l00481"></a>00481 |
|
391 <a name="l00493"></a><a class="code" href="class_c_icl_example.html#fc6a5f0e8468d977d0b1d11001c773b7">00493</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#fc6a5f0e8468d977d0b1d11001c773b7">CIclExample::AddExifDataToJpegFileL</a>(<span class="keyword">const</span> TDesC& aFileName) |
|
392 <a name="l00494"></a>00494 { |
|
393 <a name="l00495"></a>00495 HBufC8* encodedImageDescriptor = NULL; |
|
394 <a name="l00496"></a>00496 |
|
395 <a name="l00497"></a>00497 <span class="comment">// Create the encoder, passing a buffer to store the encoded image</span> |
|
396 <a name="l00498"></a>00498 CJPEGExifEncoder* exifEncoder = <span class="keyword">static_cast<</span>CJPEGExifEncoder*<span class="keyword">></span>(CImageEncoder::DataNewL(encodedImageDescriptor, CImageEncoder::EOptionNone, KImageTypeJPGUid)); |
|
397 <a name="l00499"></a>00499 CleanupStack::PushL(exifEncoder); |
|
398 <a name="l00500"></a>00500 |
|
399 <a name="l00501"></a>00501 <span class="comment">// Create a MExifMetadata object and initializes to metadata associated with CJPEGexifEncoder </span> |
|
400 <a name="l00502"></a>00502 MExifMetadataWriter* metaData = exifEncoder->ExifMetadata(); |
|
401 <a name="l00503"></a>00503 |
|
402 <a name="l00504"></a>00504 <span class="comment">// Create a TExifWriterUtility object to write the metadata in to the image</span> |
|
403 <a name="l00505"></a>00505 TExifWriterUtility exifWriteUtility(metaData); |
|
404 <a name="l00506"></a>00506 |
|
405 <a name="l00507"></a>00507 HBufC8* buf8ParamWriteVersion = KBuf8ParamWriteVersion().AllocLC(); |
|
406 <a name="l00508"></a>00508 |
|
407 <a name="l00509"></a>00509 User::LeaveIfError(exifWriteUtility.SetImageDescription(buf8ParamWriteVersion)); |
|
408 <a name="l00510"></a>00510 |
|
409 <a name="l00511"></a>00511 CleanupStack::PopAndDestroy(buf8ParamWriteVersion); |
|
410 <a name="l00512"></a>00512 |
|
411 <a name="l00513"></a>00513 |
|
412 <a name="l00514"></a>00514 <span class="comment">// Create a CFbsBitmap to store the source bitmap to encode</span> |
|
413 <a name="l00515"></a>00515 CFbsBitmap* sourceBitmap = <span class="keyword">new</span>(ELeave) CFbsBitmap; |
|
414 <a name="l00516"></a>00516 CleanupStack::PushL(sourceBitmap); |
|
415 <a name="l00517"></a>00517 |
|
416 <a name="l00518"></a>00518 User::LeaveIfError(sourceBitmap->Create(TSize(20,30), EColor16M)); |
|
417 <a name="l00519"></a>00519 User::LeaveIfError(sourceBitmap->Load(aFileName)); |
|
418 <a name="l00520"></a>00520 |
|
419 <a name="l00521"></a>00521 <span class="comment">// Create CFrameImageData object and push it on the cleanup stack </span> |
|
420 <a name="l00522"></a>00522 CFrameImageData* frameImageData = CFrameImageData::NewL(); |
|
421 <a name="l00523"></a>00523 CleanupStack::PushL(frameImageData); |
|
422 <a name="l00524"></a>00524 |
|
423 <a name="l00525"></a>00525 <span class="comment">// See Note 1</span> |
|
424 <a name="l00526"></a>00526 <a class="code" href="class_c_active_listener.html">CActiveListener</a>* activeListener = <a class="code" href="class_c_icl_example.html#6cb9b9dbd3a9e04e6ad4f144e6e2a8d9">CreateAndInitializeActiveListenerLC</a>(); |
|
425 <a name="l00527"></a>00527 |
|
426 <a name="l00528"></a>00528 <span class="comment">// Convert the image</span> |
|
427 <a name="l00529"></a>00529 exifEncoder->Convert(&activeListener->iStatus, *sourceBitmap, frameImageData); |
|
428 <a name="l00530"></a>00530 |
|
429 <a name="l00531"></a>00531 <span class="comment">// See Note 2</span> |
|
430 <a name="l00532"></a>00532 CActiveScheduler::Start(); |
|
431 <a name="l00533"></a>00533 User::LeaveIfError(activeListener->iStatus.Int()); <span class="comment">// encode complete either display the image or report an error.</span> |
|
432 <a name="l00534"></a>00534 |
|
433 <a name="l00535"></a>00535 |
|
434 <a name="l00536"></a>00536 <span class="comment">// Just verifying the presence of some output.</span> |
|
435 <a name="l00537"></a>00537 sourceBitmap->Save(_L(<span class="stringliteral">"c:\\ICLExample\\addexifbitmap.mbm"</span>)); |
|
436 <a name="l00538"></a>00538 |
|
437 <a name="l00539"></a>00539 |
|
438 <a name="l00540"></a>00540 CleanupStack::PopAndDestroy(4); <span class="comment">// activeListener, frameImageData, sourceBitmap and exifEncoder</span> |
|
439 <a name="l00541"></a>00541 |
|
440 <a name="l00542"></a>00542 |
|
441 <a name="l00543"></a>00543 <span class="comment">// We can use the descriptor here</span> |
|
442 <a name="l00544"></a>00544 |
|
443 <a name="l00545"></a>00545 <span class="comment">// And as we took ownership back, we need to push into the cleanup stack to make sure no</span> |
|
444 <a name="l00546"></a>00546 <span class="comment">// memory leaks take place if any leave later</span> |
|
445 <a name="l00547"></a>00547 |
|
446 <a name="l00548"></a>00548 CleanupDeletePushL(encodedImageDescriptor); |
|
447 <a name="l00549"></a>00549 |
|
448 <a name="l00550"></a>00550 |
|
449 <a name="l00551"></a>00551 <span class="comment">// Just verifying the presence of some output.</span> |
|
450 <a name="l00552"></a>00552 |
|
451 <a name="l00553"></a>00553 RFile file; |
|
452 <a name="l00554"></a>00554 |
|
453 <a name="l00555"></a>00555 User::LeaveIfError(file.Replace(iFs, _L(<span class="stringliteral">"c:\\ICLExample\\addexifdescriptor.mbm"</span>), EFileWrite)); |
|
454 <a name="l00556"></a>00556 CleanupClosePushL(file); |
|
455 <a name="l00557"></a>00557 |
|
456 <a name="l00558"></a>00558 User::LeaveIfError(file.Write(*encodedImageDescriptor)); |
|
457 <a name="l00559"></a>00559 |
|
458 <a name="l00560"></a>00560 CleanupStack::PopAndDestroy(&file); |
|
459 <a name="l00561"></a>00561 |
|
460 <a name="l00562"></a>00562 |
|
461 <a name="l00563"></a>00563 CleanupStack::PopAndDestroy(encodedImageDescriptor); |
|
462 <a name="l00564"></a>00564 } |
|
463 <a name="l00565"></a>00565 |
|
464 <a name="l00566"></a>00566 |
|
465 <a name="l00578"></a><a class="code" href="class_c_icl_example.html#5f453ea5f17eeeadbf0558774c9947f4">00578</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#5f453ea5f17eeeadbf0558774c9947f4">CIclExample::EncodeBitmapToFileUsingOperationExtensionL</a>(<span class="keyword">const</span> TDesC& aSrcFileName, <span class="keyword">const</span> TDesC& aDestFileName) |
|
466 <a name="l00579"></a>00579 { |
|
467 <a name="l00580"></a>00580 <span class="comment">// Create the encoder, passing the filename. </span> |
|
468 <a name="l00581"></a>00581 <span class="comment">// If the image is not recognised or valid then the call will leave with an error </span> |
|
469 <a name="l00582"></a>00582 CImageEncoder* jpegImageEncoder = CImageEncoder::FileNewL(iFs, aDestFileName, CImageEncoder::EOptionNone, KImageTypeJPGUid); |
|
470 <a name="l00583"></a>00583 CleanupStack::PushL(jpegImageEncoder); |
|
471 <a name="l00584"></a>00584 |
|
472 <a name="l00585"></a>00585 <span class="comment">// Create a CFbsBitmap to store the source bitmap to encode</span> |
|
473 <a name="l00586"></a>00586 CFbsBitmap* sourceBitmap = <span class="keyword">new</span>(ELeave) CFbsBitmap; |
|
474 <a name="l00587"></a>00587 CleanupStack::PushL(sourceBitmap); |
|
475 <a name="l00588"></a>00588 |
|
476 <a name="l00589"></a>00589 User::LeaveIfError(sourceBitmap->Load(aSrcFileName)); |
|
477 <a name="l00590"></a>00590 |
|
478 <a name="l00591"></a>00591 <span class="comment">// Create operation extension</span> |
|
479 <a name="l00592"></a>00592 TImageConvOperation* operation = jpegImageEncoder->OperationL(); |
|
480 <a name="l00593"></a>00593 |
|
481 <a name="l00594"></a>00594 <span class="comment">// Add Rotate 90degrees operation</span> |
|
482 <a name="l00595"></a>00595 operation->AddOperationL(TImageConvOperation::ERotation90DegreesClockwise); |
|
483 <a name="l00596"></a>00596 <span class="comment">// NOTE: Multiple operations can be added</span> |
|
484 <a name="l00597"></a>00597 |
|
485 <a name="l00598"></a>00598 <span class="comment">// See Note 1</span> |
|
486 <a name="l00599"></a>00599 <a class="code" href="class_c_active_listener.html">CActiveListener</a>* activeListener = <a class="code" href="class_c_icl_example.html#6cb9b9dbd3a9e04e6ad4f144e6e2a8d9">CreateAndInitializeActiveListenerLC</a>(); |
|
487 <a name="l00600"></a>00600 |
|
488 <a name="l00601"></a>00601 <span class="comment">// Convert the image</span> |
|
489 <a name="l00602"></a>00602 jpegImageEncoder->Convert(&activeListener->iStatus, *sourceBitmap, NULL); |
|
490 <a name="l00603"></a>00603 |
|
491 <a name="l00604"></a>00604 <span class="comment">// See Note 2</span> |
|
492 <a name="l00605"></a>00605 CActiveScheduler::Start(); |
|
493 <a name="l00606"></a>00606 User::LeaveIfError(activeListener->iStatus.Int());<span class="comment">// encode complete either display the image or report an error.</span> |
|
494 <a name="l00607"></a>00607 |
|
495 <a name="l00608"></a>00608 CleanupStack::PopAndDestroy(3, jpegImageEncoder); <span class="comment">// jpegImageEncoder, sourceBitmap and activeListener</span> |
|
496 <a name="l00609"></a>00609 } |
|
497 </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Thu Jan 21 10:32:59 2010 for TB10.1 Example Applications by |
|
498 <a href="http://www.doxygen.org/index.html"> |
|
499 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address> |
|
500 </body> |
|
501 </html> |