week 10 bug fix submission (SF PDK version): Bug 1892, Bug 1897, Bug 1319. Also 3 or 4 documents were found to contain code blocks with SFL, which has been fixed. Partial fix for broken links, links to Forum Nokia, and the 'Symbian platform' terminology issues.
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License
"Eclipse Public License v1.0" which accompanies this distribution,
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
Nokia Corporation - initial contribution.
Contributors:
-->
<!DOCTYPE concept
PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<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">
TUint options = CImageDecoder::EOptionExtRotation |
CImageDecoder::EOptionExtMirrorHorizontalAxis |
CImageDecoder::EOptionExtScaling;
// The installed decoder supports all the operations requested.
CImageDecoder* decoder = CImageDecoder::FileNewL(iFs, KInputFile, static_cast<CImageDecoder::TOptions>(options));
// Ask for vertical flipping support.
TImageConvOperation* operation = decoder->OperationL();
if (operation)
{
// This gives KErrNotSupported because you have not asked for vertical flipping support.
operation>AddOperationL(TImageConvOperation::EMirrorVerticalAxis);
}
</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">
TUint options = CImageEncoder::EOptionExtRotation |
CImageEncoder::EOptionExtMirrorHorizontalAxis
// The installed encoder supports all the operations requested.
CImageEncoder* encoder = CImageEncoder::FileNewL(iFs, KInputFile, static_cast<CImageEncoder::TOptions>(options));
// Ask for vertical flipping support.
TImageConvOperation* operation = encoder->OperationL();
if (operation)
{
// This gives KErrNotSupported because you have not asked for vertical flipping support.
operation>AddOperationL(TImageConvOperation::EMirrorVerticalAxis);
}
</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">
void CIclExample::ClipScaleDuringDecode()
{
TRect clipRect(TPoint(50, 65), TSize(170, 160)); // The wheel in thumbimage.jpg
TSize finalSize;
// The decoder supports all the operations you are going to perform.
TUint options = CImageDecoder::EOptionExtRotation |
CImageDecoder::EOptionExtMirrorHorizontalAxis |
CImageDecoder::EOptionExtCrop |
CImageDecoder::EOptionExtScaling;
// The installed decoder supports all the operations requested in options.
_LIT(KInputFile, "c:\\ICLExample\\thumbimage.jpg");
CImageDecoder* decoder = CImageDecoder::FileNewL(iFs, KInputFile, static_cast<CImageDecoder::TOptions>(options));
CleanupStack::PushL(decoder);
const TFrameInfo& frameInfo = decoder->FrameInfo(KFirstFrame);
CFbsBitmap* output = new(ELeave) CFbsBitmap();
CleanupStack::PushL(output);
User::LeaveIfError(output->Create(frameInfo.iFrameSizeInPixels, frameInfo.iFrameDisplayMode));
CActiveListener* ao = CActiveListener::NewLC();
TImageConvOperation* operation = decoder->OperationL();
TImageConvScaler* scaler = decoder->ScalerL();
TInt i = 0;
while (KDecodeParams[i].iOutputFile != NULL)
{
const TDecodeParams& params = KDecodeParams[i++];
operation->ClearOperationStack();
if (params.iRotate90)
{
operation->AddOperationL(TImageConvOperation::ERotation90DegreesClockwise);
}
if (params.iMirrorVerticalAxis)
{
operation->AddOperationL(TImageConvOperation::EMirrorVerticalAxis);
}
// Some codecs have a limit on the amount of scaling they can do.
scaler->SetScalingL(params.iScalingCoeff, TImageConvScaler::EMaximumQuality);
// Setting the clipping rect to NULL decodes the whole image.
decoder->SetClippingRectL(params.iClip ? &clipRect : NULL);
User::LeaveIfError(decoder->GetDestinationSize(finalSize, KFirstFrame));
User::LeaveIfError(output->Resize(finalSize));
// See Note 1
ao->Initialize();
decoder->Convert(&ao->iStatus, *output, KFirstFrame);
// See Note 2
CActiveScheduler::Start();
TPtrC outputFile(params.iOutputFile);
output->Save(outputFile); // Ignore error code.
}
CleanupStack::PopAndDestroy(3); // decoder, output, ao
}
</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">
void CIclExample::ClipAndRotateDuringDecode()
{
TRect clipRect(TPoint(50, 65), TSize(170, 160)); // The wheel in thumbimage.jpg
TSize finalSize;
// The decoder must support *all* the operations we're going to perform.
TUint options = CImageDecoder::EOptionExtRotation |
CImageDecoder::EOptionExtMirrorHorizontalAxis |
CImageDecoder::EOptionExtCrop |
CImageDecoder::EOptionExtScaling;
// The installed decoders must support *all* the operations requested in aOptions.
_LIT(KInputFile, "c:\\ICLExample\\thumbimage.jpg");
CImageDecoder* decoder = CImageDecoder::FileNewL(iFs, KInputFile, static_cast<CImageDecoder::TOptions>(options));
CleanupStack::PushL(decoder);
const TFrameInfo& frameInfo = decoder->FrameInfo(KFirstFrame);
CFbsBitmap* output = new(ELeave) CFbsBitmap();
CleanupStack::PushL(output);
User::LeaveIfError(output->Create(frameInfo.iFrameSizeInPixels, frameInfo.iFrameDisplayMode));
CActiveListener* ao = CActiveListener::NewLC();
TImageConvOperation* operation = decoder->OperationL();
TImageConvScaler* scaler = decoder->ScalerL();
TInt i = 0;
while (KDecodeParams[i].iOutputFile != NULL)
{
const TDecodeParams& params = KDecodeParams[i++];
operation->ClearOperationStack();
if (params.iRotate90)
{
operation->AddOperationL(TImageConvOperation::ERotation90DegreesClockwise);
}
if (params.iMirrorVerticalAxis)
{
operation->AddOperationL(TImageConvOperation::EMirrorVerticalAxis);
}
// Some codecs may have a limit on the amount of scaling they can do.
scaler->SetScalingL(params.iScalingCoeff, TImageConvScaler::EMaximumQuality);
// Setting the clipping rect to NULL will decode the whole image.
decoder->SetClippingRectL(params.iClip ? &clipRect : NULL);
User::LeaveIfError(decoder->GetDestinationSize(finalSize, KFirstFrame));
User::LeaveIfError(output->Resize(finalSize));
// See Note 1
ao->Initialize();
decoder->Convert(&ao->iStatus, *output, KFirstFrame);
// See Note 2
CActiveScheduler::Start();
TPtrC outputFile(params.iOutputFile);
output->Save(outputFile); // Ignore error code.
}
CleanupStack::PopAndDestroy(3); // decoder, output, ao
}
</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">
void CIclExample::EncodeBitmapToFileUsingOperationExtensionL(const TDesC& aSrcFileName, const TDesC& aDestFileName)
{
// Create the encoder, passing the filename.
// If the image is not recognised or valid then the call will leave with an error
CImageEncoder* jpegImageEncoder = CImageEncoder::FileNewL(iFs, aDestFileName, CImageEncoder::EOptionNone, KImageTypeJPGUid);
CleanupStack::PushL(jpegImageEncoder);
// Create a CFbsBitmap to store the source bitmap to encode
CFbsBitmap* sourceBitmap = new(ELeave) CFbsBitmap;
CleanupStack::PushL(sourceBitmap);
User::LeaveIfError(sourceBitmap->Create(TSize(20,30), EColor16M));
User::LeaveIfError(sourceBitmap->Load(aSrcFileName));
// Create operation extension
TImageConvOperation* operation = jpegImageEncoder->OperationL();
// Add Rotate 90degrees operation
operation->AddOperationL(TImageConvOperation::ERotation90DegreesClockwise);
//NOTE: Multiple operations can be added
// See Note 1
CActiveListener* activeListener = CreateAndInitializeActiveListenerLC();
// Convert the image
jpegImageEncoder->Convert(&activeListener->iStatus, *sourceBitmap, NULL);
// See Note 2
CActiveScheduler::Start();
User::LeaveIfError(activeListener->iStatus.Int());// encode complete either display the image or report an error.
CleanupStack::PopAndDestroy(3); // jpegImageEncoder, sourceBitmap and activeListener
}
</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
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
Decoder Tutorial</linktext> </link> </related-links></concept>