Symbian3/SDK/Source/GUID-E6692CDA-9E24-57AE-9BC2-14D68D6480C3.dita
changeset 7 51a74ef9ed63
parent 0 89d6a7a84779
equal deleted inserted replaced
6:43e37759235e 7:51a74ef9ed63
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept xml:lang="en" id="GUID-E6692CDA-9E24-57AE-9BC2-14D68D6480C3"><title> Enhanced Features for Encoder and Decoder Tutorial</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>This document gives you more information about the enhanced features for the encoder and the decoder during the bitmap transformation. </p> <section><title>Purpose</title> <p>The purpose of the enhanced features for encoder and decoder is to set various transformation operations during encoding and decoding, which gives faster and more resource friendly output. </p> <p><b>Required Background</b> </p> <p>The enhanced features for encoder and decoder are provided through Imaging Frameworks and Imaging plugins. </p> <p><b>Introduction</b> </p> <p>The enhanced features of the decoder are currently supported by the Symbian JPEG codec and PNG codec. The transformation features during the decoding are as follows: </p> <ul><li id="GUID-7FB92047-2217-580B-B201-EFCC9CA627B8"><p> <b>Clipping : </b>  </p> <p>A rectangular region of an image is chosen and it is clipped for decoding. The decoded output is either a native bitmap (<xref href="GUID-683A1D42-2764-3EB7-BD19-9E12559199AB.dita"><apiname>CFbsBitmap</apiname></xref>) or a pixel buffer (e.g YUV 4:2:2 frames). </p> </li> <li id="GUID-1C14DD15-3EE9-53F7-946B-B48FAA7C23CB"><p> <b> Rotation / Mirroring : </b>  </p> <p>The functionality in rotation are 90º increments, mirroring over the horizontal axis, mirroring over the vertical axis, and combination of these features. </p> </li> <li id="GUID-6E856862-0EE7-59EA-A354-CEA4C2C840F4"><p> <b>Scaling : </b>  </p> <p>In scaling only downscaling is supported during the decode operation. At present the supported scaling coefficients for an image are ½, ¼ or ⅛ of the original image size. </p> </li> </ul> <p>In transformation of an image during decode you can choose more than one operation. For example you can choose clipping and scaling, or clipping and rotation, or all the three combinations of clipping, scaling and rotation. </p> <p> <b>Note:-</b> When you want to clip and scale an image you need to follow this order: </p> <ul><li id="GUID-41626AF1-F425-5965-B238-F5B94A0EA627"><p>First you need to clip the image. </p> </li> <li id="GUID-056D21EA-6627-5FA6-848D-ED516C332CE6"><p>Then you can scale the image. </p> </li> </ul> <p>This order is defined because if you scale an image and do clipping the output will not be a resource friendly output. </p> <p>The enhanced feature of the encoder is currently supported by the Symbian JPEG codec and PNG codec. The transformation feature during the encoding is: </p> <ul><li id="GUID-667B9F91-729B-5B4B-B83D-B3EC4219E297"><p>Imaging Frameworks provides support for rotation and mirroring while encode bitmaps or YUV pixel data, contained in a memory descriptor, to the data format. </p> </li> </ul> <p><b>Setup and Configuration Requirements</b> </p> <p> <b>Setting up the right decoder</b>  </p> <p>In order to allow the decoder to advertise the extended operations (cropping, rotation, horizontal flipping and vertical flipping) use <xref href="GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4.dita#GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4/GUID-350DA091-17AB-3455-BE35-10A4ABA34706"><apiname>CImageDecoder::TOptions()</apiname></xref> and select the option for <xref href="GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4.dita#GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4/GUID-6DA07559-7DDC-32A9-9E09-D557348D46DE"><apiname>CImageDecoder::FileNewL()</apiname></xref> and <xref href="GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4.dita#GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4/GUID-00FB83E8-3759-32BE-B6E8-6F04EC60A909"><apiname>CImageDecoder::DataNewL()</apiname></xref>. The code below shows, how to set the right decoder and to set the options: </p> <codeblock id="GUID-8FD5579B-FBA4-585B-B52F-6C6C4D187E61" xml:space="preserve">
       
    13 
       
    14 TUint options =    CImageDecoder::EOptionExtRotation |
       
    15             CImageDecoder::EOptionExtMirrorHorizontalAxis |
       
    16             CImageDecoder::EOptionExtScaling;
       
    17 
       
    18 // The installed decoder supports all the operations requested.
       
    19 CImageDecoder* decoder = CImageDecoder::FileNewL(iFs, KInputFile, static_cast&lt;CImageDecoder::TOptions&gt;(options));
       
    20 
       
    21 // Ask for vertical flipping support.
       
    22 TImageConvOperation* operation = decoder-&gt;OperationL();
       
    23 if (operation)
       
    24     {
       
    25     // This gives KErrNotSupported because you have not asked for vertical flipping support.
       
    26     
       
    27 operation&gt;AddOperationL(TImageConvOperation::EMirrorVerticalAxis);
       
    28 }
       
    29 
       
    30 </codeblock> <p> <b>Setting up the right encoder</b>  </p> <p>In order to allow the encoder to advertise the extended operations (rotation, horizontal flipping and vertical flipping) use <xref href="GUID-737DA130-9A66-39E2-9E68-2E65F37E02C8.dita#GUID-737DA130-9A66-39E2-9E68-2E65F37E02C8/GUID-669FCF04-BC55-3CAF-93EB-C824E6C2BBB5"><apiname>CImageEncoder::TOptions()</apiname></xref> and select the option for <xref href="GUID-737DA130-9A66-39E2-9E68-2E65F37E02C8.dita#GUID-737DA130-9A66-39E2-9E68-2E65F37E02C8/GUID-1F25CC18-A8E4-3E1D-BA3D-F5F472E20CC0"><apiname>CImageEncoder::FileNewL()</apiname></xref> and <xref href="GUID-737DA130-9A66-39E2-9E68-2E65F37E02C8.dita#GUID-737DA130-9A66-39E2-9E68-2E65F37E02C8/GUID-51ECB4D3-5A87-35E7-82EB-DF2BAEAB2CAC"><apiname>CImageEncoder::DataNewL()</apiname></xref>. The code below shows, how to set the right encoder and to set the options: </p> <codeblock id="GUID-A01A75D6-F9A7-56A6-8C9F-1991D954F019" xml:space="preserve">
       
    31 
       
    32 TUint options =    CImageEncoder::EOptionExtRotation |
       
    33             CImageEncoder::EOptionExtMirrorHorizontalAxis 
       
    34             
       
    35 // The installed encoder supports all the operations requested.
       
    36 CImageEncoder* encoder = CImageEncoder::FileNewL(iFs, KInputFile, static_cast&lt;CImageEncoder::TOptions&gt;(options));
       
    37 
       
    38 // Ask for vertical flipping support.
       
    39 TImageConvOperation* operation = encoder-&gt;OperationL();
       
    40 if (operation)
       
    41     {
       
    42     // This gives KErrNotSupported because you have not asked for vertical flipping support.
       
    43     
       
    44 operation&gt;AddOperationL(TImageConvOperation::EMirrorVerticalAxis);
       
    45 }
       
    46 
       
    47 
       
    48 </codeblock> </section> <section><title>Using Enhanced Features for Encoder and Decoder </title> <p>The Following tasks are covered in this tutorial: </p> <ul><li id="GUID-FBC2B2C3-CD3A-5C88-8086-6F348FF709FA"><p><xref href="GUID-E6692CDA-9E24-57AE-9BC2-14D68D6480C3.dita#GUID-E6692CDA-9E24-57AE-9BC2-14D68D6480C3/GUID-B5E10863-7F1D-586B-B752-8A6C0081F022">How to set clipping / cropping operation during decode</xref>  </p> </li> <li id="GUID-AA02F1AC-FB21-5F70-8E72-71BC04B23557"><p><xref href="GUID-E6692CDA-9E24-57AE-9BC2-14D68D6480C3.dita#GUID-E6692CDA-9E24-57AE-9BC2-14D68D6480C3/GUID-D92FA64D-3ABF-5159-815A-06108FEE6A4E">How to set rotation / mirroring operation during decode</xref>  </p> </li> <li id="GUID-EA24348E-9C10-5147-9419-CD5540F8C9B8"><p><xref href="GUID-E6692CDA-9E24-57AE-9BC2-14D68D6480C3.dita#GUID-E6692CDA-9E24-57AE-9BC2-14D68D6480C3/GUID-3362463F-5B27-571B-AE8D-047BB544CF8D">How to set scaling operation during decode</xref>  </p> </li> <li id="GUID-9397F20A-79CA-5C3B-B251-A07741BCECC6"><p><xref href="GUID-E6692CDA-9E24-57AE-9BC2-14D68D6480C3.dita#GUID-E6692CDA-9E24-57AE-9BC2-14D68D6480C3/GUID-466BDF59-39CE-5631-9CE1-83615C3D92A1">How to set rotation / mirrioring opeartion during encode</xref>  </p> </li> </ul> <p id="GUID-B5E10863-7F1D-586B-B752-8A6C0081F022"><b>Basic Procedure For Clipping / Cropping Operation During Decode</b> </p> <p>The high level steps to set clipping / cropping operation during decode are as follows: </p> <ol id="GUID-9873ED31-6562-5E9B-89B6-05B00185AAD5"><li id="GUID-19A92D1F-49C6-5A6C-9D80-C75D35F37F52"><p>To create the decoder call <xref href="GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4.dita#GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4/GUID-6DA07559-7DDC-32A9-9E09-D557348D46DE"><apiname>CImageDecoder::FileNewL()</apiname></xref> or <xref href="GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4.dita#GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4/GUID-00FB83E8-3759-32BE-B6E8-6F04EC60A909"><apiname>CImageDecoder::DataNewL()</apiname></xref>, using the <codeph>TOptions</codeph> parameter of <codeph>EOptionExtCrop</codeph> to request the added functionality. </p> </li> <li id="GUID-6EF8781B-61F2-5421-B7AB-4890590D55B6"><p>In order to clip / crop the image call <xref href="GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4.dita#GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4/GUID-BA78485B-F2DB-31A5-A1B1-188A0F72C69D"><apiname>CImageDecoder::SetClippingRectL()</apiname></xref>. </p> </li> <li id="GUID-488BCB35-1F0C-5F3D-998C-8F3625BE97A9"><p>Then you need to obtain the size of the bitmap which holds the output of the operation being performed during decode, call the <xref href="GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4.dita#GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4/GUID-B8F6B2B5-F99B-3C4F-B2AD-0B378777D9B0"><apiname>CImageDecoder::GetDestinationSize()</apiname></xref> function. </p> </li> <li id="GUID-0ED79E97-DB79-5F31-A849-D60D9849262A"><p>Finally start the decoding operation by calling <xref href="GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4.dita#GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4/GUID-8118AC37-471E-3CB6-9F71-4E93507DDE57"><apiname>CImageDecoder::Convert()</apiname></xref> and use the <codeph>CFbsBitmap</codeph> obtained by <xref href="GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4.dita#GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4/GUID-B8F6B2B5-F99B-3C4F-B2AD-0B378777D9B0"><apiname>CImageDecoder::GetDestinationSize()</apiname></xref>. </p> </li> </ol> <p>For example code got to the session <xref href="GUID-E6692CDA-9E24-57AE-9BC2-14D68D6480C3.dita#GUID-E6692CDA-9E24-57AE-9BC2-14D68D6480C3/GUID-AC972EE1-E26C-5166-AC0A-5979ACA7FC73">Example Code During Decode</xref>. </p> <p id="GUID-3362463F-5B27-571B-AE8D-047BB544CF8D"><b>Basic Procedure For Scaling Operation During Decode</b> </p> <p>The high level steps to set scaling during decode are as follows: </p> <ol id="GUID-B084C5B1-2098-5802-8862-F6E5D54104D4"><li id="GUID-B099FFAB-F2B3-5A73-A2B5-5C7CAF6D02D1"><p>To create the decoder call <xref href="GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4.dita#GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4/GUID-6DA07559-7DDC-32A9-9E09-D557348D46DE"><apiname>CImageDecoder::FileNewL()</apiname></xref> or <xref href="GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4.dita#GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4/GUID-00FB83E8-3759-32BE-B6E8-6F04EC60A909"><apiname>CImageDecoder::DataNewL()</apiname></xref>. </p> <p> </p> </li> <li id="GUID-6529BA30-0BCC-5023-83CB-484A3CC909BE"><p>In order to scale the image call <xref href="GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4.dita#GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4/GUID-0C59067D-22EB-32E1-A4F6-A4335FD94B40"><apiname>CImageDecoder::ScalerL()</apiname></xref>. </p> </li> <li id="GUID-8D1C2920-E59B-5DAB-B08D-27A5A814DEF9"><p>Then you need to obtain the size of the bitmap which holds the output of the operation being performed during decode, call the <xref href="GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4.dita#GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4/GUID-B8F6B2B5-F99B-3C4F-B2AD-0B378777D9B0"><apiname>CImageDecoder::GetDestinationSize()</apiname></xref> function. </p> </li> <li id="GUID-AAF8C49D-8620-533E-AA22-055E8B505E98"><p>Finally start the decoding operation by calling <xref href="GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4.dita#GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4/GUID-8118AC37-471E-3CB6-9F71-4E93507DDE57"><apiname>CImageDecoder::Convert()</apiname></xref> and use the <codeph>CFbsBitmap</codeph> obtained by <xref href="GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4.dita#GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4/GUID-B8F6B2B5-F99B-3C4F-B2AD-0B378777D9B0"><apiname>CImageDecoder::GetDestinationSize()</apiname></xref>. </p> </li> </ol> <p>For example code got to the session <xref href="GUID-E6692CDA-9E24-57AE-9BC2-14D68D6480C3.dita#GUID-E6692CDA-9E24-57AE-9BC2-14D68D6480C3/GUID-AC972EE1-E26C-5166-AC0A-5979ACA7FC73">Example Code During Decode</xref>. </p> <p id="GUID-AC972EE1-E26C-5166-AC0A-5979ACA7FC73"><b>Example Code For Clipping And Scaling During Decode</b> </p> <p>The example below shows how to peform clipping and scaling during decode : </p> <codeblock id="GUID-75D99482-1116-505E-AC6A-7D740B29AC59" xml:space="preserve">
       
    49 
       
    50 void CIclExample::ClipScaleDuringDecode()
       
    51     {
       
    52     TRect clipRect(TPoint(50, 65), TSize(170, 160));    // The wheel in thumbimage.jpg
       
    53     TSize finalSize;
       
    54 
       
    55     // The decoder supports all the operations you are going to perform.
       
    56     TUint options =    CImageDecoder::EOptionExtRotation |
       
    57                     CImageDecoder::EOptionExtMirrorHorizontalAxis |
       
    58                     CImageDecoder::EOptionExtCrop |
       
    59                     CImageDecoder::EOptionExtScaling;
       
    60 
       
    61     // The installed decoder supports all the operations requested in options.
       
    62     _LIT(KInputFile, "c:\\ICLExample\\thumbimage.jpg");
       
    63     CImageDecoder* decoder = CImageDecoder::FileNewL(iFs, KInputFile, static_cast&lt;CImageDecoder::TOptions&gt;(options));
       
    64     CleanupStack::PushL(decoder);
       
    65 
       
    66     const TFrameInfo&amp; frameInfo = decoder-&gt;FrameInfo(KFirstFrame);
       
    67     CFbsBitmap* output = new(ELeave) CFbsBitmap();
       
    68     CleanupStack::PushL(output);
       
    69     User::LeaveIfError(output-&gt;Create(frameInfo.iFrameSizeInPixels, frameInfo.iFrameDisplayMode));
       
    70 
       
    71     CActiveListener* ao = CActiveListener::NewLC();
       
    72 
       
    73     TImageConvOperation* operation = decoder-&gt;OperationL();
       
    74     TImageConvScaler* scaler = decoder-&gt;ScalerL();
       
    75 
       
    76     TInt i = 0;
       
    77     while (KDecodeParams[i].iOutputFile != NULL)
       
    78         {
       
    79         const TDecodeParams&amp; params = KDecodeParams[i++];
       
    80 
       
    81         operation-&gt;ClearOperationStack();
       
    82         if (params.iRotate90)
       
    83             {
       
    84             operation-&gt;AddOperationL(TImageConvOperation::ERotation90DegreesClockwise);
       
    85             }
       
    86 
       
    87         if (params.iMirrorVerticalAxis)
       
    88             {
       
    89             operation-&gt;AddOperationL(TImageConvOperation::EMirrorVerticalAxis);
       
    90             }
       
    91 
       
    92         // Some codecs have a limit on the amount of scaling they can do.
       
    93         scaler-&gt;SetScalingL(params.iScalingCoeff, TImageConvScaler::EMaximumQuality);
       
    94 
       
    95         // Setting the clipping rect to NULL decodes the whole image.
       
    96         decoder-&gt;SetClippingRectL(params.iClip ? &amp;clipRect : NULL);
       
    97         User::LeaveIfError(decoder-&gt;GetDestinationSize(finalSize, KFirstFrame));
       
    98         User::LeaveIfError(output-&gt;Resize(finalSize));
       
    99 
       
   100         // See Note 1
       
   101         ao-&gt;Initialize();
       
   102         decoder-&gt;Convert(&amp;ao-&gt;iStatus, *output, KFirstFrame);
       
   103 
       
   104         // See Note 2
       
   105         CActiveScheduler::Start();
       
   106 
       
   107         TPtrC outputFile(params.iOutputFile);
       
   108         output-&gt;Save(outputFile);    // Ignore error code.
       
   109         }
       
   110 
       
   111     CleanupStack::PopAndDestroy(3); // decoder, output, ao
       
   112     }
       
   113 
       
   114 </codeblock> <p id="GUID-D92FA64D-3ABF-5159-815A-06108FEE6A4E"><b>Basic Procedure For Rotation / Mirroring Operation During Decode </b> </p> <p>The high level steps to set rotation / mirroring operation during decode are as follows: </p> <ol id="GUID-085C04F4-13C2-57F5-9C97-5171CB5ACC1E"><li id="GUID-FAE03E80-DD1E-5833-A10D-3775C8857E75"><p>To create the decoder call <xref href="GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4.dita#GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4/GUID-6DA07559-7DDC-32A9-9E09-D557348D46DE"><apiname>CImageDecoder::FileNewL()</apiname></xref> or <xref href="GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4.dita#GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4/GUID-00FB83E8-3759-32BE-B6E8-6F04EC60A909"><apiname>CImageDecoder::DataNewL()</apiname></xref>, using the <codeph>TOptions</codeph> parameter to request the desired functionality from the decoder. </p> </li> <li id="GUID-00393EB0-413B-59DC-BCD6-22511ECAB9EE"><p>In order to rotate the image call <xref href="GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4.dita#GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4/GUID-6DB314D3-4B0F-3DA7-98A5-43C6B121B810"><apiname>CImageDecoder::EOptionRotation()</apiname></xref> and for vertical mirroring call <xref href="GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4.dita#GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4/GUID-F0973A0F-AE96-3781-8D44-09019D87F8A3"><apiname>CImageDecoder::EOptionMirrorVerticalAxis()</apiname></xref>. </p> </li> <li id="GUID-E6E176CE-8DA8-57BE-9C6B-4B0C367D82FE"><p>Then you need to obtain the size of the bitmap which holds the output of the operation being performed during decode, call the <xref href="GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4.dita#GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4/GUID-B8F6B2B5-F99B-3C4F-B2AD-0B378777D9B0"><apiname>CImageDecoder::GetDestinationSize()</apiname></xref> function. </p> </li> <li id="GUID-758730D6-F264-5690-BD11-9575A0ABECD6"><p>Finally start the decoding operation by calling <xref href="GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4.dita#GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4/GUID-8118AC37-471E-3CB6-9F71-4E93507DDE57"><apiname>CImageDecoder::Convert()</apiname></xref> and use the <codeph>CFbsBitmap</codeph> obtained by <xref href="GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4.dita#GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4/GUID-B8F6B2B5-F99B-3C4F-B2AD-0B378777D9B0"><apiname>CImageDecoder::GetDestinationSize()</apiname></xref>. </p> </li> </ol> <p><b>Example </b> </p> <p>The example below shows how to peform clipping and rotation operation during decode: </p> <codeblock id="GUID-159E0452-66EA-5702-865C-5C7FC6EAD0B0" xml:space="preserve">
       
   115 
       
   116 void CIclExample::ClipAndRotateDuringDecode()
       
   117     {
       
   118     TRect clipRect(TPoint(50, 65), TSize(170, 160));    // The wheel in thumbimage.jpg
       
   119     TSize finalSize;
       
   120 
       
   121     // The decoder must support *all* the operations we're going to perform.
       
   122     TUint options =    CImageDecoder::EOptionExtRotation |
       
   123                     CImageDecoder::EOptionExtMirrorHorizontalAxis |
       
   124                     CImageDecoder::EOptionExtCrop |
       
   125                     CImageDecoder::EOptionExtScaling;
       
   126 
       
   127     // The installed decoders must support *all* the operations requested in aOptions.
       
   128     _LIT(KInputFile, "c:\\ICLExample\\thumbimage.jpg");
       
   129     CImageDecoder* decoder = CImageDecoder::FileNewL(iFs, KInputFile, static_cast&lt;CImageDecoder::TOptions&gt;(options));
       
   130     CleanupStack::PushL(decoder);
       
   131 
       
   132     const TFrameInfo&amp; frameInfo = decoder-&gt;FrameInfo(KFirstFrame);
       
   133     CFbsBitmap* output = new(ELeave) CFbsBitmap();
       
   134     CleanupStack::PushL(output);
       
   135     User::LeaveIfError(output-&gt;Create(frameInfo.iFrameSizeInPixels, frameInfo.iFrameDisplayMode));
       
   136 
       
   137     CActiveListener* ao = CActiveListener::NewLC();
       
   138 
       
   139     TImageConvOperation* operation = decoder-&gt;OperationL();
       
   140     TImageConvScaler* scaler = decoder-&gt;ScalerL();
       
   141 
       
   142     TInt i = 0;
       
   143     while (KDecodeParams[i].iOutputFile != NULL)
       
   144         {
       
   145         const TDecodeParams&amp; params = KDecodeParams[i++];
       
   146 
       
   147         operation-&gt;ClearOperationStack();
       
   148         if (params.iRotate90)
       
   149             {
       
   150             operation-&gt;AddOperationL(TImageConvOperation::ERotation90DegreesClockwise);
       
   151             }
       
   152 
       
   153         if (params.iMirrorVerticalAxis)
       
   154             {
       
   155             operation-&gt;AddOperationL(TImageConvOperation::EMirrorVerticalAxis);
       
   156             }
       
   157 
       
   158         // Some codecs may have a limit on the amount of scaling they can do.
       
   159         scaler-&gt;SetScalingL(params.iScalingCoeff, TImageConvScaler::EMaximumQuality);
       
   160 
       
   161         // Setting the clipping rect to NULL will decode the whole image.
       
   162         decoder-&gt;SetClippingRectL(params.iClip ? &amp;clipRect : NULL);
       
   163         User::LeaveIfError(decoder-&gt;GetDestinationSize(finalSize, KFirstFrame));
       
   164         User::LeaveIfError(output-&gt;Resize(finalSize));
       
   165 
       
   166         // See Note 1
       
   167         ao-&gt;Initialize();
       
   168         decoder-&gt;Convert(&amp;ao-&gt;iStatus, *output, KFirstFrame);
       
   169 
       
   170         // See Note 2
       
   171         CActiveScheduler::Start();
       
   172 
       
   173         TPtrC outputFile(params.iOutputFile);
       
   174         output-&gt;Save(outputFile);    // Ignore error code.
       
   175         }
       
   176 
       
   177     CleanupStack::PopAndDestroy(3); // decoder, output, ao
       
   178     }
       
   179 
       
   180 </codeblock> <p id="GUID-466BDF59-39CE-5631-9CE1-83615C3D92A1"><b>Basic Procedure For Rotation / Mirroring Operation During Encode</b> </p> <p>The high level steps to set rotation / mirroring during encode are as follows: </p> <ol id="GUID-15EB693F-5149-579B-83C6-20EC69AE3436"><li id="GUID-CC6F230B-1478-5E81-9D1C-48B917DC4E7B"><p>To create the encoder call <xref href="GUID-737DA130-9A66-39E2-9E68-2E65F37E02C8.dita#GUID-737DA130-9A66-39E2-9E68-2E65F37E02C8/GUID-1F25CC18-A8E4-3E1D-BA3D-F5F472E20CC0"><apiname>CImageEncoder::FileNewL()</apiname></xref> or <xref href="GUID-737DA130-9A66-39E2-9E68-2E65F37E02C8.dita#GUID-737DA130-9A66-39E2-9E68-2E65F37E02C8/GUID-51ECB4D3-5A87-35E7-82EB-DF2BAEAB2CAC"><apiname>CImageEncoder::DataNewL()</apiname></xref> and a bitmap holding the image which is to be encoded. </p> </li> <li id="GUID-85932A49-E067-518B-97F2-044A5F336DB7"><p>To request an operation extension call, <xref href="GUID-737DA130-9A66-39E2-9E68-2E65F37E02C8.dita#GUID-737DA130-9A66-39E2-9E68-2E65F37E02C8/GUID-DE7E1ACD-9619-3D42-B29F-4909DB491630"><apiname>CImageEncoder::OperationL()</apiname></xref>. If the extension is supported then a T class pointer is returned which gives access to the codec extension. <codeph>TImageConvOperation</codeph> has the extension function for rotation, and mirroring operation. </p> </li> <li id="GUID-BF922F17-05D3-5044-A5FE-A8B18BACC257"><p>To add multiple transformation operations call <xref href="GUID-8B339FC8-C565-3992-965D-DCE097110937.dita#GUID-8B339FC8-C565-3992-965D-DCE097110937/GUID-1A9C2AA5-F6F7-3BDE-839F-75C307B8B789"><apiname>TImageConvOperation::AddOperationL()</apiname></xref>. And to remove the transformation operation call <xref href="GUID-8B339FC8-C565-3992-965D-DCE097110937.dita#GUID-8B339FC8-C565-3992-965D-DCE097110937/GUID-49D6254B-9CCF-3623-AE1C-DF750632AC14"><apiname>TImageConvOperation::ClearOperationStack()</apiname></xref>. </p> <p>The rotations defined are: </p> <ul><li id="GUID-0CCFD0EE-9039-54C6-8D2E-68DB0C10C143"><p>Clockwise rotation 90 degrees. </p> </li> <li id="GUID-36E35E45-FE83-5A6B-BF73-12A9BA027C6C"><p>Clockwise rotation 180 degrees. </p> </li> <li id="GUID-454E31B3-CE8F-5786-B14D-4C8EB6B43F02"><p>Clockwise rotation 270 degrees. </p> </li> <li id="GUID-5F5B89F5-16B1-5025-B5B7-4445092521CB"><p>Horizontal axis mirroring. </p> </li> <li id="GUID-0DA0FD9A-FF1B-58E6-BD5B-6F98A350D741"><p>Vertical axis mirroring. </p> </li> </ul> </li> <li id="GUID-5FF035AB-DB18-5793-AC59-BA7084676585"><p>Finally call <xref href="GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4.dita#GUID-8F2953B2-E64E-3D8B-B30B-B35B373368D4/GUID-8118AC37-471E-3CB6-9F71-4E93507DDE57"><apiname>CImageDecoder::Convert()</apiname></xref> to decode the image. At the end of the <codeph>Convert()</codeph> call, the waiting application output in the main application is signalled and the bitmap or YUV image is encoded into a transformed <filepath>JPEG</filepath> based on the operations applied, assuming that no error is returned. </p> <p> <b>NOTE:</b> The transformation operations are only supported by the images which are multiples of Minimum Coded Unit (MCU). </p> </li> </ol> <p><b>Example </b> </p> <p>The example below shows how to peform rotation / mirrioring operation during encode: </p> <codeblock id="GUID-5A8C4894-018B-56F8-B33E-A8F7AEA413FC" xml:space="preserve">
       
   181 
       
   182 void CIclExample::EncodeBitmapToFileUsingOperationExtensionL(const TDesC&amp; aSrcFileName, const TDesC&amp; aDestFileName)
       
   183     {
       
   184     // Create the encoder, passing the filename. 
       
   185     // If the image is not recognised or valid then the call will leave with an error    
       
   186     CImageEncoder* jpegImageEncoder = CImageEncoder::FileNewL(iFs, aDestFileName, CImageEncoder::EOptionNone, KImageTypeJPGUid);
       
   187     CleanupStack::PushL(jpegImageEncoder);
       
   188     
       
   189     // Create a CFbsBitmap to store the source bitmap to encode
       
   190     CFbsBitmap* sourceBitmap = new(ELeave) CFbsBitmap;
       
   191     CleanupStack::PushL(sourceBitmap);
       
   192 
       
   193     User::LeaveIfError(sourceBitmap-&gt;Create(TSize(20,30), EColor16M));
       
   194     User::LeaveIfError(sourceBitmap-&gt;Load(aSrcFileName));
       
   195     
       
   196     // Create operation extension
       
   197     TImageConvOperation* operation = jpegImageEncoder-&gt;OperationL();
       
   198     
       
   199     // Add Rotate 90degrees operation
       
   200     operation-&gt;AddOperationL(TImageConvOperation::ERotation90DegreesClockwise); 
       
   201     //NOTE: Multiple operations can be added
       
   202     
       
   203     // See Note 1
       
   204     CActiveListener* activeListener = CreateAndInitializeActiveListenerLC();
       
   205 
       
   206     // Convert the image
       
   207     jpegImageEncoder-&gt;Convert(&amp;activeListener-&gt;iStatus, *sourceBitmap, NULL);
       
   208 
       
   209     // See Note 2
       
   210     CActiveScheduler::Start();
       
   211     User::LeaveIfError(activeListener-&gt;iStatus.Int());// encode complete either display the image or report an error.
       
   212     
       
   213     CleanupStack::PopAndDestroy(3); // jpegImageEncoder, sourceBitmap and activeListener
       
   214     }
       
   215 </codeblock> </section> </conbody><related-links><link href="GUID-88091838-03FC-550F-9A3D-DA70907EF955.dita"><linktext>Imaging Frameworks overview</linktext> </link> <link href="GUID-C0B39D73-0A3C-5289-A774-7BE590037404.dita"><linktext> Bitmap Transform Library
       
   216                 Overview</linktext> </link> <link href="GUID-9D6C086F-7621-5522-AE0B-81CBD5E99125.dita"><linktext>Bitmap Transform Library Guide</linktext> </link> <link href="GUID-E6692CDA-9E24-57AE-9BC2-14D68D6480C3.dita"><linktext>Enhanced Features for Encoder and
       
   217                 Decoder Tutorial</linktext> </link> </related-links></concept>