This document gives you more information about Image Processor.
The purpose of this tutorial is to show you how to initialize and process an image.
Required background
Image Processor features are provided through the Imaging Frameworks and the Imaging Plug-ins components.
Introduction
Every new instance of Image Processor must be initialized before processing.
Initializing an image
You need to choose an input image you want to work with. You can start
with an image file stored on flash memory or a hard drive
with a memory buffer containing an image of any of the supported image formats
with a Symbian bitmap or image frame
by only specifying a background colour.
An image stored on file is the most likely option if you are building an editor (most mobile cameras store images in JPEG format on flash memory). If you transfer images from your Digital Still Camera (DSC) or your PC to your mobile phone, the images are probably stored as JPEG files.
If you build a camera application, you receive viewfinder data from the camera module. In this case you will use Symbian bitmaps or image frames.
If you want to start with an empty image, only specify the background colour. For example, if you want to create a collage of several images, you do not really have a main source image and it is memory efficient to set a ‘blank’ input.
Processing an image
When you process an image, all the operations and settings you specified in your Image Processor instance are performed on your input image.
There are three options to choose from to get the output format. In a mobile imaging application there are at least two formats you want your results in. You want to see a preview of the result on the screen of the mobile phone – in which case you render to a bitmap or image frame. When you are satisfied with the preview you want to apply the operations and effects on the source image that is usually significantly larger – you will then render to a file on the flash memory.
To see a preview of the image call Imageprocessor::TPreview::RenderL(). To apply the effects on the source image to get a full resolution result call ImageProcessor::CImgProcessor::ProcessL() which will render to the output you have set.
The following tasks are covered in this tutorial:
Basic procedure to set an input image
The various ways to set an input image are as follows:
To create an internal pixel buffer for an input image use ImageProcessor::CImgProcessor::CreateInputL(CFbsBitmap& ).
To create an internal pixel buffer for an input image use ImageProcessor::CImgProcessor::CreateInputL(CImageFrame& ).
To create an internal pixel buffer for an input image using a size and then initialize the source image with a colour use ImageProcessor::CImgProcessor::CreateInputL(const TSize& ).
To set or update an input image to a specified file name use ImageProcessor::CImgProcessor::SetInputL(const TDesC& ).
To set or updated an input image to a file use ImageProcessor::CImgProcessor::SetInputL(RFile& ).
To set or update a DRM protected input image use ImageProcessor::CImgProcessor::SetInputL(TMMSource& ).
To set or update an input image from a memory buffer use ImageProcessor::CImgProcessor::SetInputL(const TDesC8& ).
To set or update an input image from a provided bitmap use ImageProcessor::CImgProcessor::SetInputL(const CFbsBitmap& ).
To set or update an input image from a provided image frame use ImageProcessor::CImgProcessor::SetInputL(const CImageFrame& ).
Basic procedure to set an output image
The various ways to set an output image are as follows:
To set an output image image to a file call ImageProcessor::CImgProcessor::SetOutputL(const TDesC& ).
To set an output image to a file represented by a file handle call ImageProcessor::CImgProcessor::SetOutputL(RFile& ).
To set an output image to the memory buffer call ImageProcessor::CImgProcessor::SetOutputL(RBuf8& ).
To set an output image to a pixel buffer call ImageProcessor::CImgProcessor::SetOutputL(CImageFrame& ).
To set an output image to an OS native bitmap call ImageProcessor::CImgProcessor::SetOutputL(CFbsBitmap& ).
Note: Rendering is not performed when you set an output image. In case of setting the output image to a memory buffer RBuf8 instance should not contain pre-allocated memory.
Basic procedure to process the image
The high level steps to process an image are as follows:
To initialize the Image Processor instance call ImageProcessor::CImgProcessor::InitializeL().
Note: By default the initialization of Image Processor is asynchronous.
To set an input image call ImageProcessor::CImgProcessor::SetInputL().
To set an output image call ImageProcessor::CImgProcessor::SetOutputL().
To retrieve information about an output image call ImageProcessor::CImgProcessor::TOutputInfo().
To set quality for an output image (in the case of JPEG output) call TOutputInfo::SetJpegQualityL(TReal32& ).
To process an input image and create the output image call ImageProcessor::CImgProcessor::ProcessL().
Example
ImageProcessor::ImageProcessor::CImgProcessor* imageProcessor = ImageProcessor::ImageProcessor::CImgProcessor::NewL(iFs, observer); CleanupStack::PushL(imageProcessor); // Initialize the Image Processor instance. By default the initialization is asynchronous. // (It might take some time to load Image Processor plugin and initialize it). imageProcessor->InitializeL(); // Wait for asynchronous callback CActiveScheduler::Start(); // Set input and output images imageProcessor->SetInputL(KInputFileName, KImageTypeJPGUid); imageProcessor->SetOutputL(KOutputFileName, KImageTypeJPGUid); // Get the TOutputInfo interface TOutputInfo* outputInfo = imageProcessor->OutputInfoL(); // Set 0.75 quality for an output image. // (Note. Default quality value for an output image is the same as for the input image.) TReal32 quality = 0.75f; outputInfo->SetJpegQualityL(quality); // Process the input image to an output image. // an output image size is QVGA and an output image keeps the same aspect ration as the input image. imageProcessor->ProcessL(TSize(320, 240), ETrue); // Wait for asynchronous callback CActiveScheduler::Start(); CleanupStack::PopAndDestroy(); //imageProcessor