Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/icljpgtoolsandsqueezeexample_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/icljpgtoolsandsqueezeexample.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/icljpgtoolsandsqueezeexample.cpp</h1><a href="icljpgtoolsandsqueezeexample_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).</span>
<a name="l00002"></a>00002 <span class="comment">// All rights reserved.</span>
<a name="l00003"></a>00003 <span class="comment">// This component and the accompanying materials are made available</span>
<a name="l00004"></a>00004 <span class="comment">// under the terms of "Eclipse Public License v1.0"</span>
<a name="l00005"></a>00005 <span class="comment">// which accompanies this distribution, and is available</span>
<a name="l00006"></a>00006 <span class="comment">// at the URL "http://www.eclipse.org/legal/epl-v10.html".</span>
<a name="l00007"></a>00007 <span class="comment">//</span>
<a name="l00008"></a>00008 <span class="comment">// Initial Contributors:</span>
<a name="l00009"></a>00009 <span class="comment">// Nokia Corporation - initial contribution.</span>
<a name="l00010"></a>00010 <span class="comment">//</span>
<a name="l00011"></a>00011 <span class="comment">// Contributors:</span>
<a name="l00012"></a>00012 <span class="comment">//</span>
<a name="l00013"></a>00013 <span class="comment">// Description:</span>
<a name="l00014"></a>00014 <span class="comment">// This code demonstrates various imagetransformations available in Jpeg Tools and Squeeze </span>
<a name="l00015"></a>00015 <span class="comment">// modules of ICL </span>
<a name="l00016"></a>00016 <span class="comment">// Note 1: For demonstration purposes we create a client side active object which can </span>
<a name="l00017"></a>00017 <span class="comment">// handle the asynchronous request to transform the image. In a standard application the asynchronous</span>
<a name="l00018"></a>00018 <span class="comment">// call would be made passing in a TRequestStatus object associate with an active object</span>
<a name="l00019"></a>00019 <span class="comment">// which is part of that application. We would return to the main UI processing thread in </span>
<a name="l00020"></a>00020 <span class="comment">// which an active scheduler is running and wait for the asynchronous request to complete. In </span>
<a name="l00021"></a>00021 <span class="comment">// this demonstration we need to manually start the active scheduler.</span>
<a name="l00022"></a>00022 <span class="comment">// Note 2: Starts the active scheduler - this is for demonstration purposes. See Note 1:</span>
<a name="l00023"></a>00023 <span class="comment">//</span>
<a name="l00024"></a>00024
<a name="l00025"></a>00025
<a name="l00026"></a>00026
<a name="l00027"></a>00027
<a name="l00028"></a>00028
<a name="l00033"></a>00033 <span class="preprocessor">#include "<a class="code" href="iclexample_8h.html">iclexample.h</a>"</span>
<a name="l00034"></a>00034
<a name="l00035"></a>00035 <span class="preprocessor">#include <imagetransform.h></span>
<a name="l00036"></a>00036 <span class="preprocessor">#include <icl/squeezetransformextension.h></span>
<a name="l00037"></a>00037 <span class="preprocessor">#include <icl/orientationtransformextension.h></span>
<a name="l00038"></a>00038 <span class="preprocessor">#include <icl/overlaytransformextension.h></span>
<a name="l00039"></a>00039 <span class="preprocessor">#include <iclexifimageframe.h></span>
<a name="l00040"></a>00040 <span class="preprocessor">#include <imageframe.h></span>
<a name="l00041"></a>00041 <span class="preprocessor">#include <imageconversion.h></span>
<a name="l00042"></a>00042
<a name="l00043"></a>00043
<a name="l00044"></a><a class="code" href="icljpgtoolsandsqueezeexample_8cpp.html#59c2123c4f4c2095c8330b4876bfe28e">00044</a> <span class="keyword">const</span> TUid <a class="code" href="icljpgtoolsandsqueezeexample_8cpp.html#59c2123c4f4c2095c8330b4876bfe28e">KImageFramePluginUid</a> = {0x101F7C60};
<a name="l00045"></a>00045
<a name="l00056"></a><a class="code" href="class_c_icl_example.html#01e8b801b449b110507d038fd29c0465">00056</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#01e8b801b449b110507d038fd29c0465">CIclExample::SqueezeJpgFileToFileL</a>(<span class="keyword">const</span> TDesC& aSrcFileName, <span class="keyword">const</span> TDesC& aDestFileName)
<a name="l00057"></a>00057 {
<a name="l00058"></a>00058 <span class="comment">// Create CImageTransform object and push it on to the cleanup stack</span>
<a name="l00059"></a>00059 CImageTransform* imageTransform = CImageTransform::NewL(iFs);
<a name="l00060"></a>00060 CleanupStack::PushL(imageTransform);
<a name="l00061"></a>00061
<a name="l00062"></a>00062 imageTransform->SetSourceFilenameL(aSrcFileName);
<a name="l00063"></a>00063 imageTransform->SetDestFilenameL(aDestFileName);
<a name="l00064"></a>00064 imageTransform->SetTransformationsL(CImageTransform::ESqueeze);
<a name="l00065"></a>00065 imageTransform->SetOptionsL(CImageTransform::EIgnoreExifMetadataProcessing);
<a name="l00066"></a>00066 imageTransform->SetupL();
<a name="l00067"></a>00067
<a name="l00068"></a>00068 TUid lSqUid = {KUidSqueezeTransformExtension };
<a name="l00069"></a>00069 TInt err = KErrNone;
<a name="l00070"></a>00070 CSqueezeTransformExtension* lSqExt = <span class="keyword">static_cast<</span>CSqueezeTransformExtension*<span class="keyword">></span>(imageTransform->Extension(lSqUid, err));
<a name="l00071"></a>00071 <span class="keywordflow">if</span>(!lSqExt)
<a name="l00072"></a>00072 {
<a name="l00073"></a>00073 User::Leave(err);
<a name="l00074"></a>00074 }
<a name="l00075"></a>00075
<a name="l00076"></a>00076 <span class="comment">// Squeeze by 20% of size in bytes</span>
<a name="l00077"></a>00077 TInt squeezeRate = 20;
<a name="l00078"></a>00078 RFile file;
<a name="l00079"></a>00079 User::LeaveIfError(file.Open(iFs, aSrcFileName, EFileRead));
<a name="l00080"></a>00080 TInt filesize;
<a name="l00081"></a>00081 User::LeaveIfError(file.Size(filesize));
<a name="l00082"></a>00082 file.Close();
<a name="l00083"></a>00083 TInt maxdestsize = filesize - ( (filesize * squeezeRate)/100 );
<a name="l00084"></a>00084
<a name="l00085"></a>00085 <span class="comment">// Set the desired max size of the squeezed file on the squeeze extension</span>
<a name="l00086"></a>00086 lSqExt->SetDestSizeInBytes(maxdestsize);
<a name="l00087"></a>00087
<a name="l00088"></a>00088 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span>
<a name="l00089"></a>00089 <span class="comment">// See Note 1</span>
<a name="l00090"></a>00090 <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="l00091"></a>00091
<a name="l00092"></a>00092 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span>
<a name="l00093"></a>00093 imageTransform->Transform(activeListener->iStatus);
<a name="l00094"></a>00094
<a name="l00095"></a>00095 <span class="comment">// See Note 2</span>
<a name="l00096"></a>00096 CActiveScheduler::Start();
<a name="l00097"></a>00097 User::LeaveIfError(activeListener->iStatus.Int());
<a name="l00098"></a>00098
<a name="l00099"></a>00099
<a name="l00100"></a>00100 CleanupStack::PopAndDestroy(2); <span class="comment">// activeListener, imageTransform </span>
<a name="l00101"></a>00101 }
<a name="l00102"></a>00102
<a name="l00103"></a>00103
<a name="l00114"></a><a class="code" href="class_c_icl_example.html#5a2b4947cd5af165546515ee95742419">00114</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#5a2b4947cd5af165546515ee95742419">CIclExample::SqueezeJpgBufferToBufferL</a>(<span class="keyword">const</span> TDesC& aSrcFileName, <span class="keyword">const</span> TDesC& aDestFileName)
<a name="l00115"></a>00115 {
<a name="l00116"></a>00116 TPtr8 imageFromFilePtr = LoadImageIntoMemoryLC(aSrcFileName);
<a name="l00117"></a>00117 HBufC8* destData = NULL;
<a name="l00118"></a>00118
<a name="l00119"></a>00119 <span class="comment">// Create CImageTransform object and push it on to the cleanup stack</span>
<a name="l00120"></a>00120 CImageTransform* imageTransform = CImageTransform::NewL(iFs);
<a name="l00121"></a>00121 CleanupStack::PushL(imageTransform);
<a name="l00122"></a>00122
<a name="l00123"></a>00123 imageTransform->SetSourceDataL(imageFromFilePtr);
<a name="l00124"></a>00124 imageTransform->SetDestDataL(destData);
<a name="l00125"></a>00125 imageTransform->SetTransformationsL(CImageTransform::ESqueeze);
<a name="l00126"></a>00126 imageTransform->SetupL();
<a name="l00127"></a>00127
<a name="l00128"></a>00128 TUid lSqUid = {KUidSqueezeTransformExtension };
<a name="l00129"></a>00129 TInt err = KErrNone;
<a name="l00130"></a>00130 CSqueezeTransformExtension* lSqExt = <span class="keyword">static_cast<</span>CSqueezeTransformExtension*<span class="keyword">></span>(imageTransform->Extension(lSqUid, err));
<a name="l00131"></a>00131 <span class="keywordflow">if</span>(!lSqExt)
<a name="l00132"></a>00132 {
<a name="l00133"></a>00133 User::Leave(err);
<a name="l00134"></a>00134 }
<a name="l00135"></a>00135
<a name="l00136"></a>00136 <span class="comment">// Squeeze by 5% of size in bytes</span>
<a name="l00137"></a>00137 TInt squeezeRate = 5;
<a name="l00138"></a>00138 RFile file;
<a name="l00139"></a>00139 User::LeaveIfError(file.Open(iFs, aSrcFileName, EFileRead));
<a name="l00140"></a>00140 TInt filesize;
<a name="l00141"></a>00141 User::LeaveIfError(file.Size(filesize));
<a name="l00142"></a>00142 file.Close();
<a name="l00143"></a>00143 TInt maxdestsize = filesize - ( (filesize * squeezeRate)/100 );
<a name="l00144"></a>00144
<a name="l00145"></a>00145 <span class="comment">// Set the desired max size of the squeezed file on the squeeze extension</span>
<a name="l00146"></a>00146 lSqExt->SetDestSizeInBytes(maxdestsize);
<a name="l00147"></a>00147
<a name="l00148"></a>00148 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span>
<a name="l00149"></a>00149 <span class="comment">// See Note 1</span>
<a name="l00150"></a>00150 <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="l00151"></a>00151
<a name="l00152"></a>00152 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span>
<a name="l00153"></a>00153 imageTransform->Transform(activeListener->iStatus);
<a name="l00154"></a>00154
<a name="l00155"></a>00155 <span class="comment">// See Note 2</span>
<a name="l00156"></a>00156 CActiveScheduler::Start();
<a name="l00157"></a>00157 User::LeaveIfError(activeListener->iStatus.Int());
<a name="l00158"></a>00158
<a name="l00159"></a>00159 <span class="comment">// write the descriptor to the output file</span>
<a name="l00160"></a>00160 User::LeaveIfError(file.Replace(iFs, aDestFileName, EFileWrite));
<a name="l00161"></a>00161 file.Write(*destData);
<a name="l00162"></a>00162 file.Close();
<a name="l00163"></a>00163 <span class="keyword">delete</span> destData;
<a name="l00164"></a>00164
<a name="l00165"></a>00165 CleanupStack::PopAndDestroy(3); <span class="comment">// activeListener, imageTransform, image </span>
<a name="l00166"></a>00166 }
<a name="l00167"></a>00167
<a name="l00168"></a>00168
<a name="l00179"></a><a class="code" href="class_c_icl_example.html#ad1303bafe8aac71274efa90558f29ff">00179</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#ad1303bafe8aac71274efa90558f29ff">CIclExample::AutoSqueezeJpgFileToFileL</a>(<span class="keyword">const</span> TDesC& aSrcFileName, <span class="keyword">const</span> TDesC& aDestFileName)
<a name="l00180"></a>00180 {
<a name="l00181"></a>00181 <span class="comment">// Create CImageTransform object and push it on to the cleanup stack</span>
<a name="l00182"></a>00182 CImageTransform* imageTransform = CImageTransform::NewL(iFs);
<a name="l00183"></a>00183 CleanupStack::PushL(imageTransform);
<a name="l00184"></a>00184
<a name="l00185"></a>00185 imageTransform->SetSourceFilenameL(aSrcFileName);
<a name="l00186"></a>00186 imageTransform->SetDestFilenameL(aDestFileName);
<a name="l00187"></a>00187 imageTransform->SetTransformationsL(CImageTransform::ESqueeze);
<a name="l00188"></a>00188 imageTransform->SetupL();
<a name="l00189"></a>00189
<a name="l00190"></a>00190 TUid lSqUid = {KUidSqueezeTransformExtension };
<a name="l00191"></a>00191 TInt err = KErrNone;
<a name="l00192"></a>00192 CSqueezeTransformExtension* lSqExt = <span class="keyword">static_cast<</span>CSqueezeTransformExtension*<span class="keyword">></span>(imageTransform->Extension(lSqUid, err));
<a name="l00193"></a>00193 <span class="keywordflow">if</span>(!lSqExt)
<a name="l00194"></a>00194 {
<a name="l00195"></a>00195 User::Leave(err);
<a name="l00196"></a>00196 }
<a name="l00197"></a>00197
<a name="l00198"></a>00198 <span class="comment">// Squeeze by 5% of size in bytes</span>
<a name="l00199"></a>00199 TInt squeezeRate = 5;
<a name="l00200"></a>00200 RFile file;
<a name="l00201"></a>00201 User::LeaveIfError(file.Open(iFs, aSrcFileName, EFileRead));
<a name="l00202"></a>00202 TInt filesize;
<a name="l00203"></a>00203 User::LeaveIfError(file.Size(filesize));
<a name="l00204"></a>00204 file.Close();
<a name="l00205"></a>00205 TInt maxdestsize = filesize - ( (filesize * squeezeRate)/100 );
<a name="l00206"></a>00206
<a name="l00207"></a>00207 <span class="comment">// Get the pixel size of the image</span>
<a name="l00208"></a>00208 CJPEGImageFrameDecoder *decoder = NULL;
<a name="l00209"></a>00209 decoder= <span class="keyword">static_cast<</span>CJPEGImageFrameDecoder*<span class="keyword">></span> (CImageDecoder::FileNewL(iFs, aSrcFileName, CImageDecoder::EOptionNone, KNullUid, KNullUid, <a class="code" href="icljpgtoolsandsqueezeexample_8cpp.html#59c2123c4f4c2095c8330b4876bfe28e">KImageFramePluginUid</a>));
<a name="l00210"></a>00210 <span class="keyword">const</span> TFrameInfo* frameInfo = &decoder->FrameInfo();;
<a name="l00211"></a>00211 TSize imgSizeInPixels = frameInfo->iOverallSizeInPixels;
<a name="l00212"></a>00212 <span class="keyword">delete</span> decoder;
<a name="l00213"></a>00213
<a name="l00214"></a>00214 <span class="comment">// Max pixel size may be 10% of the original size</span>
<a name="l00215"></a>00215 TSize maxImageSizeInPixels;
<a name="l00216"></a>00216 maxImageSizeInPixels.iWidth = imgSizeInPixels.iWidth - (imgSizeInPixels.iWidth *10) /100;
<a name="l00217"></a>00217 maxImageSizeInPixels.iHeight = imgSizeInPixels.iHeight - (imgSizeInPixels.iHeight *10) /100;
<a name="l00218"></a>00218
<a name="l00219"></a>00219 <span class="comment">// Min pixel size may be 30% of the original size</span>
<a name="l00220"></a>00220 TSize minImageSizeInPixels;
<a name="l00221"></a>00221 minImageSizeInPixels.iWidth = imgSizeInPixels.iWidth - (imgSizeInPixels.iWidth *30) /100;
<a name="l00222"></a>00222 minImageSizeInPixels.iHeight = imgSizeInPixels.iHeight - (imgSizeInPixels.iHeight *30) /100;
<a name="l00223"></a>00223
<a name="l00224"></a>00224 <span class="comment">// Set the various desired parmas for the auto squeeze</span>
<a name="l00225"></a>00225 TAdvancedSqueezeParams squeezeAutoResizeParams;
<a name="l00226"></a>00226 squeezeAutoResizeParams.iMaxDestSizeInBytes = maxdestsize;
<a name="l00227"></a>00227 squeezeAutoResizeParams.iResizeAction = TAdvancedSqueezeParams::EAutoResizeActionPrioritizeLargeImageSize;
<a name="l00228"></a>00228 squeezeAutoResizeParams.iMinImageSize = minImageSizeInPixels;
<a name="l00229"></a>00229 squeezeAutoResizeParams.iMaxImageSize = maxImageSizeInPixels;
<a name="l00230"></a>00230 squeezeAutoResizeParams.iSamplingUid = KUidSamplingColor422;
<a name="l00231"></a>00231 squeezeAutoResizeParams.iMinEncodingQuality = 0.8f;
<a name="l00232"></a>00232 <span class="comment">// Set the advance params to the squeeze extension</span>
<a name="l00233"></a>00233 lSqExt->SetAdvancedSqueezeModeL(&squeezeAutoResizeParams);
<a name="l00234"></a>00234
<a name="l00235"></a>00235
<a name="l00236"></a>00236 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span>
<a name="l00237"></a>00237 <span class="comment">// See Note 1</span>
<a name="l00238"></a>00238 <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="l00239"></a>00239
<a name="l00240"></a>00240 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span>
<a name="l00241"></a>00241 imageTransform->Transform(activeListener->iStatus);
<a name="l00242"></a>00242
<a name="l00243"></a>00243 <span class="comment">// See Note 2</span>
<a name="l00244"></a>00244 CActiveScheduler::Start();
<a name="l00245"></a>00245 User::LeaveIfError(activeListener->iStatus.Int());
<a name="l00246"></a>00246
<a name="l00247"></a>00247
<a name="l00248"></a>00248 CleanupStack::PopAndDestroy(2); <span class="comment">// activeListener, imageTransform </span>
<a name="l00249"></a>00249 }
<a name="l00250"></a>00250
<a name="l00261"></a><a class="code" href="class_c_icl_example.html#0afdb26ddecd25134d6c33109f9ce99f">00261</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#0afdb26ddecd25134d6c33109f9ce99f">CIclExample::RotateJpgFileToFileL</a>(<span class="keyword">const</span> TDesC& aSrcFileName, <span class="keyword">const</span> TDesC& aDestFileName)
<a name="l00262"></a>00262 {
<a name="l00263"></a>00263 <span class="comment">// Create CImageTransform object and push it on to the cleanup stack</span>
<a name="l00264"></a>00264 CImageTransform* imageTransform = CImageTransform::NewL(iFs);
<a name="l00265"></a>00265 CleanupStack::PushL(imageTransform);
<a name="l00266"></a>00266
<a name="l00267"></a>00267 imageTransform->SetSourceFilenameL(aSrcFileName);
<a name="l00268"></a>00268 imageTransform->SetDestFilenameL(aDestFileName);
<a name="l00269"></a>00269 imageTransform->SetTransformationsL(CImageTransform::EOrientation);
<a name="l00270"></a>00270 imageTransform->SetupL();
<a name="l00271"></a>00271
<a name="l00272"></a>00272 TUid lRotateUid = {KUidOrientationTransformExtension };
<a name="l00273"></a>00273 TInt err = KErrNone;
<a name="l00274"></a>00274 COrientationTransformExtension* lRotateExt = <span class="keyword">static_cast<</span>COrientationTransformExtension*<span class="keyword">></span>(imageTransform->Extension(lRotateUid, err));
<a name="l00275"></a>00275 <span class="keywordflow">if</span>(!lRotateExt)
<a name="l00276"></a>00276 {
<a name="l00277"></a>00277 User::Leave(err);
<a name="l00278"></a>00278 }
<a name="l00279"></a>00279 <span class="comment">// Rotate by 90 degree of size in bytes</span>
<a name="l00280"></a>00280 lRotateExt->SetOrientationL(COrientationTransformExtension::ERotation90DegreesClockwise);
<a name="l00281"></a>00281
<a name="l00282"></a>00282 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span>
<a name="l00283"></a>00283 <span class="comment">// See Note 1</span>
<a name="l00284"></a>00284 <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="l00285"></a>00285
<a name="l00286"></a>00286 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span>
<a name="l00287"></a>00287 imageTransform->Transform(activeListener->iStatus);
<a name="l00288"></a>00288
<a name="l00289"></a>00289 <span class="comment">// See Note 2</span>
<a name="l00290"></a>00290 CActiveScheduler::Start();
<a name="l00291"></a>00291 User::LeaveIfError(activeListener->iStatus.Int());
<a name="l00292"></a>00292
<a name="l00293"></a>00293
<a name="l00294"></a>00294 CleanupStack::PopAndDestroy(2); <span class="comment">// activeListener, imageTransform </span>
<a name="l00295"></a>00295 }
<a name="l00296"></a>00296
<a name="l00297"></a>00297
<a name="l00309"></a><a class="code" href="class_c_icl_example.html#5a9a18e5cb34223269cf92d0367d7dd2">00309</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#5a9a18e5cb34223269cf92d0367d7dd2">CIclExample::OverlayJpgDataToJpgFileToFileL</a>(<span class="keyword">const</span> TDesC& aSrcFileName, <span class="keyword">const</span> TDesC& aOverlayFileName, <span class="keyword">const</span> TDesC& aDestFileName)
<a name="l00310"></a>00310 {
<a name="l00311"></a>00311 <span class="comment">// Create CImageTransform object and push it on to the cleanup stack</span>
<a name="l00312"></a>00312 CImageTransform* imageTransform = CImageTransform::NewL(iFs);
<a name="l00313"></a>00313 CleanupStack::PushL(imageTransform);
<a name="l00314"></a>00314
<a name="l00315"></a>00315 imageTransform->SetSourceFilenameL(aSrcFileName);
<a name="l00316"></a>00316 imageTransform->SetDestFilenameL(aDestFileName);
<a name="l00317"></a>00317 imageTransform->SetTransformationsL(CImageTransform::EOverlay);
<a name="l00318"></a>00318 imageTransform->SetupL();
<a name="l00319"></a>00319
<a name="l00320"></a>00320 TUid lRotateUid = {KUidOverlayTransformExtension };
<a name="l00321"></a>00321 TInt err = KErrNone;
<a name="l00322"></a>00322 COverlayTransformExtension* lOverlayExt = <span class="keyword">static_cast<</span>COverlayTransformExtension*<span class="keyword">></span>(imageTransform->Extension(lRotateUid, err));
<a name="l00323"></a>00323 <span class="keywordflow">if</span>(!lOverlayExt)
<a name="l00324"></a>00324 {
<a name="l00325"></a>00325 User::Leave(err);
<a name="l00326"></a>00326 }
<a name="l00327"></a>00327 <span class="comment">// Set the position</span>
<a name="l00328"></a>00328 TPoint position(0,0);
<a name="l00329"></a>00329 lOverlayExt->SetPosition(position);
<a name="l00330"></a>00330
<a name="l00331"></a>00331 <span class="comment">// Set the overlay file</span>
<a name="l00332"></a>00332 TPtr8 imageFromFilePtr = LoadImageIntoMemoryLC(aOverlayFileName);
<a name="l00333"></a>00333 lOverlayExt->SetOverlayDataL(imageFromFilePtr, KImageTypeJPGUid);
<a name="l00334"></a>00334
<a name="l00335"></a>00335 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span>
<a name="l00336"></a>00336 <span class="comment">// See Note 1</span>
<a name="l00337"></a>00337 <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="l00338"></a>00338
<a name="l00339"></a>00339 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span>
<a name="l00340"></a>00340 imageTransform->Transform(activeListener->iStatus);
<a name="l00341"></a>00341
<a name="l00342"></a>00342 <span class="comment">// See Note 2</span>
<a name="l00343"></a>00343 CActiveScheduler::Start();
<a name="l00344"></a>00344 User::LeaveIfError(activeListener->iStatus.Int());
<a name="l00345"></a>00345
<a name="l00346"></a>00346
<a name="l00347"></a>00347 CleanupStack::PopAndDestroy(3); <span class="comment">// activeListener, overlay image, imageTransform </span>
<a name="l00348"></a>00348 }
<a name="l00349"></a>00349
<a name="l00361"></a><a class="code" href="class_c_icl_example.html#dfaa0ee7346aa45a9ef50d9fe7295404">00361</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#dfaa0ee7346aa45a9ef50d9fe7295404">CIclExample::OverlayPngFileToJpgFileToFileL</a>(<span class="keyword">const</span> TDesC& aSrcFileName, <span class="keyword">const</span> TDesC& aOverlayFileName, <span class="keyword">const</span> TDesC& aDestFileName)
<a name="l00362"></a>00362 {
<a name="l00363"></a>00363 <span class="comment">// Create CImageTransform object and push it on to the cleanup stack</span>
<a name="l00364"></a>00364 CImageTransform* imageTransform = CImageTransform::NewL(iFs);
<a name="l00365"></a>00365 CleanupStack::PushL(imageTransform);
<a name="l00366"></a>00366
<a name="l00367"></a>00367 imageTransform->SetSourceFilenameL(aSrcFileName);
<a name="l00368"></a>00368 imageTransform->SetDestFilenameL(aDestFileName);
<a name="l00369"></a>00369 imageTransform->SetTransformationsL(CImageTransform::EOverlay);
<a name="l00370"></a>00370 imageTransform->SetupL();
<a name="l00371"></a>00371
<a name="l00372"></a>00372 TUid lOverlayUid = {KUidOverlayTransformExtension };
<a name="l00373"></a>00373 TInt err = KErrNone;
<a name="l00374"></a>00374 COverlayTransformExtension* lOverlayExt = <span class="keyword">static_cast<</span>COverlayTransformExtension*<span class="keyword">></span>(imageTransform->Extension(lOverlayUid, err));
<a name="l00375"></a>00375 <span class="keywordflow">if</span>(!lOverlayExt)
<a name="l00376"></a>00376 {
<a name="l00377"></a>00377 User::Leave(err);
<a name="l00378"></a>00378 }
<a name="l00379"></a>00379 <span class="comment">// Set the position</span>
<a name="l00380"></a>00380 TPoint position(0,0);
<a name="l00381"></a>00381 lOverlayExt->SetPosition(position);
<a name="l00382"></a>00382
<a name="l00383"></a>00383 <span class="comment">// Set the overlay data</span>
<a name="l00384"></a>00384 TUid pngUid = KImageTypePNGUid;
<a name="l00385"></a>00385 lOverlayExt->SetOverlayFileL(aOverlayFileName, pngUid);
<a name="l00386"></a>00386
<a name="l00387"></a>00387 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span>
<a name="l00388"></a>00388 <span class="comment">// See Note 1</span>
<a name="l00389"></a>00389 <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="l00390"></a>00390
<a name="l00391"></a>00391 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span>
<a name="l00392"></a>00392 imageTransform->Transform(activeListener->iStatus);
<a name="l00393"></a>00393
<a name="l00394"></a>00394 <span class="comment">// See Note 2</span>
<a name="l00395"></a>00395 CActiveScheduler::Start();
<a name="l00396"></a>00396 User::LeaveIfError(activeListener->iStatus.Int());
<a name="l00397"></a>00397
<a name="l00398"></a>00398
<a name="l00399"></a>00399 CleanupStack::PopAndDestroy(2); <span class="comment">// activeListener, overlay image, imageTransform </span>
<a name="l00400"></a>00400 }
<a name="l00401"></a>00401
<a name="l00402"></a>00402
<a name="l00414"></a><a class="code" href="class_c_icl_example.html#3c18c273d702e32b9d4e196e38edfa46">00414</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#3c18c273d702e32b9d4e196e38edfa46">CIclExample::OverlayBmpDataToJpgFileToFileL</a>(<span class="keyword">const</span> TDesC& aSrcFileName, <span class="keyword">const</span> TDesC& aOverlayFileName, <span class="keyword">const</span> TDesC& aDestFileName)
<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->SetSourceFilenameL(aSrcFileName);
<a name="l00421"></a>00421 imageTransform->SetDestFilenameL(aDestFileName);
<a name="l00422"></a>00422 imageTransform->SetTransformationsL(CImageTransform::EOverlay);
<a name="l00423"></a>00423 imageTransform->SetupL();
<a name="l00424"></a>00424
<a name="l00425"></a>00425 TUid lRotateUid = {KUidOverlayTransformExtension };
<a name="l00426"></a>00426 TInt err = KErrNone;
<a name="l00427"></a>00427 COverlayTransformExtension* lOverlayExt = <span class="keyword">static_cast<</span>COverlayTransformExtension*<span class="keyword">></span>(imageTransform->Extension(lRotateUid, err));
<a name="l00428"></a>00428 <span class="keywordflow">if</span>(!lOverlayExt)
<a name="l00429"></a>00429 {
<a name="l00430"></a>00430 User::Leave(err);
<a name="l00431"></a>00431 }
<a name="l00432"></a>00432 <span class="comment">// Set the position</span>
<a name="l00433"></a>00433 TPoint position(0,0);
<a name="l00434"></a>00434 lOverlayExt->SetPosition(position);
<a name="l00435"></a>00435
<a name="l00436"></a>00436 <span class="comment">// Set the overlay bitmap</span>
<a name="l00437"></a>00437 CFbsBitmap* overlayBitmap = <span class="keyword">new</span> (ELeave) CFbsBitmap;
<a name="l00438"></a>00438 CleanupStack::PushL(overlayBitmap);
<a name="l00439"></a>00439 User::LeaveIfError(overlayBitmap->Load(aOverlayFileName));
<a name="l00440"></a>00440 lOverlayExt->SetOverlayImageL(*overlayBitmap);
<a name="l00441"></a>00441
<a name="l00442"></a>00442
<a name="l00443"></a>00443 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span>
<a name="l00444"></a>00444 <span class="comment">// See Note 1</span>
<a name="l00445"></a>00445 <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="l00446"></a>00446
<a name="l00447"></a>00447 <span class="comment">// Call Transform() function of CImageTransform for image transform operation</span>
<a name="l00448"></a>00448 imageTransform->Transform(activeListener->iStatus);
<a name="l00449"></a>00449
<a name="l00450"></a>00450 <span class="comment">// See Note 2</span>
<a name="l00451"></a>00451 CActiveScheduler::Start();
<a name="l00452"></a>00452 User::LeaveIfError(activeListener->iStatus.Int());
<a name="l00453"></a>00453
<a name="l00454"></a>00454
<a name="l00455"></a>00455 CleanupStack::PopAndDestroy(3); <span class="comment">// activeListener, overlay bitmap, imageTransform </span>
<a name="l00456"></a>00456 }
<a name="l00457"></a>00457
</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>