Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/iclencodeexample_8cpp-source.html
Week 12 contribution of SDK documentation_content. See release notes for details. Fixes Bug 1892, Bug 1522, Bug 1520, Bug 394, Bug 1319, Bug 344, Bug 1897
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>TB10.1 Example Applications: examples/Multimedia/ICL/ICLExample/iclencodeexample.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<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>
<a name="l00002"></a>00002 <span class="comment">// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).</span>
<a name="l00003"></a>00003 <span class="comment">// All rights reserved.</span>
<a name="l00004"></a>00004 <span class="comment">// This component and the accompanying materials are made available</span>
<a name="l00005"></a>00005 <span class="comment">// under the terms of "Eclipse Public License v1.0"</span>
<a name="l00006"></a>00006 <span class="comment">// which accompanies this distribution, and is available</span>
<a name="l00007"></a>00007 <span class="comment">// at the URL "http://www.eclipse.org/legal/epl-v10.html".</span>
<a name="l00008"></a>00008 <span class="comment">//</span>
<a name="l00009"></a>00009 <span class="comment">// Initial Contributors:</span>
<a name="l00010"></a>00010 <span class="comment">// Nokia Corporation - initial contribution.</span>
<a name="l00011"></a>00011 <span class="comment">//</span>
<a name="l00012"></a>00012 <span class="comment">// Contributors:</span>
<a name="l00013"></a>00013 <span class="comment">//</span>
<a name="l00014"></a>00014 <span class="comment">// Description:</span>
<a name="l00015"></a>00015 <span class="comment">// </span>
<a name="l00016"></a>00016 <span class="comment">//</span>
<a name="l00017"></a>00017
<a name="l00018"></a>00018
<a name="l00039"></a>00039 <span class="preprocessor">#include "<a class="code" href="iclexample_8h.html">iclexample.h</a>"</span>
<a name="l00040"></a>00040 <span class="preprocessor">#include <gifscaler.h></span>
<a name="l00041"></a>00041 <span class="preprocessor">#include <imagetransform.h></span>
<a name="l00042"></a>00042
<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)
<a name="l00054"></a>00054 {
<a name="l00055"></a>00055 HBufC8* encodedImageDescriptor = NULL;
<a name="l00056"></a>00056
<a name="l00057"></a>00057 <span class="comment">// Create the encoder, passing a buffer to store the encoded image</span>
<a name="l00058"></a>00058 CImageEncoder* encoder = CImageEncoder::DataNewL(encodedImageDescriptor, CImageEncoder::EOptionNone,KImageTypeGIFUid);
<a name="l00059"></a>00059 CleanupStack::PushL(encoder);
<a name="l00060"></a>00060
<a name="l00061"></a>00061 <span class="comment">// Create a CFbsBitmap to store the source bitmap to encode</span>
<a name="l00062"></a>00062 CFbsBitmap* sourceBitmap = <span class="keyword">new</span>(ELeave) CFbsBitmap;
<a name="l00063"></a>00063 CleanupStack::PushL(sourceBitmap);
<a name="l00064"></a>00064
<a name="l00065"></a>00065 User::LeaveIfError(sourceBitmap->Create(TSize(20,30), EColor16M));
<a name="l00066"></a>00066 User::LeaveIfError(sourceBitmap->Load(aFileName));
<a name="l00067"></a>00067
<a name="l00068"></a>00068 <span class="comment">// See Note 1</span>
<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>();
<a name="l00070"></a>00070
<a name="l00071"></a>00071 <span class="comment">// Convert the image</span>
<a name="l00072"></a>00072 encoder->Convert(&activeListener->iStatus, *sourceBitmap);
<a name="l00073"></a>00073
<a name="l00074"></a>00074 <span class="comment">// See Note 2</span>
<a name="l00075"></a>00075 CActiveScheduler::Start();
<a name="l00076"></a>00076 User::LeaveIfError(activeListener->iStatus.Int());<span class="comment">// encode complete either display the image or report an error.</span>
<a name="l00077"></a>00077
<a name="l00078"></a>00078
<a name="l00079"></a>00079 CleanupStack::PopAndDestroy(3); <span class="comment">// encoder, sourceBitmap and activeListener</span>
<a name="l00080"></a>00080
<a name="l00081"></a>00081
<a name="l00082"></a>00082 <span class="comment">// We can use the descriptor here</span>
<a name="l00083"></a>00083
<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>
<a name="l00085"></a>00085 <span class="comment">// memory leaks take place if any leave later</span>
<a name="l00086"></a>00086
<a name="l00087"></a>00087 CleanupDeletePushL(encodedImageDescriptor);
<a name="l00088"></a>00088
<a name="l00089"></a>00089
<a name="l00090"></a>00090 <span class="comment">// Just verifying the presence of some output. </span>
<a name="l00091"></a>00091
<a name="l00092"></a>00092 RFile file;
<a name="l00093"></a>00093
<a name="l00094"></a>00094 User::LeaveIfError(file.Replace(iFs, _L(<span class="stringliteral">"c:\\ICLExample\\encodeddescriptor.mbm"</span>), EFileWrite));
<a name="l00095"></a>00095 CleanupClosePushL(file);
<a name="l00096"></a>00096
<a name="l00097"></a>00097 User::LeaveIfError(file.Write(*encodedImageDescriptor));
<a name="l00098"></a>00098
<a name="l00099"></a>00099 CleanupStack::PopAndDestroy(&file);
<a name="l00100"></a>00100
<a name="l00101"></a>00101
<a name="l00102"></a>00102 CleanupStack::PopAndDestroy(encodedImageDescriptor);
<a name="l00103"></a>00103 }
<a name="l00104"></a>00104
<a name="l00105"></a>00105
<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)
<a name="l00117"></a>00117 {
<a name="l00118"></a>00118 HBufC8* encodedImageDescriptor = NULL;
<a name="l00119"></a>00119
<a name="l00120"></a>00120 <span class="comment">// Create the encoder, passing a buffer to store the encoded image</span>
<a name="l00121"></a>00121 CImageEncoder* encoder = CImageEncoder::DataNewL(encodedImageDescriptor, CImageEncoder::EOptionNone, KImageTypeJPGUid);
<a name="l00122"></a>00122 CleanupStack::PushL(encoder);
<a name="l00123"></a>00123
<a name="l00124"></a>00124 <span class="comment">// Set the image type to thumbnail </span>
<a name="l00125"></a>00125 encoder->SetThumbnail(ETrue);
<a name="l00126"></a>00126
<a name="l00127"></a>00127 <span class="comment">// Create a bitmap to access the thumbnail</span>
<a name="l00128"></a>00128 CFbsBitmap* sourceBitmap = <span class="keyword">new</span>(ELeave) CFbsBitmap;
<a name="l00129"></a>00129 CleanupStack::PushL(sourceBitmap);
<a name="l00130"></a>00130
<a name="l00131"></a>00131 User::LeaveIfError(sourceBitmap->Create(TSize(250,200), EColor16M));
<a name="l00132"></a>00132 User::LeaveIfError(sourceBitmap->Load(aFileName));
<a name="l00133"></a>00133
<a name="l00134"></a>00134 <span class="comment">// See Note 1</span>
<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>();
<a name="l00136"></a>00136
<a name="l00137"></a>00137 <span class="comment">// Convert the image</span>
<a name="l00138"></a>00138 encoder->Convert(&activeListener->iStatus, *sourceBitmap);
<a name="l00139"></a>00139
<a name="l00140"></a>00140 <span class="comment">// See Note 2</span>
<a name="l00141"></a>00141 CActiveScheduler::Start();
<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>
<a name="l00143"></a>00143
<a name="l00144"></a>00144
<a name="l00145"></a>00145 CleanupStack::PopAndDestroy(3); <span class="comment">// encoder, sourceBitmap and activeListener</span>
<a name="l00146"></a>00146
<a name="l00147"></a>00147
<a name="l00148"></a>00148 <span class="comment">// We can use the descriptor here</span>
<a name="l00149"></a>00149
<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>
<a name="l00151"></a>00151 <span class="comment">// memory leaks take place if any leave later</span>
<a name="l00152"></a>00152
<a name="l00153"></a>00153 CleanupDeletePushL(encodedImageDescriptor);
<a name="l00154"></a>00154
<a name="l00155"></a>00155
<a name="l00156"></a>00156 <span class="comment">// Just verifying the presence of some output.</span>
<a name="l00157"></a>00157
<a name="l00158"></a>00158 RFile file;
<a name="l00159"></a>00159
<a name="l00160"></a>00160 User::LeaveIfError(file.Replace(iFs, _L(<span class="stringliteral">"c:\\ICLExample\\encodedbitmapwiththumbnail.mbm"</span>), EFileWrite));
<a name="l00161"></a>00161 CleanupClosePushL(file);
<a name="l00162"></a>00162
<a name="l00163"></a>00163 User::LeaveIfError(file.Write(*encodedImageDescriptor));
<a name="l00164"></a>00164
<a name="l00165"></a>00165 CleanupStack::PopAndDestroy(&file);
<a name="l00166"></a>00166
<a name="l00167"></a>00167
<a name="l00168"></a>00168 CleanupStack::PopAndDestroy(encodedImageDescriptor);
<a name="l00169"></a>00169 }
<a name="l00170"></a>00170
<a name="l00171"></a>00171
<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)
<a name="l00184"></a>00184 {
<a name="l00185"></a>00185 HBufC8* encodedImageDescriptor = NULL;
<a name="l00186"></a>00186
<a name="l00187"></a>00187 <span class="comment">// Create the encoder, passing a buffer to store the encoded image</span>
<a name="l00188"></a>00188 CJPEGExifEncoder* exifEncoder = <span class="keyword">static_cast<</span>CJPEGExifEncoder*<span class="keyword">></span>(CImageEncoder::DataNewL(encodedImageDescriptor, CImageEncoder::EOptionNone, KImageTypeJPGUid));
<a name="l00189"></a>00189 CleanupStack::PushL(exifEncoder);
<a name="l00190"></a>00190
<a name="l00191"></a>00191 <span class="comment">// Create a MExifMetadata object and initialize it with the metadata associated with CJPEGexifEncoder </span>
<a name="l00192"></a>00192 MExifMetadataWriter* metaData = exifEncoder->ExifMetadata();
<a name="l00193"></a>00193
<a name="l00194"></a>00194 <span class="comment">// Create a TExifWriterUtility object to write the metadata in to the image</span>
<a name="l00195"></a>00195 TExifWriterUtility exifWriteUtility(metaData);
<a name="l00196"></a>00196
<a name="l00197"></a>00197 HBufC8* buf8ParamWriteVersion = KBuf8ParamWriteVersion().AllocLC();
<a name="l00198"></a>00198
<a name="l00199"></a>00199 User::LeaveIfError(exifWriteUtility.SetImageDescription(buf8ParamWriteVersion));
<a name="l00200"></a>00200
<a name="l00201"></a>00201 CleanupStack::PopAndDestroy(buf8ParamWriteVersion);
<a name="l00202"></a>00202
<a name="l00203"></a>00203
<a name="l00204"></a>00204 <span class="comment">// Create a bitmap </span>
<a name="l00205"></a>00205 CFbsBitmap* sourceBitmap = <span class="keyword">new</span>(ELeave) CFbsBitmap;
<a name="l00206"></a>00206 CleanupStack::PushL(sourceBitmap);
<a name="l00207"></a>00207
<a name="l00208"></a>00208 User::LeaveIfError(sourceBitmap->Create(TSize(250,200), EColor16M));
<a name="l00209"></a>00209 User::LeaveIfError(sourceBitmap->Load(aFileName));
<a name="l00210"></a>00210
<a name="l00211"></a>00211 <span class="comment">// See Note 1</span>
<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>();
<a name="l00213"></a>00213
<a name="l00214"></a>00214 <span class="comment">// Convert the image</span>
<a name="l00215"></a>00215 exifEncoder->Convert(&activeListener->iStatus, *sourceBitmap);
<a name="l00216"></a>00216
<a name="l00217"></a>00217 <span class="comment">// See Note 2</span>
<a name="l00218"></a>00218 CActiveScheduler::Start();
<a name="l00219"></a>00219 User::LeaveIfError(activeListener->iStatus.Int());
<a name="l00220"></a>00220
<a name="l00221"></a>00221
<a name="l00222"></a>00222 CleanupStack::PopAndDestroy(3); <span class="comment">// encoder, sourceBitmap and activeListener</span>
<a name="l00223"></a>00223
<a name="l00224"></a>00224
<a name="l00225"></a>00225 <span class="comment">// We can use the descriptor here</span>
<a name="l00226"></a>00226
<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>
<a name="l00228"></a>00228 <span class="comment">// memory leaks take place if any leave later</span>
<a name="l00229"></a>00229
<a name="l00230"></a>00230 CleanupDeletePushL(encodedImageDescriptor);
<a name="l00231"></a>00231
<a name="l00232"></a>00232
<a name="l00233"></a>00233 <span class="comment">// Just verifying the presence of some output.</span>
<a name="l00234"></a>00234
<a name="l00235"></a>00235 RFile file;
<a name="l00236"></a>00236
<a name="l00237"></a>00237 User::LeaveIfError(file.Replace(iFs, _L(<span class="stringliteral">"c:\\ICLExample\\settingexifdescriptor.mbm"</span>), EFileWrite));
<a name="l00238"></a>00238 CleanupClosePushL(file);
<a name="l00239"></a>00239
<a name="l00240"></a>00240 User::LeaveIfError(file.Write(*encodedImageDescriptor));
<a name="l00241"></a>00241
<a name="l00242"></a>00242 CleanupStack::PopAndDestroy(&file);
<a name="l00243"></a>00243
<a name="l00244"></a>00244
<a name="l00245"></a>00245 CleanupStack::PopAndDestroy(encodedImageDescriptor);
<a name="l00246"></a>00246 }
<a name="l00247"></a>00247
<a name="l00248"></a>00248
<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)
<a name="l00257"></a>00257 {
<a name="l00258"></a>00258 <span class="comment">// Create a CBitmapRotator object and push it on the cleanup stack </span>
<a name="l00259"></a>00259 CBitmapRotator* rotator = CBitmapRotator::NewL();
<a name="l00260"></a>00260 CleanupStack::PushL(rotator);
<a name="l00261"></a>00261
<a name="l00262"></a>00262 <span class="comment">// Create a source bitmap </span>
<a name="l00263"></a>00263 CFbsBitmap* sourceBitmap = <span class="keyword">new</span>(ELeave) CFbsBitmap;
<a name="l00264"></a>00264 CleanupStack::PushL(sourceBitmap);
<a name="l00265"></a>00265
<a name="l00266"></a>00266 User::LeaveIfError(sourceBitmap->Create(TSize(15,20), EColor16M));
<a name="l00267"></a>00267 User::LeaveIfError(sourceBitmap->Load(aFileName));
<a name="l00268"></a>00268
<a name="l00269"></a>00269 <span class="comment">// See Note 1</span>
<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>();
<a name="l00271"></a>00271
<a name="l00272"></a>00272 <span class="comment">// Rotate the bitmap through the specified angle</span>
<a name="l00273"></a>00273 rotator->Rotate(&activeListener->iStatus, *sourceBitmap, CBitmapRotator::ERotation180DegreesClockwise);
<a name="l00274"></a>00274
<a name="l00275"></a>00275 <span class="comment">// See Note 2</span>
<a name="l00276"></a>00276 CActiveScheduler::Start();
<a name="l00277"></a>00277 User::LeaveIfError(activeListener->iStatus.Int());
<a name="l00278"></a>00278
<a name="l00279"></a>00279 <span class="comment">// Just verifying the presence of some output.</span>
<a name="l00280"></a>00280 sourceBitmap->Save(_L(<span class="stringliteral">"c:\\ICLExample\\rotatedbitmap.mbm"</span>));
<a name="l00281"></a>00281
<a name="l00282"></a>00282
<a name="l00283"></a>00283 CleanupStack::PopAndDestroy(3); <span class="comment">// rotator, sourceBitmap and activeListener</span>
<a name="l00284"></a>00284 }
<a name="l00285"></a>00285
<a name="l00286"></a>00286
<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)
<a name="l00296"></a>00296 {
<a name="l00297"></a>00297 <span class="comment">// Create a source bitmap object and push it on to the cleanup stack</span>
<a name="l00298"></a>00298 CFbsBitmap* sourceBitmap = <span class="keyword">new</span>(ELeave) CFbsBitmap;
<a name="l00299"></a>00299 CleanupStack::PushL(sourceBitmap);
<a name="l00300"></a>00300
<a name="l00301"></a>00301 User::LeaveIfError(sourceBitmap->Create(TSize(100,100), EGray2));
<a name="l00302"></a>00302 User::LeaveIfError(sourceBitmap->Load(aFileName));
<a name="l00303"></a>00303
<a name="l00304"></a>00304 <span class="comment">// Create a destination bitmap object and push it on to the cleanup stack</span>
<a name="l00305"></a>00305 CFbsBitmap* destBitmap = <span class="keyword">new</span>(ELeave) CFbsBitmap;
<a name="l00306"></a>00306 CleanupStack::PushL(destBitmap);
<a name="l00307"></a>00307
<a name="l00308"></a>00308 User::LeaveIfError(destBitmap->Create(TSize(20,30), EColor16M));
<a name="l00309"></a>00309
<a name="l00310"></a>00310 <span class="comment">// Scale the bitmap with old algorithm</span>
<a name="l00311"></a>00311 <span class="comment">// Create a CBitmapScaler object and push it on to the cleanup stack</span>
<a name="l00312"></a>00312 CBitmapScaler* scaler = CBitmapScaler::NewL();
<a name="l00313"></a>00313 CleanupStack::PushL(scaler);
<a name="l00314"></a>00314
<a name="l00315"></a>00315 <span class="comment">// See Note 1</span>
<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>();
<a name="l00317"></a>00317
<a name="l00318"></a>00318 <span class="comment">// Scale the bitmap using low memory and medium quality algorithm</span>
<a name="l00319"></a>00319 scaler->UseLowMemoryAlgorithm(ETrue);
<a name="l00320"></a>00320 scaler->SetQualityAlgorithm(CBitmapScaler::EMediumQuality);
<a name="l00321"></a>00321
<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>
<a name="l00323"></a>00323 scaler->Scale(&activeListener->iStatus, *sourceBitmap, *destBitmap, EFalse);
<a name="l00324"></a>00324
<a name="l00325"></a>00325 <span class="comment">// See Note 2</span>
<a name="l00326"></a>00326 CActiveScheduler::Start();
<a name="l00327"></a>00327 User::LeaveIfError(activeListener->iStatus.Int());<span class="comment">// scale complete either display the image or report an error.</span>
<a name="l00328"></a>00328
<a name="l00329"></a>00329 <span class="comment">// Just verifying the presence of some output. Descriptor can also be used instead</span>
<a name="l00330"></a>00330
<a name="l00331"></a>00331 destBitmap->Save(_L(<span class="stringliteral">"c:\\ICLExample\\scaledbitmap.mbm"</span>));
<a name="l00332"></a>00332
<a name="l00333"></a>00333
<a name="l00334"></a>00334 CleanupStack::PopAndDestroy(4); <span class="comment">// activeListener, scaler, destBitmap and sourceBitmap</span>
<a name="l00335"></a>00335 }
<a name="l00336"></a>00336
<a name="l00337"></a>00337
<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)
<a name="l00349"></a>00349 {
<a name="l00350"></a>00350 HBufC8* desData = NULL;
<a name="l00351"></a>00351
<a name="l00352"></a>00352 <span class="comment">// Create CImageTransform object and push it on to the cleanup stack</span>
<a name="l00353"></a>00353 CImageTransform* imageTransform = CImageTransform::NewL(iFs);
<a name="l00354"></a>00354 CleanupStack::PushL(imageTransform);
<a name="l00355"></a>00355
<a name="l00356"></a>00356 imageTransform->SetSourceFilenameL(aFileName);
<a name="l00357"></a>00357 imageTransform->SetDestDataL(desData);
<a name="l00358"></a>00358 imageTransform->SetDestSizeInPixelsL(TSize(160, 120), ETrue);
<a name="l00359"></a>00359 imageTransform->SetupL();
<a name="l00360"></a>00360
<a name="l00361"></a>00361 <span class="comment">// See Note 1</span>
<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>();
<a name="l00363"></a>00363
<a name="l00364"></a>00364 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span>
<a name="l00365"></a>00365 imageTransform->Transform(activeListener->iStatus);
<a name="l00366"></a>00366
<a name="l00367"></a>00367 <span class="comment">// See Note 2</span>
<a name="l00368"></a>00368 CActiveScheduler::Start();
<a name="l00369"></a>00369 <span class="comment">// destData ownership is on CLI side if something goes wrong</span>
<a name="l00370"></a>00370 User::LeaveIfError(activeListener->iStatus.Int());
<a name="l00371"></a>00371
<a name="l00372"></a>00372
<a name="l00373"></a>00373 CleanupStack::PopAndDestroy(2); <span class="comment">// imageTransform and activeListener</span>
<a name="l00374"></a>00374
<a name="l00375"></a>00375
<a name="l00376"></a>00376 <span class="comment">// We can use the destination data here</span>
<a name="l00377"></a>00377
<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>
<a name="l00379"></a>00379 <span class="comment">// memory leaks take place if any leave later</span>
<a name="l00380"></a>00380
<a name="l00381"></a>00381 CleanupDeletePushL(desData);
<a name="l00382"></a>00382
<a name="l00383"></a>00383
<a name="l00384"></a>00384 <span class="comment">// Just verifying the presence of some output.</span>
<a name="l00385"></a>00385
<a name="l00386"></a>00386 RFile file;
<a name="l00387"></a>00387
<a name="l00388"></a>00388 User::LeaveIfError(file.Replace(iFs, _L(<span class="stringliteral">"c:\\ICLExample\\destdata.mbm"</span>), EFileWrite));
<a name="l00389"></a>00389 CleanupClosePushL(file);
<a name="l00390"></a>00390
<a name="l00391"></a>00391 User::LeaveIfError(file.Write(*desData));
<a name="l00392"></a>00392
<a name="l00393"></a>00393 CleanupStack::PopAndDestroy(&file);
<a name="l00394"></a>00394
<a name="l00395"></a>00395
<a name="l00396"></a>00396 CleanupStack::PopAndDestroy(desData);
<a name="l00397"></a>00397 }
<a name="l00398"></a>00398
<a name="l00399"></a>00399
<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)
<a name="l00413"></a>00413 {
<a name="l00414"></a>00414 TPtr8 imageFromFilePtr = LoadImageIntoMemoryLC(aFileName1);
<a name="l00415"></a>00415
<a name="l00416"></a>00416 <span class="comment">// Create CImageTransform object and push it on to the cleanup stack</span>
<a name="l00417"></a>00417 CImageTransform* imageTransform = CImageTransform::NewL(iFs);
<a name="l00418"></a>00418 CleanupStack::PushL(imageTransform);
<a name="l00419"></a>00419
<a name="l00420"></a>00420 imageTransform->SetSourceDataL(imageFromFilePtr);
<a name="l00421"></a>00421 imageTransform->SetDestFilenameL(aFileName2);
<a name="l00422"></a>00422 imageTransform->SetDestSizeInPixelsL(TSize(160, 120), ETrue);
<a name="l00423"></a>00423 imageTransform->SetPreserveImageData(ETrue);
<a name="l00424"></a>00424 imageTransform->SetupL();
<a name="l00425"></a>00425
<a name="l00426"></a>00426 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span>
<a name="l00427"></a>00427 <span class="comment">// See Note 1</span>
<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>();
<a name="l00429"></a>00429
<a name="l00430"></a>00430 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span>
<a name="l00431"></a>00431 imageTransform->Transform(activeListener->iStatus);
<a name="l00432"></a>00432
<a name="l00433"></a>00433 <span class="comment">// See Note 2</span>
<a name="l00434"></a>00434 CActiveScheduler::Start();
<a name="l00435"></a>00435 User::LeaveIfError(activeListener->iStatus.Int());
<a name="l00436"></a>00436
<a name="l00437"></a>00437
<a name="l00438"></a>00438 CleanupStack::PopAndDestroy(3); <span class="comment">// activeListener, imageTransform and imageInMemory</span>
<a name="l00439"></a>00439 }
<a name="l00440"></a>00440
<a name="l00441"></a>00441
<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)
<a name="l00453"></a>00453 {
<a name="l00454"></a>00454 <span class="comment">// Create a CImageTransform object and push it on to the cleanup stack</span>
<a name="l00455"></a>00455 CImageTransform* imageTransform = NULL;
<a name="l00456"></a>00456
<a name="l00457"></a>00457 imageTransform = CImageTransform::NewL(iFs);
<a name="l00458"></a>00458 CleanupStack::PushL(imageTransform);
<a name="l00459"></a>00459
<a name="l00460"></a>00460 imageTransform->SetSourceFilenameL(aSrcFileName);
<a name="l00461"></a>00461 imageTransform->SetDestFilenameL(aDesFileName);
<a name="l00462"></a>00462 imageTransform->SetDestSizeInPixelsL(TSize(160, 120), ETrue);
<a name="l00463"></a>00463 imageTransform->SetOptionsL(CImageTransform::EThumbnail);
<a name="l00464"></a>00464 imageTransform->SetupL();
<a name="l00465"></a>00465
<a name="l00466"></a>00466 <span class="comment">// encode the image to add thumbnail</span>
<a name="l00467"></a>00467 <span class="comment">// See Note 1</span>
<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>();
<a name="l00469"></a>00469
<a name="l00470"></a>00470 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span>
<a name="l00471"></a>00471 imageTransform->Transform(activeListener->iStatus);
<a name="l00472"></a>00472
<a name="l00473"></a>00473 <span class="comment">// See Note 2</span>
<a name="l00474"></a>00474 CActiveScheduler::Start();
<a name="l00475"></a>00475 User::LeaveIfError(activeListener->iStatus.Int());
<a name="l00476"></a>00476
<a name="l00477"></a>00477
<a name="l00478"></a>00478 CleanupStack::PopAndDestroy(2); <span class="comment">// activeListener and imageTransform</span>
<a name="l00479"></a>00479 }
<a name="l00480"></a>00480
<a name="l00481"></a>00481
<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)
<a name="l00494"></a>00494 {
<a name="l00495"></a>00495 HBufC8* encodedImageDescriptor = NULL;
<a name="l00496"></a>00496
<a name="l00497"></a>00497 <span class="comment">// Create the encoder, passing a buffer to store the encoded image</span>
<a name="l00498"></a>00498 CJPEGExifEncoder* exifEncoder = <span class="keyword">static_cast<</span>CJPEGExifEncoder*<span class="keyword">></span>(CImageEncoder::DataNewL(encodedImageDescriptor, CImageEncoder::EOptionNone, KImageTypeJPGUid));
<a name="l00499"></a>00499 CleanupStack::PushL(exifEncoder);
<a name="l00500"></a>00500
<a name="l00501"></a>00501 <span class="comment">// Create a MExifMetadata object and initializes to metadata associated with CJPEGexifEncoder </span>
<a name="l00502"></a>00502 MExifMetadataWriter* metaData = exifEncoder->ExifMetadata();
<a name="l00503"></a>00503
<a name="l00504"></a>00504 <span class="comment">// Create a TExifWriterUtility object to write the metadata in to the image</span>
<a name="l00505"></a>00505 TExifWriterUtility exifWriteUtility(metaData);
<a name="l00506"></a>00506
<a name="l00507"></a>00507 HBufC8* buf8ParamWriteVersion = KBuf8ParamWriteVersion().AllocLC();
<a name="l00508"></a>00508
<a name="l00509"></a>00509 User::LeaveIfError(exifWriteUtility.SetImageDescription(buf8ParamWriteVersion));
<a name="l00510"></a>00510
<a name="l00511"></a>00511 CleanupStack::PopAndDestroy(buf8ParamWriteVersion);
<a name="l00512"></a>00512
<a name="l00513"></a>00513
<a name="l00514"></a>00514 <span class="comment">// Create a CFbsBitmap to store the source bitmap to encode</span>
<a name="l00515"></a>00515 CFbsBitmap* sourceBitmap = <span class="keyword">new</span>(ELeave) CFbsBitmap;
<a name="l00516"></a>00516 CleanupStack::PushL(sourceBitmap);
<a name="l00517"></a>00517
<a name="l00518"></a>00518 User::LeaveIfError(sourceBitmap->Create(TSize(20,30), EColor16M));
<a name="l00519"></a>00519 User::LeaveIfError(sourceBitmap->Load(aFileName));
<a name="l00520"></a>00520
<a name="l00521"></a>00521 <span class="comment">// Create CFrameImageData object and push it on the cleanup stack </span>
<a name="l00522"></a>00522 CFrameImageData* frameImageData = CFrameImageData::NewL();
<a name="l00523"></a>00523 CleanupStack::PushL(frameImageData);
<a name="l00524"></a>00524
<a name="l00525"></a>00525 <span class="comment">// See Note 1</span>
<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>();
<a name="l00527"></a>00527
<a name="l00528"></a>00528 <span class="comment">// Convert the image</span>
<a name="l00529"></a>00529 exifEncoder->Convert(&activeListener->iStatus, *sourceBitmap, frameImageData);
<a name="l00530"></a>00530
<a name="l00531"></a>00531 <span class="comment">// See Note 2</span>
<a name="l00532"></a>00532 CActiveScheduler::Start();
<a name="l00533"></a>00533 User::LeaveIfError(activeListener->iStatus.Int()); <span class="comment">// encode complete either display the image or report an error.</span>
<a name="l00534"></a>00534
<a name="l00535"></a>00535
<a name="l00536"></a>00536 <span class="comment">// Just verifying the presence of some output.</span>
<a name="l00537"></a>00537 sourceBitmap->Save(_L(<span class="stringliteral">"c:\\ICLExample\\addexifbitmap.mbm"</span>));
<a name="l00538"></a>00538
<a name="l00539"></a>00539
<a name="l00540"></a>00540 CleanupStack::PopAndDestroy(4); <span class="comment">// activeListener, frameImageData, sourceBitmap and exifEncoder</span>
<a name="l00541"></a>00541
<a name="l00542"></a>00542
<a name="l00543"></a>00543 <span class="comment">// We can use the descriptor here</span>
<a name="l00544"></a>00544
<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>
<a name="l00546"></a>00546 <span class="comment">// memory leaks take place if any leave later</span>
<a name="l00547"></a>00547
<a name="l00548"></a>00548 CleanupDeletePushL(encodedImageDescriptor);
<a name="l00549"></a>00549
<a name="l00550"></a>00550
<a name="l00551"></a>00551 <span class="comment">// Just verifying the presence of some output.</span>
<a name="l00552"></a>00552
<a name="l00553"></a>00553 RFile file;
<a name="l00554"></a>00554
<a name="l00555"></a>00555 User::LeaveIfError(file.Replace(iFs, _L(<span class="stringliteral">"c:\\ICLExample\\addexifdescriptor.mbm"</span>), EFileWrite));
<a name="l00556"></a>00556 CleanupClosePushL(file);
<a name="l00557"></a>00557
<a name="l00558"></a>00558 User::LeaveIfError(file.Write(*encodedImageDescriptor));
<a name="l00559"></a>00559
<a name="l00560"></a>00560 CleanupStack::PopAndDestroy(&file);
<a name="l00561"></a>00561
<a name="l00562"></a>00562
<a name="l00563"></a>00563 CleanupStack::PopAndDestroy(encodedImageDescriptor);
<a name="l00564"></a>00564 }
<a name="l00565"></a>00565
<a name="l00566"></a>00566
<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)
<a name="l00579"></a>00579 {
<a name="l00580"></a>00580 <span class="comment">// Create the encoder, passing the filename. </span>
<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>
<a name="l00582"></a>00582 CImageEncoder* jpegImageEncoder = CImageEncoder::FileNewL(iFs, aDestFileName, CImageEncoder::EOptionNone, KImageTypeJPGUid);
<a name="l00583"></a>00583 CleanupStack::PushL(jpegImageEncoder);
<a name="l00584"></a>00584
<a name="l00585"></a>00585 <span class="comment">// Create a CFbsBitmap to store the source bitmap to encode</span>
<a name="l00586"></a>00586 CFbsBitmap* sourceBitmap = <span class="keyword">new</span>(ELeave) CFbsBitmap;
<a name="l00587"></a>00587 CleanupStack::PushL(sourceBitmap);
<a name="l00588"></a>00588
<a name="l00589"></a>00589 User::LeaveIfError(sourceBitmap->Load(aSrcFileName));
<a name="l00590"></a>00590
<a name="l00591"></a>00591 <span class="comment">// Create operation extension</span>
<a name="l00592"></a>00592 TImageConvOperation* operation = jpegImageEncoder->OperationL();
<a name="l00593"></a>00593
<a name="l00594"></a>00594 <span class="comment">// Add Rotate 90degrees operation</span>
<a name="l00595"></a>00595 operation->AddOperationL(TImageConvOperation::ERotation90DegreesClockwise);
<a name="l00596"></a>00596 <span class="comment">// NOTE: Multiple operations can be added</span>
<a name="l00597"></a>00597
<a name="l00598"></a>00598 <span class="comment">// See Note 1</span>
<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>();
<a name="l00600"></a>00600
<a name="l00601"></a>00601 <span class="comment">// Convert the image</span>
<a name="l00602"></a>00602 jpegImageEncoder->Convert(&activeListener->iStatus, *sourceBitmap, NULL);
<a name="l00603"></a>00603
<a name="l00604"></a>00604 <span class="comment">// See Note 2</span>
<a name="l00605"></a>00605 CActiveScheduler::Start();
<a name="l00606"></a>00606 User::LeaveIfError(activeListener->iStatus.Int());<span class="comment">// encode complete either display the image or report an error.</span>
<a name="l00607"></a>00607
<a name="l00608"></a>00608 CleanupStack::PopAndDestroy(3, jpegImageEncoder); <span class="comment">// jpegImageEncoder, sourceBitmap and activeListener</span>
<a name="l00609"></a>00609 }
</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
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>