Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



Image Encoding

The image encoding class CImageEncoder provides functions to save images originating from the screen, applications such as browsers and paint programs and photos from cameras or viewer applications, to files or descriptors. Just as in CImageDecoder, this class provides these features via a plugin framework. The standard formats supported by the encoder plugins are shown in the table in Overview.

Note: None of the encoder plugin formats support multiframe images or bitmap masks (transparent images).

Using CImageEncoder can be summarised as a two stage process, object creation and conversion. Each of these stages is described below.


Creation

The creation of the encoder object is a synchronous operation performed using one of the following factory constructors:

static CImageEncoder* FileNewL(RFs& aFs, const TDesC& aDestinationFilename, const TDesC8& aMIMEType, const TOptions aOptions = EOptionNone);

static CImageEncoder* FileNewL(RFs& aFs, const TDesC& aDestinationFilename, const TOptions aOptions = EOptionNone, const TUid aImageType = KNullUid, const TUid aImageSubType = KNullUid, const TUid aEncoderUid = KNullUid);

static CImageEncoder* DataNewL(HBufC8*& aDestinationData, const TDesC8& aMIMEType, const TOptions aOptions = EOptionNone);

static CImageEncoder* DataNewL(HBufC8*& aDestinationData, const TOptions aOptions = EOptionNone, const TUid aImageType = KNullUid, const TUid aImageSubType = KNullUid, const TUid aEncoderUid = KNullUid);

The FileNewL() constructors are used when converting image data that is to be saved to a file. The two variants of the function enable you to specify the plugin to use either by specifying a MIME type, or by specifying an image type and sub-type and optional encoder UID.

The DataNewL() constructors are used when converting image data that is to be saved to a buffer. Rather than specifying the destination buffer itself, the DataNewL functions require a HBufC8* value that must be set to zero. On successful completion of the conversion the HBufC8* will contain a pointer to an internally generated buffer containing the converted image data.

The two variants of the DataNewL() constructors enable you to specify the plugin to use either by specifying a MIME type, an image type and sub-type, or by specifying the plugin ID itself.

[Top]


Conversion

Before converting the image data, destination image format specific data can be set by using CFrameImageData. However, the type of data that can be supplied is dependant on the plugin that is being used. The format specific data are TImageDataBlock and TFrameDataBlock derivatives provided by the plugin. These can be appended to CFrameImageData using AppendImageData() and AppendFrameData() at which point CFrameImageData takes ownership of the data.

An example of how to pass this format specific data and then convert is shown below.

TJpegImageData imageData = new (ELeave) TJpegImageData;

// Set some format specific data
imageData->iSampleScheme = TJpegImageData::EColor444;
imageData->iQualityFactor = 95;

iFrameImageData = CFrameImageData::NewL();

// frameData - ownership passed to iFrameImageData after AppendImageData
User::LeaveIfError(iFrameImageData->AppendImageData(imageData));

// Do the convert
iEncoder->Convert(iRequesStatus,iFrameBitmap,iFrameImageData);

[Top]


See also