Initializing And Processing an Image Tutorial

This document gives you more information about Image Processor.

Purpose

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.

Using the image processor

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:

Basic procedure to set an output image

The various ways to set an output image are as follows:

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:

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