Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/icldecodeexample_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/icldecodeexample.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/icldecodeexample.cpp</h1><a href="icldecodeexample_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) 2007-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">// </span>
<a name="l00015"></a>00015 <span class="comment">//</span>
<a name="l00016"></a>00016
<a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="iclexample_8h.html">iclexample.h</a>"</span>
<a name="l00023"></a>00023
<a name="l00052"></a><a class="code" href="class_c_icl_example.html#932e5b95f92e651980d2c6720c8fd86d">00052</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#932e5b95f92e651980d2c6720c8fd86d">CIclExample::DecodeFromDescriptorToBitmapL</a>(<span class="keyword">const</span> TDesC& aFileName)
<a name="l00053"></a>00053 {
<a name="l00054"></a>00054 TPtr8 imageInMemory = LoadImageIntoMemoryLC(aFileName);
<a name="l00055"></a>00055
<a name="l00056"></a>00056 <span class="comment">// Try to create the decoder. If it's successful the image headers are read.</span>
<a name="l00057"></a>00057 CImageDecoder* imageDecoder = CImageDecoder::DataNewL(iFs, imageInMemory);
<a name="l00058"></a>00058 CleanupStack::PushL(imageDecoder);
<a name="l00059"></a>00059
<a name="l00060"></a>00060 <span class="comment">// Decoder found, create a bitmap for it to render the image to.</span>
<a name="l00061"></a>00061 CFbsBitmap* destBitmap = <span class="keyword">new</span>(ELeave) CFbsBitmap();
<a name="l00062"></a>00062 CleanupStack::PushL(destBitmap);
<a name="l00063"></a>00063
<a name="l00064"></a>00064 <span class="comment">// Since the image header has been read we can find out the image size and</span>
<a name="l00065"></a>00065 <span class="comment">// can create the bitmap to match the display mode we wish to support</span>
<a name="l00066"></a>00066 <span class="keyword">const</span> TFrameInfo& frameInfo = imageDecoder->FrameInfo(<a class="code" href="iclexample_8h.html#8e6dac40318753daf806f44078888a2e">KFirstFrame</a>);
<a name="l00067"></a>00067 User::LeaveIfError(destBitmap->Create(frameInfo.iOverallSizeInPixels, frameInfo.iFrameDisplayMode));
<a name="l00068"></a>00068
<a name="l00069"></a>00069 <span class="comment">// See Note 1</span>
<a name="l00070"></a>00070 <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="l00071"></a>00071
<a name="l00072"></a>00072 <span class="comment">// Convert the image (first frame)</span>
<a name="l00073"></a>00073 imageDecoder->Convert(&activeListener->iStatus, *destBitmap, <a class="code" href="iclexample_8h.html#8e6dac40318753daf806f44078888a2e">KFirstFrame</a>);
<a name="l00074"></a>00074
<a name="l00075"></a>00075 <span class="comment">// See Note 2</span>
<a name="l00076"></a>00076 CActiveScheduler::Start();
<a name="l00077"></a>00077 User::LeaveIfError(activeListener->iStatus.Int()); <span class="comment">// decode complete either display the image or report an error.</span>
<a name="l00078"></a>00078
<a name="l00079"></a>00079 <span class="comment">// Just verifying the presence of some output. The image can also be displayed instead.</span>
<a name="l00080"></a>00080 _LIT(KOutputFile, <span class="stringliteral">"c:\\ICLExample\\DecodedBitmapFromDescriptor.mbm"</span>);
<a name="l00081"></a>00081 destBitmap->Save(KOutputFile); <span class="comment">// Ignore return code.</span>
<a name="l00082"></a>00082
<a name="l00083"></a>00083 CleanupStack::PopAndDestroy(4); <span class="comment">// activeListener, destBitmap, imageDecoder and imageInMemory</span>
<a name="l00084"></a>00084 }
<a name="l00085"></a>00085
<a name="l00086"></a>00086
<a name="l00102"></a><a class="code" href="class_c_icl_example.html#f04196b4645c4aacad4f969f3a6ade0f">00102</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#f04196b4645c4aacad4f969f3a6ade0f">CIclExample::DecodeFromFileToBitmapL</a>(<span class="keyword">const</span> TDesC& aFileName)
<a name="l00103"></a>00103 {
<a name="l00104"></a>00104 <span class="comment">// Create the decoder, passing the filename. The image is recognised by the</span>
<a name="l00105"></a>00105 <span class="comment">// Image Conversion Library, an appropriate codec plugin loaded and the image</span>
<a name="l00106"></a>00106 <span class="comment">// headers parsed.</span>
<a name="l00107"></a>00107 <span class="comment">// If the image is not recognised or valid then the call will leave with an error</span>
<a name="l00108"></a>00108 CImageDecoder* imageDecoder = CImageDecoder::FileNewL(iFs, aFileName);
<a name="l00109"></a>00109 CleanupStack::PushL(imageDecoder);
<a name="l00110"></a>00110
<a name="l00111"></a>00111 CFbsBitmap* destBitmap = <span class="keyword">new</span>(ELeave) CFbsBitmap();
<a name="l00112"></a>00112 CleanupStack::PushL(destBitmap);
<a name="l00113"></a>00113
<a name="l00114"></a>00114 <span class="comment">// Since the image header has been parsed we can find out the image size and</span>
<a name="l00115"></a>00115 <span class="comment">// can create the bitmap to match the display mode we wish to support</span>
<a name="l00116"></a>00116 <span class="keyword">const</span> TFrameInfo& frameInfo = imageDecoder->FrameInfo(<a class="code" href="iclexample_8h.html#8e6dac40318753daf806f44078888a2e">KFirstFrame</a>);
<a name="l00117"></a>00117 User::LeaveIfError(destBitmap->Create(frameInfo.iOverallSizeInPixels, frameInfo.iFrameDisplayMode));
<a name="l00118"></a>00118
<a name="l00119"></a>00119 <span class="comment">// See Note 1</span>
<a name="l00120"></a>00120 <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="l00121"></a>00121
<a name="l00122"></a>00122 <span class="comment">// Convert the image (first frame)</span>
<a name="l00123"></a>00123 imageDecoder->Convert(&activeListener->iStatus, *destBitmap, <a class="code" href="iclexample_8h.html#8e6dac40318753daf806f44078888a2e">KFirstFrame</a>);
<a name="l00124"></a>00124
<a name="l00125"></a>00125 <span class="comment">// See Note 2</span>
<a name="l00126"></a>00126 CActiveScheduler::Start();
<a name="l00127"></a>00127 User::LeaveIfError(activeListener->iStatus.Int()); <span class="comment">// decode complete either display the image or report an error.</span>
<a name="l00128"></a>00128
<a name="l00129"></a>00129 <span class="comment">// Just verifying the presence of some output. The image can also be displayed instead.</span>
<a name="l00130"></a>00130 _LIT(KOutputFile, <span class="stringliteral">"c:\\ICLExample\\DecodedBitmapFromFile.mbm"</span>);
<a name="l00131"></a>00131 destBitmap->Save(KOutputFile); <span class="comment">// Ignore return code.</span>
<a name="l00132"></a>00132
<a name="l00133"></a>00133 CleanupStack::PopAndDestroy(3); <span class="comment">// activeListener, destBitmap and imageDecoder</span>
<a name="l00134"></a>00134 }
<a name="l00135"></a>00135
<a name="l00136"></a>00136
<a name="l00149"></a><a class="code" href="class_c_icl_example.html#59c8518cca1e856ec9977c77c133ba57">00149</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#59c8518cca1e856ec9977c77c133ba57">CIclExample::DecodeToYuvFrameL</a>(<span class="keyword">const</span> TDesC& aFileName)
<a name="l00150"></a>00150 {
<a name="l00151"></a>00151 RChunk chunk;
<a name="l00152"></a>00152 TInt imageSizeInBytes = 0;
<a name="l00153"></a>00153
<a name="l00154"></a>00154 <span class="comment">// Create the decoder, passing the filename. The image is recognised by the</span>
<a name="l00155"></a>00155 <span class="comment">// Image Conversion Library, an appropriate codec plugin loaded and the image</span>
<a name="l00156"></a>00156 <span class="comment">// headers parsed.</span>
<a name="l00157"></a>00157 <span class="comment">// If the image is not recognised or valid then the call will leave with an error</span>
<a name="l00158"></a>00158 CJPEGImageFrameDecoder* jpegImageDecoder = <span class="keyword">static_cast<</span>CJPEGImageFrameDecoder*<span class="keyword">></span>(CJPEGImageFrameDecoder::FileNewL(iFs, aFileName));
<a name="l00159"></a>00159 CleanupStack::PushL(jpegImageDecoder);
<a name="l00160"></a>00160
<a name="l00161"></a>00161 <span class="comment">// Check the image whether it's supporting YUV or not</span>
<a name="l00162"></a>00162 <span class="keywordflow">if</span> (jpegImageDecoder->RecommendedBufferSize(imageSizeInBytes) == EFalse)
<a name="l00163"></a>00163 {
<a name="l00164"></a>00164 User::Leave(KErrNotSupported);
<a name="l00165"></a>00165 }
<a name="l00166"></a>00166
<a name="l00167"></a>00167 User::LeaveIfError(chunk.CreateGlobal(KRChunk, imageSizeInBytes, imageSizeInBytes, EOwnerProcess));
<a name="l00168"></a>00168 CleanupClosePushL(chunk);
<a name="l00169"></a>00169
<a name="l00170"></a>00170 <span class="comment">// Create an empty imageframe</span>
<a name="l00171"></a>00171 CImageFrame* imageFrame = CImageFrame::NewL(&chunk, imageSizeInBytes, 0);
<a name="l00172"></a>00172 CleanupStack::PushL(imageFrame);
<a name="l00173"></a>00173
<a name="l00174"></a>00174 <span class="comment">// See Note 1</span>
<a name="l00175"></a>00175 <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="l00176"></a>00176
<a name="l00177"></a>00177 <span class="comment">// Convert the image to YUV image frame</span>
<a name="l00178"></a>00178 jpegImageDecoder->ConvertFrame(&activeListener->iStatus, *imageFrame, <a class="code" href="iclexample_8h.html#8e6dac40318753daf806f44078888a2e">KFirstFrame</a>);
<a name="l00179"></a>00179
<a name="l00180"></a>00180 <span class="comment">// See Note 2</span>
<a name="l00181"></a>00181 CActiveScheduler::Start();
<a name="l00182"></a>00182 User::LeaveIfError(activeListener->iStatus.Int()); <span class="comment">// decode complete either display the image or report an error.</span>
<a name="l00183"></a>00183
<a name="l00184"></a>00184 <span class="comment">// NOTE: YUV pixel buffer can be used if appropriate screen driver is available</span>
<a name="l00185"></a>00185
<a name="l00186"></a>00186 CleanupStack::PopAndDestroy(4); <span class="comment">// activeListener, imageFrame, chunk and jpegImageDecoder</span>
<a name="l00187"></a>00187 }
<a name="l00188"></a>00188
<a name="l00189"></a>00189
<a name="l00201"></a><a class="code" href="class_c_icl_example.html#81fa0479879d15a817fff1809ac17854">00201</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#81fa0479879d15a817fff1809ac17854">CIclExample::AccessThumbnailToDecodeL</a>(<span class="keyword">const</span> TDesC& aFileName)
<a name="l00202"></a>00202 {
<a name="l00203"></a>00203 TPtr8 imageInMemory = LoadImageIntoMemoryLC(aFileName);
<a name="l00204"></a>00204
<a name="l00205"></a>00205 <span class="comment">// Create the decoder, passing the image buffer. The image is recognised by the</span>
<a name="l00206"></a>00206 <span class="comment">// Image Conversion Library, an appropriate codec plugin loaded and the image</span>
<a name="l00207"></a>00207 <span class="comment">// headers parsed.</span>
<a name="l00208"></a>00208 <span class="comment">// If the image is not recognised or valid then the call will leave with an error</span>
<a name="l00209"></a>00209 CJPEGExifDecoder* exifDecoder = <span class="keyword">static_cast<</span>CJPEGExifDecoder*<span class="keyword">></span>(CJPEGExifDecoder::DataNewL(iFs, imageInMemory));
<a name="l00210"></a>00210 CleanupStack::PushL(exifDecoder);
<a name="l00211"></a>00211
<a name="l00212"></a>00212 exifDecoder->SetImageTypeL(CImageDecoder::EImageTypeThumbnail);
<a name="l00213"></a>00213
<a name="l00214"></a>00214 CFbsBitmap* destBitmap = <span class="keyword">new</span>(ELeave) CFbsBitmap();
<a name="l00215"></a>00215 CleanupStack::PushL(destBitmap);
<a name="l00216"></a>00216
<a name="l00217"></a>00217 <span class="comment">// Since the image header has been parsed we can find out the image size and</span>
<a name="l00218"></a>00218 <span class="comment">// can create the bitmap to match the display mode we wish to support</span>
<a name="l00219"></a>00219 <span class="keyword">const</span> TFrameInfo& frameInfo = exifDecoder->FrameInfo(<a class="code" href="iclexample_8h.html#8e6dac40318753daf806f44078888a2e">KFirstFrame</a>);
<a name="l00220"></a>00220 User::LeaveIfError(destBitmap->Create(frameInfo.iOverallSizeInPixels, frameInfo.iFrameDisplayMode));
<a name="l00221"></a>00221
<a name="l00222"></a>00222 <span class="comment">// See Note 1</span>
<a name="l00223"></a>00223 <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="l00224"></a>00224
<a name="l00225"></a>00225 <span class="comment">// Convert the image</span>
<a name="l00226"></a>00226 exifDecoder->Convert(&activeListener->iStatus, *destBitmap, <a class="code" href="iclexample_8h.html#8e6dac40318753daf806f44078888a2e">KFirstFrame</a>);
<a name="l00227"></a>00227
<a name="l00228"></a>00228 <span class="comment">// See Note 2</span>
<a name="l00229"></a>00229 CActiveScheduler::Start();
<a name="l00230"></a>00230 User::LeaveIfError(activeListener->iStatus.Int()); <span class="comment">// access and decode to thumbnail complete either display the image or report an error.</span>
<a name="l00231"></a>00231
<a name="l00232"></a>00232 <span class="comment">// Just verifying the presence of some output. The image can also be displayed instead.</span>
<a name="l00233"></a>00233
<a name="l00234"></a>00234 _LIT(KOutputFile, <span class="stringliteral">"c:\\ICLExample\\DecodedDescThumbnail.mbm"</span>);
<a name="l00235"></a>00235 destBitmap->Save(KOutputFile); <span class="comment">// Ignore return code.</span>
<a name="l00236"></a>00236
<a name="l00237"></a>00237 CleanupStack::PopAndDestroy(4); <span class="comment">// activeListener, destBitmap, exifDecoder and imageInMemory</span>
<a name="l00238"></a>00238 }
<a name="l00239"></a>00239
<a name="l00240"></a>00240
<a name="l00254"></a><a class="code" href="class_c_icl_example.html#c007f7bd46e86ce6bfbf87137ef0a064">00254</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#c007f7bd46e86ce6bfbf87137ef0a064">CIclExample::AccessExifMetadataL</a>(<span class="keyword">const</span> TDesC& aFileName)
<a name="l00255"></a>00255 {
<a name="l00256"></a>00256 <span class="comment">// Create the decoder, passing the image buffer. The image is recognised by the</span>
<a name="l00257"></a>00257 <span class="comment">// Image Conversion Library, an appropriate codec plugin loaded and the image</span>
<a name="l00258"></a>00258 <span class="comment">// headers parsed.</span>
<a name="l00259"></a>00259 <span class="comment">// If the image is not recognised or valid then the call will leave with an error</span>
<a name="l00260"></a>00260 CJPEGExifDecoder* exifDecoder = <span class="keyword">static_cast<</span>CJPEGExifDecoder*<span class="keyword">></span>(CJPEGExifDecoder::FileNewL(iFs, aFileName));
<a name="l00261"></a>00261 CleanupStack::PushL(exifDecoder);
<a name="l00262"></a>00262
<a name="l00263"></a>00263 <span class="comment">// Create a MExifMetadata object and Initializes to metadata associated with the CJPEGExifDecoder</span>
<a name="l00264"></a>00264 MExifMetadata* metaData = exifDecoder->ExifMetadata();
<a name="l00265"></a>00265 <span class="keywordflow">if</span> (metaData != NULL)
<a name="l00266"></a>00266 {
<a name="l00267"></a>00267 <span class="comment">// Create a TExifReaderUtility object and pass the metadata to read it</span>
<a name="l00268"></a>00268 TExifReaderUtility reader(metaData);
<a name="l00269"></a>00269
<a name="l00270"></a>00270 HBufC8* buffer8Bit = NULL;
<a name="l00271"></a>00271 User::LeaveIfError(reader.GetImageDescription(buffer8Bit));
<a name="l00272"></a>00272
<a name="l00273"></a>00273 <span class="comment">// NOTE: Image metadata buffer can be used here</span>
<a name="l00274"></a>00274
<a name="l00275"></a>00275 <span class="keyword">delete</span> buffer8Bit;
<a name="l00276"></a>00276 }
<a name="l00277"></a>00277
<a name="l00278"></a>00278 CleanupStack::PopAndDestroy(exifDecoder);
<a name="l00279"></a>00279 }
<a name="l00280"></a>00280
<a name="l00281"></a>00281
<a name="l00298"></a><a class="code" href="class_c_icl_example.html#6046f80ebdc6a7f8e4ce23f31faef8a0">00298</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#6046f80ebdc6a7f8e4ce23f31faef8a0">CIclExample::DecodeTheThumbnailL</a>(<span class="keyword">const</span> TDesC& aFileName)
<a name="l00299"></a>00299 {
<a name="l00300"></a>00300 TPtr8 imageInMemory = LoadImageIntoMemoryLC(aFileName);
<a name="l00301"></a>00301
<a name="l00302"></a>00302 <span class="comment">// Create the decoder, passing the image buffer . The image is recognised by the</span>
<a name="l00303"></a>00303 <span class="comment">// Image Conversion Library, an appropriate codec plugin loaded and the image</span>
<a name="l00304"></a>00304 <span class="comment">// headers parsed.</span>
<a name="l00305"></a>00305 <span class="comment">// If the image is not recognised or valid then the call will leave with an error</span>
<a name="l00306"></a>00306 CImageDecoder* imageDecoder = CImageDecoder::DataNewL(iFs, imageInMemory);
<a name="l00307"></a>00307 CleanupStack::PushL(imageDecoder);
<a name="l00308"></a>00308
<a name="l00309"></a>00309 <span class="comment">// Set the image type to thumbnail to decode only the thumbnail part of the image</span>
<a name="l00310"></a>00310 imageDecoder->SetImageTypeL(CImageDecoder::EImageTypeThumbnail);
<a name="l00311"></a>00311
<a name="l00312"></a>00312 CFbsBitmap* destBitmap = <span class="keyword">new</span>(ELeave) CFbsBitmap();
<a name="l00313"></a>00313 CleanupStack::PushL(destBitmap);
<a name="l00314"></a>00314
<a name="l00315"></a>00315 <span class="comment">// Since the image header has been parsed we can find out the image size and</span>
<a name="l00316"></a>00316 <span class="comment">// can create the bitmap to match the display mode we wish to support.</span>
<a name="l00317"></a>00317 <span class="keyword">const</span> TFrameInfo& frameInfo = imageDecoder->FrameInfo(<a class="code" href="iclexample_8h.html#8e6dac40318753daf806f44078888a2e">KFirstFrame</a>);
<a name="l00318"></a>00318 User::LeaveIfError(destBitmap->Create(frameInfo.iOverallSizeInPixels, frameInfo.iFrameDisplayMode));
<a name="l00319"></a>00319
<a name="l00320"></a>00320 <span class="comment">// See Note 1</span>
<a name="l00321"></a>00321 <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="l00322"></a>00322
<a name="l00323"></a>00323 <span class="comment">// Convert the thumbnail part of the image</span>
<a name="l00324"></a>00324 imageDecoder->Convert(&activeListener->iStatus, *destBitmap);
<a name="l00325"></a>00325
<a name="l00326"></a>00326 <span class="comment">// See Note 2</span>
<a name="l00327"></a>00327 CActiveScheduler::Start();
<a name="l00328"></a>00328 User::LeaveIfError(activeListener->iStatus.Int()); <span class="comment">// decode complete either display the image or report an error.</span>
<a name="l00329"></a>00329
<a name="l00330"></a>00330 <span class="comment">// Just verifying the presence of some output. The image can also be displayed instead.</span>
<a name="l00331"></a>00331 _LIT(KOutputFile, <span class="stringliteral">"c:\\ICLExample\\DecodedBitmapWithThumbnail.mbm"</span>);
<a name="l00332"></a>00332 destBitmap->Save(KOutputFile);
<a name="l00333"></a>00333
<a name="l00334"></a>00334 CleanupStack::PopAndDestroy(4); <span class="comment">// activeListener, destBitmap, imageDecoder and imageInMemory</span>
<a name="l00335"></a>00335 }
<a name="l00336"></a>00336
<a name="l00337"></a>00337
<a name="l00351"></a><a class="code" href="class_c_icl_example.html#c0261a59e3225afd05e2c82c95d1fe58">00351</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#c0261a59e3225afd05e2c82c95d1fe58">CIclExample::DecodeUsingSepThreadL</a>(<span class="keyword">const</span> TDesC& aFileName)
<a name="l00352"></a>00352 {
<a name="l00353"></a>00353 TPtr8 imageInMemory = LoadImageIntoMemoryLC(aFileName);
<a name="l00354"></a>00354
<a name="l00355"></a>00355 <span class="comment">// Create the decoder, passing the image buffer and decoder option as EOptionAlwaysThread. The image is recognised by the</span>
<a name="l00356"></a>00356 <span class="comment">// Image Conversion Library, an appropriate codec plugin loaded and the image</span>
<a name="l00357"></a>00357 <span class="comment">// headers parsed.</span>
<a name="l00358"></a>00358 <span class="comment">// If the image is not recognised or valid then the call will leave with an error</span>
<a name="l00359"></a>00359 CImageDecoder* imageDecoder = CImageDecoder::DataNewL(iFs, imageInMemory, CImageDecoder::EOptionAlwaysThread);
<a name="l00360"></a>00360 CleanupStack::PushL(imageDecoder);
<a name="l00361"></a>00361
<a name="l00362"></a>00362 <span class="comment">// Since the image header has been parsed we can find out the image size and</span>
<a name="l00363"></a>00363 <span class="comment">// can create the bitmap to match the display mode we wish to support</span>
<a name="l00364"></a>00364 <span class="keyword">const</span> TFrameInfo& frameInfo = imageDecoder->FrameInfo(<a class="code" href="iclexample_8h.html#8e6dac40318753daf806f44078888a2e">KFirstFrame</a>);
<a name="l00365"></a>00365
<a name="l00366"></a>00366 CFbsBitmap* destBitmap = <span class="keyword">new</span>(ELeave) CFbsBitmap();
<a name="l00367"></a>00367 CleanupStack::PushL(destBitmap);
<a name="l00368"></a>00368 User::LeaveIfError(destBitmap->Create(frameInfo.iOverallSizeInPixels, frameInfo.iFrameDisplayMode));
<a name="l00369"></a>00369
<a name="l00370"></a>00370 <span class="comment">// See Note 1</span>
<a name="l00371"></a>00371 <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="l00372"></a>00372
<a name="l00373"></a>00373 <span class="comment">// Convert the image</span>
<a name="l00374"></a>00374 imageDecoder->Convert(&activeListener->iStatus, *destBitmap, <a class="code" href="iclexample_8h.html#8e6dac40318753daf806f44078888a2e">KFirstFrame</a>);
<a name="l00375"></a>00375
<a name="l00376"></a>00376 <span class="comment">// See Note 2</span>
<a name="l00377"></a>00377 CActiveScheduler::Start();
<a name="l00378"></a>00378 User::LeaveIfError(activeListener->iStatus.Int()); <span class="comment">// decode complete using separate thread either display the image or report an error.</span>
<a name="l00379"></a>00379
<a name="l00380"></a>00380 <span class="comment">// Just verifying the presence of some output. The image can also be displayed instead.</span>
<a name="l00381"></a>00381 _LIT(KOutputFile, <span class="stringliteral">"c:\\ICLExample\\DecodedBitmapsUsingSeparateThread.mbm"</span>);
<a name="l00382"></a>00382 destBitmap->Save(KOutputFile); <span class="comment">// Ignore return code.</span>
<a name="l00383"></a>00383
<a name="l00384"></a>00384 CleanupStack::PopAndDestroy(4); <span class="comment">// activeListener, destBitmap, imageDecoder and imageInMemory</span>
<a name="l00385"></a>00385 }
<a name="l00386"></a>00386
<a name="l00387"></a>00387
<a name="l00401"></a><a class="code" href="class_c_icl_example.html#516e94636add0b5553afd5ca9e6b0dac">00401</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#516e94636add0b5553afd5ca9e6b0dac">CIclExample::DecodeToHalfFourthAndEighthSizedBitmapL</a>(<span class="keyword">const</span> TDesC& aFileName)
<a name="l00402"></a>00402 {
<a name="l00403"></a>00403 TPtr8 imageInMemory = LoadImageIntoMemoryLC(aFileName);
<a name="l00404"></a>00404
<a name="l00405"></a>00405 <span class="comment">// Create the decoder, passing the image buffer. The image is recognised by the</span>
<a name="l00406"></a>00406 <span class="comment">// Image Conversion Library, an appropriate codec plugin loaded and the image</span>
<a name="l00407"></a>00407 <span class="comment">// headers parsed.</span>
<a name="l00408"></a>00408 <span class="comment">// If the image is not recognised or valid then the call will leave with an error</span>
<a name="l00409"></a>00409 CImageDecoder* imageDecoder = CImageDecoder::DataNewL(iFs, imageInMemory);
<a name="l00410"></a>00410 CleanupStack::PushL(imageDecoder);
<a name="l00411"></a>00411
<a name="l00412"></a>00412 <span class="comment">// Since the image header has been parsed we can find out the image size and</span>
<a name="l00413"></a>00413 <span class="comment">// can create the bitmap to match the display mode we wish to support</span>
<a name="l00414"></a>00414 <span class="keyword">const</span> TFrameInfo& frameInfo = imageDecoder->FrameInfo(<a class="code" href="iclexample_8h.html#8e6dac40318753daf806f44078888a2e">KFirstFrame</a>);
<a name="l00415"></a>00415
<a name="l00416"></a>00416 CFbsBitmap* destBitmap = <span class="keyword">new</span>(ELeave) CFbsBitmap();
<a name="l00417"></a>00417 CleanupStack::PushL(destBitmap);
<a name="l00418"></a>00418
<a name="l00419"></a>00419 <span class="comment">// Create a new TSize object which is half the size of original size</span>
<a name="l00420"></a>00420 <span class="comment">// and pass this size to the destination bitmap</span>
<a name="l00421"></a>00421 TSize halfSize;
<a name="l00422"></a>00422 TInt reductionFactor = 1; <span class="comment">// half size, but quarter (2) and eighth (3) size are possible too</span>
<a name="l00423"></a>00423 User::LeaveIfError(imageDecoder->ReducedSize(frameInfo.iOverallSizeInPixels, reductionFactor, halfSize));
<a name="l00424"></a>00424 User::LeaveIfError(destBitmap->Create(halfSize, frameInfo.iFrameDisplayMode));
<a name="l00425"></a>00425
<a name="l00426"></a>00426 <span class="comment">// See Note 1</span>
<a name="l00427"></a>00427 <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="l00428"></a>00428
<a name="l00429"></a>00429 <span class="comment">// Convert the image to half sized bitmap</span>
<a name="l00430"></a>00430 imageDecoder->Convert(&activeListener->iStatus, *destBitmap, <a class="code" href="iclexample_8h.html#8e6dac40318753daf806f44078888a2e">KFirstFrame</a>);
<a name="l00431"></a>00431
<a name="l00432"></a>00432 <span class="comment">// See Note 2</span>
<a name="l00433"></a>00433 CActiveScheduler::Start();
<a name="l00434"></a>00434 User::LeaveIfError(activeListener->iStatus.Int()); <span class="comment">// decode to half sized bitmap complete either display the image or report an error.</span>
<a name="l00435"></a>00435
<a name="l00436"></a>00436
<a name="l00437"></a>00437 <span class="comment">// Just verifying the presence of some output. The image can also be displayed instead.</span>
<a name="l00438"></a>00438 _LIT(KOutputFile, <span class="stringliteral">"c:\\ICLExample\\HalfSizeDecodedBitmap.mbm"</span>);
<a name="l00439"></a>00439 destBitmap->Save(KOutputFile);
<a name="l00440"></a>00440
<a name="l00441"></a>00441 CleanupStack::PopAndDestroy(4); <span class="comment">// activeListener, destBitmap, imageDecoder and imageInMemory</span>
<a name="l00442"></a>00442 }
<a name="l00443"></a>00443
<a name="l00444"></a>00444
<a name="l00458"></a><a class="code" href="class_c_icl_example.html#22e8c59d2313f074a3e29df89e20e05f">00458</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#22e8c59d2313f074a3e29df89e20e05f">CIclExample::DecodeUsingImageMaskL</a>(<span class="keyword">const</span> TDesC& aFileName)
<a name="l00459"></a>00459 {
<a name="l00460"></a>00460 TPtr8 imageInMemory = LoadImageIntoMemoryLC(aFileName);
<a name="l00461"></a>00461
<a name="l00462"></a>00462 <span class="comment">// Create the decoder, passing the image buffer. The image is recognised by the</span>
<a name="l00463"></a>00463 <span class="comment">// Image Conversion Library, an appropriate codec plugin loaded and the image</span>
<a name="l00464"></a>00464 <span class="comment">// headers parsed.</span>
<a name="l00465"></a>00465 <span class="comment">// If the image is not recognised or valid then the call will leave with an error</span>
<a name="l00466"></a>00466 CImageDecoder* imageDecoder = CImageDecoder::DataNewL(iFs, imageInMemory);
<a name="l00467"></a>00467 CleanupStack::PushL(imageDecoder);
<a name="l00468"></a>00468
<a name="l00469"></a>00469 <span class="comment">// Since the image header has been parsed we can find out the image size and</span>
<a name="l00470"></a>00470 <span class="comment">// can create the bitmap to match the display mode we wish to support</span>
<a name="l00471"></a>00471 <span class="comment">// for both destination bitmap and destination mask bitmap</span>
<a name="l00472"></a>00472 <span class="keyword">const</span> TFrameInfo& frameInfo = imageDecoder->FrameInfo(<a class="code" href="iclexample_8h.html#8e6dac40318753daf806f44078888a2e">KFirstFrame</a>);
<a name="l00473"></a>00473
<a name="l00474"></a>00474 CFbsBitmap* destBitmap = <span class="keyword">new</span>(ELeave) CFbsBitmap();
<a name="l00475"></a>00475 CleanupStack::PushL(destBitmap);
<a name="l00476"></a>00476 User::LeaveIfError(destBitmap->Create(frameInfo.iOverallSizeInPixels, frameInfo.iFrameDisplayMode));
<a name="l00477"></a>00477
<a name="l00478"></a>00478 <span class="comment">// See note 1.</span>
<a name="l00479"></a>00479 <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="l00480"></a>00480
<a name="l00481"></a>00481 <span class="keywordflow">if</span> (frameInfo.iFlags & TFrameInfo::ETransparencyPossible)
<a name="l00482"></a>00482 {
<a name="l00483"></a>00483 <span class="comment">// we can decode the mask</span>
<a name="l00484"></a>00484 CFbsBitmap* destBitmapMask = <span class="keyword">new</span>(ELeave) CFbsBitmap();
<a name="l00485"></a>00485 CleanupStack::PushL(destBitmapMask);
<a name="l00486"></a>00486
<a name="l00487"></a>00487 <span class="comment">// mask bitmap type depends on presence of alpha channel</span>
<a name="l00488"></a>00488 TDisplayMode bitmapMode = (frameInfo.iFlags & TFrameInfo::EAlphaChannel) ? EGray256 : EGray2;
<a name="l00489"></a>00489 User::LeaveIfError(destBitmapMask->Create(frameInfo.iOverallSizeInPixels, bitmapMode));
<a name="l00490"></a>00490
<a name="l00491"></a>00491 <span class="comment">// Decoding the frame and separating the mask from the main image.</span>
<a name="l00492"></a>00492 imageDecoder->Convert(&activeListener->iStatus, *destBitmap, *destBitmapMask, <a class="code" href="iclexample_8h.html#8e6dac40318753daf806f44078888a2e">KFirstFrame</a>);
<a name="l00493"></a>00493
<a name="l00494"></a>00494 <span class="comment">// See Note 2</span>
<a name="l00495"></a>00495 CActiveScheduler::Start();
<a name="l00496"></a>00496 User::LeaveIfError(activeListener->iStatus.Int()); <span class="comment">// decode complete using an image mask either display the image or report an error.</span>
<a name="l00497"></a>00497
<a name="l00498"></a>00498 <span class="comment">// Just verifying the presence of some output. The image can also be displayed instead.</span>
<a name="l00499"></a>00499 _LIT(KOutputFile1, <span class="stringliteral">"c:\\ICLExample\\DecodedBitmapMask.mbm"</span>);
<a name="l00500"></a>00500 _LIT(KOutputFile2, <span class="stringliteral">"c:\\ICLExample\\DecodedBitmapWithMask.mbm"</span>);
<a name="l00501"></a>00501 destBitmapMask->Save(KOutputFile1); <span class="comment">// Ignore error code.</span>
<a name="l00502"></a>00502 destBitmap->Save(KOutputFile2); <span class="comment">// Ignore error code.</span>
<a name="l00503"></a>00503
<a name="l00504"></a>00504 CleanupStack::PopAndDestroy(); <span class="comment">// destBitmapMask</span>
<a name="l00505"></a>00505 }
<a name="l00506"></a>00506 <span class="keywordflow">else</span>
<a name="l00507"></a>00507 {
<a name="l00508"></a>00508 <span class="comment">// no mask available - in this case we decode without mask</span>
<a name="l00509"></a>00509 <span class="comment">// Convert the image</span>
<a name="l00510"></a>00510 imageDecoder->Convert(&activeListener->iStatus, *destBitmap, <a class="code" href="iclexample_8h.html#8e6dac40318753daf806f44078888a2e">KFirstFrame</a>);
<a name="l00511"></a>00511
<a name="l00512"></a>00512 <span class="comment">// See Note 2</span>
<a name="l00513"></a>00513 CActiveScheduler::Start();
<a name="l00514"></a>00514 User::LeaveIfError(activeListener->iStatus.Int()); <span class="comment">// decode complete without using mask either display the image or report an error.</span>
<a name="l00515"></a>00515
<a name="l00516"></a>00516 <span class="comment">// Just verifying the presence of some output. The image can also be displayed instead.</span>
<a name="l00517"></a>00517 _LIT(KOutputFile, <span class="stringliteral">"c:\\ICLExample\\DecodedBitmapWithoutMask.mbm"</span>);
<a name="l00518"></a>00518 destBitmap->Save(KOutputFile); <span class="comment">// Ignore error code.</span>
<a name="l00519"></a>00519 }
<a name="l00520"></a>00520
<a name="l00521"></a>00521 CleanupStack::PopAndDestroy(4); <span class="comment">// activeListener, destBitmap, imageDecoder and imageInMemory</span>
<a name="l00522"></a>00522 }
<a name="l00523"></a>00523
<a name="l00524"></a>00524
<a name="l00539"></a><a class="code" href="class_c_icl_example.html#c12f19a867f25b00a89c80548f357074">00539</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#c12f19a867f25b00a89c80548f357074">CIclExample::MultiFrameImageDecodeL</a>(<span class="keyword">const</span> TDesC& aFileName)
<a name="l00540"></a>00540 {
<a name="l00541"></a>00541 TPtr8 imageInMemory = LoadImageIntoMemoryLC(aFileName);
<a name="l00542"></a>00542
<a name="l00543"></a>00543 <span class="comment">// Create the decoder, passing the image buffer. The image is recognised by the</span>
<a name="l00544"></a>00544 <span class="comment">// Image Conversion Library, an appropriate codec plugin loaded and the image</span>
<a name="l00545"></a>00545 <span class="comment">// headers parsed.</span>
<a name="l00546"></a>00546 <span class="comment">// If the image is not recognised or valid then the call will leave with an error</span>
<a name="l00547"></a>00547 CImageDecoder* imageDecoder = CImageDecoder::DataNewL(iFs, imageInMemory);
<a name="l00548"></a>00548 CleanupStack::PushL(imageDecoder);
<a name="l00549"></a>00549
<a name="l00550"></a>00550 <span class="comment">// Since the image header has been parsed we can find out the image size and</span>
<a name="l00551"></a>00551 <span class="comment">// can create the bitmap to match the display mode we wish to support</span>
<a name="l00552"></a>00552 <span class="keyword">const</span> TFrameInfo& frameInfo = imageDecoder->FrameInfo(<a class="code" href="iclexample_8h.html#8e6dac40318753daf806f44078888a2e">KFirstFrame</a>);
<a name="l00553"></a>00553
<a name="l00554"></a>00554 CFbsBitmap* destBitmap = <span class="keyword">new</span>(ELeave) CFbsBitmap();
<a name="l00555"></a>00555 CleanupStack::PushL(destBitmap);
<a name="l00556"></a>00556 User::LeaveIfError(destBitmap->Create(frameInfo.iOverallSizeInPixels, frameInfo.iFrameDisplayMode));
<a name="l00557"></a>00557
<a name="l00558"></a>00558 <span class="comment">// Read the number of frames</span>
<a name="l00559"></a>00559 <span class="keyword">const</span> TInt KNumberOfFrames = imageDecoder->FrameCount();
<a name="l00560"></a>00560
<a name="l00561"></a>00561 <span class="comment">// See Note 1</span>
<a name="l00562"></a>00562 <a class="code" href="class_c_active_listener.html">CActiveListener</a>* activeListener = <a class="code" href="class_c_active_listener.html#ba7c784e9f4a6fdc1e4df64ad959e5b6">CActiveListener::NewLC</a>();
<a name="l00563"></a>00563
<a name="l00564"></a>00564 <span class="comment">// Iterate all the frames and display them</span>
<a name="l00565"></a>00565 <span class="keywordflow">for</span> (TInt frameNumber = 0; frameNumber < KNumberOfFrames; ++frameNumber)
<a name="l00566"></a>00566 {
<a name="l00567"></a>00567 <span class="comment">// See Note 1</span>
<a name="l00568"></a>00568 activeListener-><a class="code" href="class_c_active_listener.html#5172079a442a39dc9e411cb7ff4b9bad">Initialize</a>();
<a name="l00569"></a>00569
<a name="l00570"></a>00570 <span class="comment">// Convert the multi frame image</span>
<a name="l00571"></a>00571 imageDecoder->Convert(&activeListener->iStatus, *destBitmap, frameNumber);
<a name="l00572"></a>00572
<a name="l00573"></a>00573 <span class="comment">// See Note 2</span>
<a name="l00574"></a>00574 CActiveScheduler::Start();
<a name="l00575"></a>00575 User::LeaveIfError(activeListener->iStatus.Int()); <span class="comment">// decode complete using multiframe image either display the image or report an error.</span>
<a name="l00576"></a>00576
<a name="l00577"></a>00577 <span class="comment">// DoSomethingWithTheFrame(destBitmap);</span>
<a name="l00578"></a>00578 }
<a name="l00579"></a>00579
<a name="l00580"></a>00580 _LIT(KOutputFile, <span class="stringliteral">"c:\\ICLExample\\DecodedMultiFrameBitmap.mbm"</span>);
<a name="l00581"></a>00581 destBitmap->Save(KOutputFile);
<a name="l00582"></a>00582
<a name="l00583"></a>00583 CleanupStack::PopAndDestroy(4); <span class="comment">// activeListener, destBitmap, imageDecoder and imageInMemory</span>
<a name="l00584"></a>00584 }
<a name="l00585"></a>00585
<a name="l00586"></a>00586
<a name="l00600"></a><a class="code" href="class_c_icl_example.html#0d936aabff37b0f9f29dcc2216525bca">00600</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#0d936aabff37b0f9f29dcc2216525bca">CIclExample::DecodeUsingContinueConvertL</a>(<span class="keyword">const</span> TDesC& aFileName)
<a name="l00601"></a>00601 {
<a name="l00602"></a>00602 <span class="keyword">const</span> TInt <a class="code" href="sharedmem_8h.html#1006d8c149c84d799a92f7de74ebcf4c">KChunkSize</a> = 32;
<a name="l00603"></a>00603
<a name="l00604"></a>00604 <span class="comment">// Open the file containing the image and get the size.</span>
<a name="l00605"></a>00605 <span class="comment">// Create a TPtr object to wrap the pointer to the buffer.</span>
<a name="l00606"></a>00606 RFile file;
<a name="l00607"></a>00607 TUint flags = EFileShareReadersOnly | EFileStream | EFileRead;
<a name="l00608"></a>00608 User::LeaveIfError(file.Open(iFs, aFileName, flags));
<a name="l00609"></a>00609 CleanupClosePushL(file);
<a name="l00610"></a>00610
<a name="l00611"></a>00611 <span class="comment">// Read the file size</span>
<a name="l00612"></a>00612 TInt fileSize = 0;
<a name="l00613"></a>00613 User::LeaveIfError(file.Size(fileSize));
<a name="l00614"></a>00614
<a name="l00615"></a>00615 <span class="comment">// Allocate the buffer for the file read in chunks</span>
<a name="l00616"></a>00616 HBufC8* buffer = HBufC8::NewLC(KChunkSize);
<a name="l00617"></a>00617 TPtr8 bufferPtr(buffer->Des());
<a name="l00618"></a>00618
<a name="l00619"></a>00619 <span class="comment">// Read the first chunk from the file</span>
<a name="l00620"></a>00620 User::LeaveIfError(file.Read(bufferPtr, KChunkSize));
<a name="l00621"></a>00621
<a name="l00622"></a>00622 <span class="comment">// Create the decoder passing the File Server session and attempt to open the decoder</span>
<a name="l00623"></a>00623 CBufferedImageDecoder* decoder = CBufferedImageDecoder::NewL(iFs);
<a name="l00624"></a>00624 CleanupStack::PushL(decoder);
<a name="l00625"></a>00625
<a name="l00626"></a>00626 <span class="comment">// The image is recognised by the Image Conversion Library, an appropriate codec plugin loaded and</span>
<a name="l00627"></a>00627 <span class="comment">// the image headers parsed.</span>
<a name="l00628"></a>00628
<a name="l00629"></a>00629 decoder->OpenL(bufferPtr);
<a name="l00630"></a>00630 <span class="keywordflow">while</span> (!decoder->ValidDecoder())
<a name="l00631"></a>00631 {
<a name="l00632"></a>00632 User::LeaveIfError(file.Read(bufferPtr, KChunkSize));
<a name="l00633"></a>00633 <span class="keywordflow">if</span>(0 == bufferPtr.Length() )
<a name="l00634"></a>00634 {<span class="comment">//no more bytes read from file. so end of file reached.</span>
<a name="l00635"></a>00635 <span class="comment">// image is corrupted as header processing is incomplete</span>
<a name="l00636"></a>00636 _LIT(KErrMsg,<span class="stringliteral">"Error: image corrupted. Processing will stop\n"</span>);
<a name="l00637"></a>00637 iConsole->Printf(KErrMsg);
<a name="l00638"></a>00638 User::Leave(KErrCorrupt);
<a name="l00639"></a>00639 }
<a name="l00640"></a>00640 decoder->AppendDataL(bufferPtr);
<a name="l00641"></a>00641 decoder->ContinueOpenL();
<a name="l00642"></a>00642 }
<a name="l00643"></a>00643 <span class="comment">// Make sure the header has been fully processed.</span>
<a name="l00644"></a>00644 <span class="keywordflow">while</span> (!decoder->IsImageHeaderProcessingComplete())
<a name="l00645"></a>00645 {
<a name="l00646"></a>00646 User::LeaveIfError(file.Read(bufferPtr, KChunkSize));
<a name="l00647"></a>00647 <span class="keywordflow">if</span>(0 == bufferPtr.Length())
<a name="l00648"></a>00648 {<span class="comment">//no more bytes read from file. so end of file reached.</span>
<a name="l00649"></a>00649 <span class="keywordflow">break</span>;
<a name="l00650"></a>00650 }
<a name="l00651"></a>00651 decoder->AppendDataL(bufferPtr);
<a name="l00652"></a>00652
<a name="l00653"></a>00653 }
<a name="l00654"></a>00654
<a name="l00655"></a>00655 <span class="comment">// Create the destination bitmap</span>
<a name="l00656"></a>00656 <span class="keyword">const</span> TFrameInfo frameInfo = decoder->FrameInfo(<a class="code" href="iclexample_8h.html#8e6dac40318753daf806f44078888a2e">KFirstFrame</a>);
<a name="l00657"></a>00657
<a name="l00658"></a>00658 CFbsBitmap* bitmap = <span class="keyword">new</span> (ELeave) CFbsBitmap();
<a name="l00659"></a>00659 CleanupStack::PushL(bitmap);
<a name="l00660"></a>00660
<a name="l00661"></a>00661 User::LeaveIfError(bitmap->Create(frameInfo.iOverallSizeInPixels, frameInfo.iFrameDisplayMode));
<a name="l00662"></a>00662
<a name="l00663"></a>00663 <span class="comment">// Convert the image (first frame) using Convert() function for the first piece of code</span>
<a name="l00664"></a>00664 <span class="comment">// and ContinueConvert() function for the remaining piece of code</span>
<a name="l00665"></a>00665 <span class="comment">// Feed the image data piece by piece into decoder while the error code is KErrUnderflow</span>
<a name="l00666"></a>00666 <span class="comment">// until it becomes KErrNone (or any other system error code).</span>
<a name="l00667"></a>00667 TInt err = KErrNone;
<a name="l00668"></a>00668 <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="l00669"></a>00669 decoder->Convert(&activeListener->iStatus, *bitmap, <a class="code" href="iclexample_8h.html#8e6dac40318753daf806f44078888a2e">KFirstFrame</a>);
<a name="l00670"></a>00670 CActiveScheduler::Start();
<a name="l00671"></a>00671
<a name="l00672"></a>00672 <span class="keywordflow">while</span> ((err = activeListener->iStatus.Int()) == KErrUnderflow)
<a name="l00673"></a>00673 {
<a name="l00674"></a>00674 <span class="keywordflow">if</span> ((err != KErrNone) && (err != KErrUnderflow))
<a name="l00675"></a>00675 {
<a name="l00676"></a>00676 User::Leave(err);
<a name="l00677"></a>00677 }
<a name="l00678"></a>00678
<a name="l00679"></a>00679 User::LeaveIfError(file.Read(bufferPtr, KChunkSize));
<a name="l00680"></a>00680 <span class="keywordflow">if</span>(0 == bufferPtr.Length())
<a name="l00681"></a>00681 {<span class="comment">//no more bytes read from file. so end of file reached.</span>
<a name="l00682"></a>00682 <span class="keywordflow">break</span>;
<a name="l00683"></a>00683 }
<a name="l00684"></a>00684 decoder->AppendDataL(bufferPtr);
<a name="l00685"></a>00685 activeListener-><a class="code" href="class_c_active_listener.html#5172079a442a39dc9e411cb7ff4b9bad">Initialize</a>();
<a name="l00686"></a>00686 decoder->ContinueConvert(&activeListener->iStatus);
<a name="l00687"></a>00687 CActiveScheduler::Start();
<a name="l00688"></a>00688 }
<a name="l00689"></a>00689
<a name="l00690"></a>00690 <span class="comment">// Just verifying the presence of some output. The image can also be displayed instead.</span>
<a name="l00691"></a>00691 _LIT(KOutputFile, <span class="stringliteral">"c:\\ICLExample\\DecodedBitmapWithContinueConvert.mbm"</span>);
<a name="l00692"></a>00692 bitmap->Save(KOutputFile);
<a name="l00693"></a>00693
<a name="l00694"></a>00694 CleanupStack::PopAndDestroy(5); <span class="comment">// file, buffer, decoder, bitmap and activeListener</span>
<a name="l00695"></a>00695 }
<a name="l00696"></a>00696
<a name="l00697"></a>00697
<a name="l00709"></a><a class="code" href="class_c_icl_example.html#34bbe8a8211f9087de9f44c0df5a5651">00709</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#34bbe8a8211f9087de9f44c0df5a5651">CIclExample::DisplayingImageCommentsL</a>(<span class="keyword">const</span> TDesC& aFileName)
<a name="l00710"></a>00710 {
<a name="l00711"></a>00711 TInt numberOfImageComments;
<a name="l00712"></a>00712
<a name="l00713"></a>00713 TPtr8 imageInMemory = LoadImageIntoMemoryLC(aFileName);
<a name="l00714"></a>00714
<a name="l00715"></a>00715 <span class="comment">// Create the decoder, passing the image buffer. The image is recognised by the</span>
<a name="l00716"></a>00716 <span class="comment">// Image Conversion Library, an appropriate codec plugin loaded and the image</span>
<a name="l00717"></a>00717 <span class="comment">// headers parsed.</span>
<a name="l00718"></a>00718 <span class="comment">// If the image is not recognised or valid then the call will leave with an error</span>
<a name="l00719"></a>00719 CImageDecoder* imageDecoder = CImageDecoder::DataNewL(iFs, imageInMemory);
<a name="l00720"></a>00720 CleanupStack::PushL(imageDecoder);
<a name="l00721"></a>00721
<a name="l00722"></a>00722 <span class="comment">// Count the number of image comments attached to the specified image</span>
<a name="l00723"></a>00723 numberOfImageComments = imageDecoder->NumberOfImageComments();
<a name="l00724"></a>00724
<a name="l00725"></a>00725 <span class="keywordflow">for</span> (TInt commentNumber = 0; commentNumber < numberOfImageComments; ++commentNumber)
<a name="l00726"></a>00726 {
<a name="l00727"></a>00727 HBufC* imageComment = imageDecoder->ImageCommentL(commentNumber);
<a name="l00728"></a>00728 CleanupStack::PushL(imageComment);
<a name="l00729"></a>00729
<a name="l00730"></a>00730 TPtrC commentPtr = imageComment->Des();
<a name="l00731"></a>00731
<a name="l00732"></a>00732 <span class="comment">// Decoded image comments can be displayed here</span>
<a name="l00733"></a>00733 CleanupStack::PopAndDestroy(imageComment);
<a name="l00734"></a>00734 }
<a name="l00735"></a>00735
<a name="l00736"></a>00736 CleanupStack::PopAndDestroy(2); <span class="comment">// imageDecoder and imageInMemory</span>
<a name="l00737"></a>00737 }
<a name="l00738"></a>00738
<a name="l00739"></a>00739
<a name="l00751"></a><a class="code" href="class_c_icl_example.html#1845f7f61a5ff996982e129c509940b4">00751</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#1845f7f61a5ff996982e129c509940b4">CIclExample::DisplayingFrameCommentsL</a>(<span class="keyword">const</span> TDesC& aFileName)
<a name="l00752"></a>00752 {
<a name="l00753"></a>00753 TInt numberOfComments = 0;
<a name="l00754"></a>00754
<a name="l00755"></a>00755 TPtr8 imageInMemory = LoadImageIntoMemoryLC(aFileName);
<a name="l00756"></a>00756
<a name="l00757"></a>00757 <span class="comment">// Create the decoder, passing the image buffer. The image is recognised by the</span>
<a name="l00758"></a>00758 <span class="comment">// Image Conversion Library, an appropriate codec plugin loaded and the image</span>
<a name="l00759"></a>00759 <span class="comment">// headers parsed.</span>
<a name="l00760"></a>00760 <span class="comment">// If the image is not recognised or valid then the call will leave with an error</span>
<a name="l00761"></a>00761 CImageDecoder* imageDecoder = CImageDecoder::DataNewL(iFs, imageInMemory);
<a name="l00762"></a>00762 CleanupStack::PushL(imageDecoder);
<a name="l00763"></a>00763
<a name="l00764"></a>00764 <span class="keywordflow">for</span> (TInt frameNumber = 0; frameNumber < imageDecoder->FrameCount(); ++frameNumber)
<a name="l00765"></a>00765 {
<a name="l00766"></a>00766 <span class="comment">// Count the number of frame comments</span>
<a name="l00767"></a>00767 numberOfComments = imageDecoder->NumberOfFrameComments(frameNumber);
<a name="l00768"></a>00768
<a name="l00769"></a>00769 <span class="keywordflow">for</span> (TInt commentNumber = 0; commentNumber < numberOfComments; ++commentNumber)
<a name="l00770"></a>00770 {
<a name="l00771"></a>00771 HBufC* frameComment = imageDecoder->FrameCommentL(frameNumber, commentNumber);
<a name="l00772"></a>00772 CleanupStack::PushL(frameComment);
<a name="l00773"></a>00773
<a name="l00774"></a>00774 TPtrC commentPtr = frameComment->Des();
<a name="l00775"></a>00775
<a name="l00776"></a>00776 <span class="comment">// Decoded frame comments can be displayed here</span>
<a name="l00777"></a>00777
<a name="l00778"></a>00778 CleanupStack::PopAndDestroy(frameComment);
<a name="l00779"></a>00779 }
<a name="l00780"></a>00780 }
<a name="l00781"></a>00781
<a name="l00782"></a>00782 CleanupStack::PopAndDestroy(2); <span class="comment">// imageDecoder and imageInMemory</span>
<a name="l00783"></a>00783 }
<a name="l00784"></a>00784
<a name="l00785"></a>00785
<a name="l00798"></a><a class="code" href="class_c_icl_example.html#f2d1182373eada0e38611d2f4a150402">00798</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#f2d1182373eada0e38611d2f4a150402">CIclExample::GettingMimeTypeOfSourceDescriptorL</a>(<span class="keyword">const</span> TDesC& aFileName)
<a name="l00799"></a>00799 {
<a name="l00800"></a>00800 TBuf8<128> theMimeType;
<a name="l00801"></a>00801
<a name="l00802"></a>00802 TPtr8 imageInMemory = LoadImageIntoMemoryLC(aFileName);
<a name="l00803"></a>00803
<a name="l00804"></a>00804 <span class="comment">// Call GetMimeTypeDataL() function of CImageDecoder to get the mime type of specified file</span>
<a name="l00805"></a>00805 CImageDecoder::GetMimeTypeDataL(imageInMemory, theMimeType);
<a name="l00806"></a>00806
<a name="l00807"></a>00807 <span class="comment">// Create the decoder, passing the image buffer. The image is recognised by the</span>
<a name="l00808"></a>00808 <span class="comment">// Image Conversion Library, an appropriate codec plugin loaded and the image</span>
<a name="l00809"></a>00809 <span class="comment">// headers parsed.</span>
<a name="l00810"></a>00810 <span class="comment">// If the image is not recognised or valid then the call will leave with an error</span>
<a name="l00811"></a>00811 CImageDecoder* imageDecoder = CImageDecoder::DataNewL(iFs, imageInMemory, theMimeType);
<a name="l00812"></a>00812 CleanupStack::PushL(imageDecoder);
<a name="l00813"></a>00813
<a name="l00814"></a>00814 <span class="comment">// Decoded image mime can be displayed here after convert operation.</span>
<a name="l00815"></a>00815
<a name="l00816"></a>00816 CleanupStack::PopAndDestroy(2); <span class="comment">// imageDecoder and imageInMemory</span>
<a name="l00817"></a>00817 }
<a name="l00818"></a>00818
<a name="l00819"></a>00819
<a name="l00831"></a><a class="code" href="class_c_icl_example.html#65106c28709a5afee5bdfcd263901f1d">00831</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#65106c28709a5afee5bdfcd263901f1d">CIclExample::GettingMimeTypeOfSourceFileL</a>(<span class="keyword">const</span> TDesC& aFileName)
<a name="l00832"></a>00832 {
<a name="l00833"></a>00833 TBuf8<128> theMimeType;
<a name="l00834"></a>00834
<a name="l00835"></a>00835 <span class="comment">// Call GetMimeTypeFileL() function of CImageDecoderGet to get the mime type of source file</span>
<a name="l00836"></a>00836 CImageDecoder::GetMimeTypeFileL(iFs, aFileName, theMimeType);
<a name="l00837"></a>00837
<a name="l00838"></a>00838 <span class="comment">// Create the decoder, passing the filename and mime type. The image is recognised by the</span>
<a name="l00839"></a>00839 <span class="comment">// Image Conversion Library, an appropriate codec plugin loaded and the image</span>
<a name="l00840"></a>00840 <span class="comment">// headers parsed.</span>
<a name="l00841"></a>00841 <span class="comment">// If the image is not recognised or valid then the call will leave with an error</span>
<a name="l00842"></a>00842 CImageDecoder* imageDecoder = CImageDecoder::FileNewL(iFs, aFileName, theMimeType);
<a name="l00843"></a>00843 CleanupStack::PushL(imageDecoder);
<a name="l00844"></a>00844
<a name="l00845"></a>00845 <span class="comment">// Decoded image mime can be displayed here after convert operation</span>
<a name="l00846"></a>00846
<a name="l00847"></a>00847 CleanupStack::PopAndDestroy(imageDecoder);
<a name="l00848"></a>00848 }
<a name="l00849"></a>00849
<a name="l00850"></a>00850
<a name="l00859"></a><a class="code" href="class_c_icl_example.html#36e3a8ae84f3813e028dee1ad6e9bc3e">00859</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#36e3a8ae84f3813e028dee1ad6e9bc3e">CIclExample::LoadPluginByUidL</a>(<span class="keyword">const</span> TDesC& aFileName, TUid aCodecUid)
<a name="l00860"></a>00860 {
<a name="l00861"></a>00861 <span class="comment">// create the decoder, passing the filename. The image is recognised by the</span>
<a name="l00862"></a>00862 <span class="comment">// Image Conversion Library, an appropriate codec plugin loaded and the image</span>
<a name="l00863"></a>00863 <span class="comment">// headers parsed according to Uid.</span>
<a name="l00864"></a>00864 <span class="comment">// If the image is not recognised or valid then the call will leave with an error</span>
<a name="l00865"></a>00865 CImageDecoder* imageDecoder = NULL;
<a name="l00866"></a>00866
<a name="l00867"></a>00867 imageDecoder = CImageDecoder::FileNewL(iFs, aFileName, CImageDecoder::EOptionNone, aCodecUid);
<a name="l00868"></a>00868 CleanupStack::PushL(imageDecoder);
<a name="l00869"></a>00869
<a name="l00870"></a>00870 <span class="comment">// Decoder can be used here</span>
<a name="l00871"></a>00871
<a name="l00872"></a>00872 CleanupStack::PopAndDestroy(imageDecoder);
<a name="l00873"></a>00873 }
<a name="l00874"></a>00874
<a name="l00875"></a>00875
<a name="l00891"></a><a class="code" href="class_c_icl_example.html#01c633fc627eeddf9446eafa62b0b0e6">00891</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#01c633fc627eeddf9446eafa62b0b0e6">CIclExample::DecodeWithRotateL</a>(<span class="keyword">const</span> TDesC& aFileName)
<a name="l00892"></a>00892 {
<a name="l00893"></a>00893 TPtr8 imageInMemory = LoadImageIntoMemoryLC(aFileName);
<a name="l00894"></a>00894
<a name="l00895"></a>00895 <span class="comment">// create the decoder, passing in the image memory. The image is recognised by the</span>
<a name="l00896"></a>00896 <span class="comment">// Image Conversion Library, an appropriate codec plugin loaded and the image</span>
<a name="l00897"></a>00897 <span class="comment">// headers parsed.</span>
<a name="l00898"></a>00898 <span class="comment">// If the image is not recognised or valid then the call will leave with an error</span>
<a name="l00899"></a>00899 CImageDecoder* imageDecoder = CImageDecoder::DataNewL(iFs, imageInMemory);
<a name="l00900"></a>00900 CleanupStack::PushL(imageDecoder);
<a name="l00901"></a>00901
<a name="l00902"></a>00902 <span class="comment">// Since the image header has been parsed we can find out the image size and can create</span>
<a name="l00903"></a>00903 <span class="comment">// the bitmap to match the display mode we wish to support.</span>
<a name="l00904"></a>00904 <span class="keyword">const</span> TFrameInfo& frameInfo = imageDecoder->FrameInfo(<a class="code" href="iclexample_8h.html#8e6dac40318753daf806f44078888a2e">KFirstFrame</a>);
<a name="l00905"></a>00905
<a name="l00906"></a>00906 CFbsBitmap* destBitmap = <span class="keyword">new</span>(ELeave) CFbsBitmap();
<a name="l00907"></a>00907 CleanupStack::PushL(destBitmap);
<a name="l00908"></a>00908
<a name="l00909"></a>00909 User::LeaveIfError(destBitmap->Create(frameInfo.iOverallSizeInPixels, frameInfo.iFrameDisplayMode));
<a name="l00910"></a>00910
<a name="l00911"></a>00911 <span class="comment">// See Note 1</span>
<a name="l00912"></a>00912 <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="l00913"></a>00913
<a name="l00914"></a>00914 <span class="comment">// Convert the image (first frame)</span>
<a name="l00915"></a>00915 imageDecoder->Convert(&activeListener->iStatus, *destBitmap, <a class="code" href="iclexample_8h.html#8e6dac40318753daf806f44078888a2e">KFirstFrame</a>);
<a name="l00916"></a>00916
<a name="l00917"></a>00917 <span class="comment">// See Note 2</span>
<a name="l00918"></a>00918 CActiveScheduler::Start();
<a name="l00919"></a>00919 User::LeaveIfError(activeListener->iStatus.Int()); <span class="comment">// decode complete either display the image or report an error.</span>
<a name="l00920"></a>00920
<a name="l00921"></a>00921 <span class="comment">// Create a CBitmapRotator object and push it on the cleanup stack</span>
<a name="l00922"></a>00922 CBitmapRotator* rotator = CBitmapRotator::NewL();
<a name="l00923"></a>00923 CleanupStack::PushL(rotator);
<a name="l00924"></a>00924
<a name="l00925"></a>00925 <span class="comment">// Rotate the bitmap through the specified angle</span>
<a name="l00926"></a>00926 activeListener->Initialize();
<a name="l00927"></a>00927 rotator->Rotate(&activeListener->iStatus, *destBitmap, CBitmapRotator::ERotation180DegreesClockwise);
<a name="l00928"></a>00928
<a name="l00929"></a>00929 <span class="comment">// See Note 2</span>
<a name="l00930"></a>00930 CActiveScheduler::Start();
<a name="l00931"></a>00931 User::LeaveIfError(activeListener->iStatus.Int()); <span class="comment">// rotate complete either display the image or report an error.</span>
<a name="l00932"></a>00932
<a name="l00933"></a>00933 <span class="comment">// Just verifying the presence of some output. The rotated image can also be displayed instead.</span>
<a name="l00934"></a>00934 _LIT(KOutputFile, <span class="stringliteral">"c:\\ICLExample\\RotatedBitmap.mbm"</span>);
<a name="l00935"></a>00935 destBitmap->Save(KOutputFile);
<a name="l00936"></a>00936
<a name="l00937"></a>00937 CleanupStack::PopAndDestroy(5); <span class="comment">// rotator, destBitmap, activeListener, imageDecoder and imageInMemory</span>
<a name="l00938"></a>00938 }
<a name="l00939"></a>00939
<a name="l00940"></a>00940 <span class="comment">//</span>
<a name="l00941"></a>00941 <span class="comment">// Illustrates how to clip and rotate images during decode.</span>
<a name="l00942"></a>00942 <span class="comment">//</span>
<a name="l00943"></a><a class="code" href="icldecodeexample_8cpp.html#0923aa2ae422ac23016215f3f602e34b">00943</a> <span class="keyword">const</span> <a class="code" href="struct_t_decode_params.html">TDecodeParams</a> <a class="code" href="icldecodeexample_8cpp.html#0923aa2ae422ac23016215f3f602e34b">KDecodeParams</a>[] =
<a name="l00944"></a>00944 { <span class="comment">// Clip - R90 - MirrorV - Scale - Output</span>
<a name="l00945"></a>00945 {EFalse, EFalse, EFalse, 1, _S(<span class="stringliteral">"\\ICLExample\\NormalFull.mbm"</span>)},
<a name="l00946"></a>00946 {ETrue, EFalse, EFalse, -1, _S(<span class="stringliteral">"\\ICLExample\\ClipFull.mbm"</span>)},
<a name="l00947"></a>00947 {ETrue, EFalse, ETrue, -2, _S(<span class="stringliteral">"\\ICLExample\\MirrorVertClipQuarter.mbm"</span>)},
<a name="l00948"></a>00948 {ETrue, ETrue, ETrue, -3, _S(<span class="stringliteral">"\\ICLExample\\Rotate90MirrorVertClipEighth.mbm"</span>)},
<a name="l00949"></a>00949 {EFalse, ETrue, EFalse, 1, _S(<span class="stringliteral">"\\ICLExample\\Rotate90Full.mbm"</span>)},
<a name="l00950"></a>00950 {EFalse, EFalse, EFalse, 1, NULL}
<a name="l00951"></a>00951 };
<a name="l00952"></a>00952
<a name="l00953"></a><a class="code" href="class_c_icl_example.html#6cca2915ce3512e8ed842715449b8ce4">00953</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#6cca2915ce3512e8ed842715449b8ce4">CIclExample::ClipAndRotateDuringDecodeL</a>()
<a name="l00954"></a>00954 {
<a name="l00955"></a>00955 TRect clipRect(TPoint(50, 65), TSize(170, 160)); <span class="comment">// The wheel in thumbimage.jpg</span>
<a name="l00956"></a>00956 TSize finalSize;
<a name="l00957"></a>00957
<a name="l00958"></a>00958 <span class="comment">// The decoder must support *all* the operations we're going to perform.</span>
<a name="l00959"></a>00959 TUint options = CImageDecoder::EOptionExtRotation |
<a name="l00960"></a>00960 CImageDecoder::EOptionExtMirrorHorizontalAxis |
<a name="l00961"></a>00961 CImageDecoder::EOptionExtCrop |
<a name="l00962"></a>00962 CImageDecoder::EOptionExtScaling;
<a name="l00963"></a>00963
<a name="l00964"></a>00964 <span class="comment">// The installed decoders must support *all* the operations requested in aOptions.</span>
<a name="l00965"></a>00965 _LIT(KInputFile, <span class="stringliteral">"c:\\ICLExample\\thumbimage.jpg"</span>);
<a name="l00966"></a>00966 CImageDecoder* decoder = CImageDecoder::FileNewL(iFs, KInputFile, static_cast<CImageDecoder::TOptions>(options));
<a name="l00967"></a>00967 CleanupStack::PushL(decoder);
<a name="l00968"></a>00968
<a name="l00969"></a>00969 <span class="keyword">const</span> TFrameInfo& frameInfo = decoder->FrameInfo(<a class="code" href="iclexample_8h.html#8e6dac40318753daf806f44078888a2e">KFirstFrame</a>);
<a name="l00970"></a>00970 CFbsBitmap* output = <span class="keyword">new</span>(ELeave) CFbsBitmap();
<a name="l00971"></a>00971 CleanupStack::PushL(output);
<a name="l00972"></a>00972 User::LeaveIfError(output->Create(frameInfo.iFrameSizeInPixels, frameInfo.iFrameDisplayMode));
<a name="l00973"></a>00973
<a name="l00974"></a>00974 <a class="code" href="class_c_active_listener.html">CActiveListener</a>* ao = <a class="code" href="class_c_active_listener.html#ba7c784e9f4a6fdc1e4df64ad959e5b6">CActiveListener::NewLC</a>();
<a name="l00975"></a>00975
<a name="l00976"></a>00976 TImageConvOperation* operation = decoder->OperationL();
<a name="l00977"></a>00977 TImageConvScaler* scaler = decoder->ScalerL();
<a name="l00978"></a>00978
<a name="l00979"></a>00979 TInt i = 0;
<a name="l00980"></a>00980 <span class="keywordflow">while</span> (KDecodeParams[i].iOutputFile != NULL)
<a name="l00981"></a>00981 {
<a name="l00982"></a>00982 <span class="keyword">const</span> <a class="code" href="struct_t_decode_params.html">TDecodeParams</a>& params = KDecodeParams[i++];
<a name="l00983"></a>00983
<a name="l00984"></a>00984 operation->ClearOperationStack();
<a name="l00985"></a>00985 <span class="keywordflow">if</span> (params.<a class="code" href="struct_t_decode_params.html#27e4da988c56da1dcd2ff5d7789ed3ee">iRotate90</a>)
<a name="l00986"></a>00986 {
<a name="l00987"></a>00987 operation->AddOperationL(TImageConvOperation::ERotation90DegreesClockwise);
<a name="l00988"></a>00988 }
<a name="l00989"></a>00989
<a name="l00990"></a>00990 <span class="keywordflow">if</span> (params.<a class="code" href="struct_t_decode_params.html#985b0d0662bc0b64240acc0a8d5ad934">iMirrorVerticalAxis</a>)
<a name="l00991"></a>00991 {
<a name="l00992"></a>00992 operation->AddOperationL(TImageConvOperation::EMirrorVerticalAxis);
<a name="l00993"></a>00993 }
<a name="l00994"></a>00994
<a name="l00995"></a>00995 <span class="comment">// Some codecs may have a limit on the amount of scaling they can do.</span>
<a name="l00996"></a>00996 scaler->SetScalingL(params.<a class="code" href="struct_t_decode_params.html#17a453d7f83232a6e80f021216070ee5">iScalingCoeff</a>, TImageConvScaler::EMaximumQuality);
<a name="l00997"></a>00997
<a name="l00998"></a>00998 <span class="comment">// Setting the clipping rect to NULL will decode the whole image.</span>
<a name="l00999"></a>00999 decoder->SetClippingRectL(params.<a class="code" href="struct_t_decode_params.html#6478708f102d567241211f6dbd3860b4">iClip</a> ? &clipRect : NULL);
<a name="l01000"></a>01000 User::LeaveIfError(decoder->GetDestinationSize(finalSize, <a class="code" href="iclexample_8h.html#8e6dac40318753daf806f44078888a2e">KFirstFrame</a>));
<a name="l01001"></a>01001 User::LeaveIfError(output->Resize(finalSize));
<a name="l01002"></a>01002
<a name="l01003"></a>01003 <span class="comment">// See Note 1</span>
<a name="l01004"></a>01004 ao->Initialize();
<a name="l01005"></a>01005 decoder->Convert(&ao->iStatus, *output, <a class="code" href="iclexample_8h.html#8e6dac40318753daf806f44078888a2e">KFirstFrame</a>);
<a name="l01006"></a>01006
<a name="l01007"></a>01007 <span class="comment">// See Note 2</span>
<a name="l01008"></a>01008 CActiveScheduler::Start();
<a name="l01009"></a>01009
<a name="l01010"></a>01010 TPtrC outputFile(params.<a class="code" href="struct_t_decode_params.html#814a2d0477db8dba0cf1ca6cb7fb3e17">iOutputFile</a>);
<a name="l01011"></a>01011 output->Save(outputFile); <span class="comment">// Ignore error code.</span>
<a name="l01012"></a>01012 }
<a name="l01013"></a>01013
<a name="l01014"></a>01014 CleanupStack::PopAndDestroy(3); <span class="comment">// decoder, output, ao</span>
<a name="l01015"></a>01015 }
<a name="l01016"></a>01016
<a name="l01017"></a>01017
<a name="l01033"></a><a class="code" href="class_c_icl_example.html#4093d046baf1ea4eeb4cfceca4ff0ac4">01033</a> <span class="keywordtype">void</span> <a class="code" href="class_c_icl_example.html#4093d046baf1ea4eeb4cfceca4ff0ac4">CIclExample::BlockStreamDecodeAndEncodeYuvFrameL</a>(<span class="keyword">const</span> TDesC& aSrcFileName, <span class="keyword">const</span> TDesC& aDestFileName)
<a name="l01034"></a>01034 {
<a name="l01035"></a>01035 <span class="keyword">const</span> TInt KNumBlocksToGet = 1;
<a name="l01036"></a>01036 RChunk chunk;
<a name="l01037"></a>01037 TSize streamBlockSizeInPixels;
<a name="l01038"></a>01038 TEncodeStreamCaps encodeCaps;
<a name="l01039"></a>01039 TDecodeStreamCaps decodeCaps;
<a name="l01040"></a>01040 TInt numBlocksRead = 0;
<a name="l01041"></a>01041 TBool haveMoreBlocks = ETrue;
<a name="l01042"></a>01042 <span class="comment">// Create the decoder, passing the filename. The image is recognised by the </span>
<a name="l01043"></a>01043 <span class="comment">// Image Conversion Library, an appropriate codec plugin loaded and the image headers parsed.</span>
<a name="l01044"></a>01044 <span class="comment">// If the image is not recognised or valid then the call will leave with an error</span>
<a name="l01045"></a>01045 CImageDecoder* jpegImageDecoder = CImageDecoder::FileNewL(iFs, aSrcFileName);
<a name="l01046"></a>01046 CleanupStack::PushL(jpegImageDecoder);
<a name="l01047"></a>01047
<a name="l01048"></a>01048 <span class="comment">// Create the encoder, passing the filename. The image is recognised by the </span>
<a name="l01049"></a>01049 <span class="comment">// Image Conversion Library, an appropriate codec plugin loaded and the image headers parsed.</span>
<a name="l01050"></a>01050 <span class="comment">// If the image is not recognised or valid then the call will leave with an error </span>
<a name="l01051"></a>01051 CImageEncoder* jpegImageEncoder = CImageEncoder::FileNewL(iFs, aDestFileName, CImageEncoder::EOptionNone, KImageTypeJPGUid);
<a name="l01052"></a>01052 CleanupStack::PushL(jpegImageEncoder);
<a name="l01053"></a>01053
<a name="l01054"></a>01054 <span class="comment">// Create encode & decode Block Streamer</span>
<a name="l01055"></a>01055 TImageConvStreamedDecode* streamDecode = jpegImageDecoder->BlockStreamerL();
<a name="l01056"></a>01056 TImageConvStreamedEncode* streamEncode = jpegImageEncoder->BlockStreamerL();
<a name="l01057"></a>01057
<a name="l01058"></a>01058 TFrameInfo frameInfo = jpegImageDecoder->FrameInfo();
<a name="l01059"></a>01059 TSize frameSizeInPixels(frameInfo.iOverallSizeInPixels); <span class="comment">//NOTE: For JPEG codec, the image used for stream decoding and encoding should be multiple of MCU(Minimum coded unit)</span>
<a name="l01060"></a>01060
<a name="l01061"></a>01061 <span class="comment">// Get decoder capabilities</span>
<a name="l01062"></a>01062 TDecodeStreamCaps::TNavigation decodeNavigation = TDecodeStreamCaps::ENavigationSequentialForward;
<a name="l01063"></a>01063
<a name="l01064"></a>01064 TUid KFormat;
<a name="l01065"></a>01065 RArray<TUid> supportedFormats;
<a name="l01066"></a>01066 CleanupClosePushL(supportedFormats);
<a name="l01067"></a>01067
<a name="l01068"></a>01068 streamDecode->GetSupportedFormatsL(supportedFormats, KFormat);
<a name="l01069"></a>01069
<a name="l01070"></a>01070 streamDecode->GetCapabilities(KFormat, <a class="code" href="iclexample_8h.html#8e6dac40318753daf806f44078888a2e">KFirstFrame</a>, decodeCaps);
<a name="l01071"></a>01071
<a name="l01072"></a>01072 <span class="comment">// Check that the decoder supports sequential navigation capabilities</span>
<a name="l01073"></a>01073 <span class="keywordflow">if</span>(decodeCaps.Navigation() & TDecodeStreamCaps::ENavigationSequentialForward != decodeNavigation)
<a name="l01074"></a>01074 {
<a name="l01075"></a>01075 User::Leave(KErrNotSupported);
<a name="l01076"></a>01076 }
<a name="l01077"></a>01077
<a name="l01078"></a>01078 <span class="comment">// set the navigation mode initialize decoder frame</span>
<a name="l01079"></a>01079 streamDecode->InitFrameL(KFormat, <a class="code" href="iclexample_8h.html#8e6dac40318753daf806f44078888a2e">KFirstFrame</a>, decodeNavigation);
<a name="l01080"></a>01080
<a name="l01081"></a>01081 <span class="comment">// Get decoder capabilities</span>
<a name="l01082"></a>01082 streamEncode->GetCapabilities(KFormat,encodeCaps);
<a name="l01083"></a>01083
<a name="l01084"></a>01084 TSize blockSizeInPixels = encodeCaps.MinBlockSizeInPixels();
<a name="l01085"></a>01085
<a name="l01086"></a>01086 <span class="comment">// initialize encoder frame</span>
<a name="l01087"></a>01087 TEncodeStreamCaps::TNavigation encodeNavigation = TEncodeStreamCaps::ENavigationSequentialForward;
<a name="l01088"></a>01088
<a name="l01089"></a>01089 <span class="comment">// Check that the encoder supports sequential navigation capabilities</span>
<a name="l01090"></a>01090 <span class="keywordflow">if</span>(encodeCaps.Navigation() & TEncodeStreamCaps::ENavigationSequentialForward != encodeNavigation)
<a name="l01091"></a>01091 {
<a name="l01092"></a>01092 User::Leave(KErrNotSupported);
<a name="l01093"></a>01093 }
<a name="l01094"></a>01094
<a name="l01095"></a>01095 <span class="comment">// create frame image data</span>
<a name="l01096"></a>01096 CFrameImageData* frameImageData = CFrameImageData::NewL();
<a name="l01097"></a>01097 CleanupStack::PushL(frameImageData);
<a name="l01098"></a>01098
<a name="l01099"></a>01099 TJpegImageData* jpegImageData = <span class="keyword">new</span>(ELeave) TJpegImageData;
<a name="l01100"></a>01100 frameImageData->AppendImageData(jpegImageData);
<a name="l01101"></a>01101
<a name="l01102"></a>01102 streamEncode->InitFrameL(KFormat, <a class="code" href="iclexample_8h.html#8e6dac40318753daf806f44078888a2e">KFirstFrame</a>, frameSizeInPixels, blockSizeInPixels, encodeNavigation, NULL);
<a name="l01103"></a>01103
<a name="l01104"></a>01104 <span class="comment">// When decoding, the buffer wrapped by the destination CImageFrame must be large enough to contain the decoded frame.</span>
<a name="l01105"></a>01105 <span class="comment">// GetBufferSize() should be used to obtain the buffer size required for a particular decode</span>
<a name="l01106"></a>01106 TInt imageSizeInBytes = streamDecode->GetBufferSize(KFormat, streamBlockSizeInPixels, KNumBlocksToGet);
<a name="l01107"></a>01107
<a name="l01108"></a>01108 User::LeaveIfError(chunk.CreateLocal(imageSizeInBytes, imageSizeInBytes));
<a name="l01109"></a>01109 CleanupClosePushL(chunk);
<a name="l01110"></a>01110
<a name="l01111"></a>01111 <span class="comment">// Create an empty imageframe </span>
<a name="l01112"></a>01112 CImageFrame* imageFrame = CImageFrame::NewL(&chunk, imageSizeInBytes, 0);
<a name="l01113"></a>01113 CleanupStack::PushL(imageFrame);
<a name="l01114"></a>01114
<a name="l01115"></a>01115 imageFrame->SetFrameSizeInPixels(streamBlockSizeInPixels);
<a name="l01116"></a>01116
<a name="l01117"></a>01117 <span class="keywordflow">while</span>(haveMoreBlocks)
<a name="l01118"></a>01118 {
<a name="l01119"></a>01119 <span class="comment">// See Note 1</span>
<a name="l01120"></a>01120 <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="l01121"></a>01121
<a name="l01122"></a>01122 <span class="comment">// decoder get blocks</span>
<a name="l01123"></a>01123 streamDecode->GetNextBlocks(activeListener->iStatus, *imageFrame, KNumBlocksToGet, numBlocksRead, haveMoreBlocks);
<a name="l01124"></a>01124
<a name="l01125"></a>01125 <span class="comment">// See Note 2</span>
<a name="l01126"></a>01126 CActiveScheduler::Start();
<a name="l01127"></a>01127 User::LeaveIfError(activeListener->iStatus.Int()); <span class="comment">// decode complete.</span>
<a name="l01128"></a>01128
<a name="l01129"></a>01129 <span class="comment">// NOTE: Apply effects like adjust brightness etc in low memory conditions by use of streaming to the image frame block</span>
<a name="l01130"></a>01130
<a name="l01131"></a>01131 <span class="comment">// See Note 1</span>
<a name="l01132"></a>01132 activeListener-><a class="code" href="class_c_active_listener.html#5172079a442a39dc9e411cb7ff4b9bad">Initialize</a>();
<a name="l01133"></a>01133
<a name="l01134"></a>01134 <span class="comment">// encoder append blocks</span>
<a name="l01135"></a>01135 streamEncode->AppendBlocks(activeListener->iStatus, *imageFrame, numBlocksRead);
<a name="l01136"></a>01136
<a name="l01137"></a>01137 <span class="comment">// See Note 2</span>
<a name="l01138"></a>01138 CActiveScheduler::Start();
<a name="l01139"></a>01139 User::LeaveIfError(activeListener->iStatus.Int()); <span class="comment">// encode complete.</span>
<a name="l01140"></a>01140
<a name="l01141"></a>01141 CleanupStack::PopAndDestroy(activeListener); <span class="comment">// encodeActiveListener </span>
<a name="l01142"></a>01142 }
<a name="l01143"></a>01143
<a name="l01144"></a>01144 CleanupStack::PopAndDestroy(6, jpegImageDecoder); <span class="comment">// imageFrame, chunk, supportedFormats, jpegImageEncoder and jpegImageDecoder</span>
<a name="l01145"></a>01145 }
<a name="l01146"></a>01146
<a name="l01147"></a>01147
</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>