Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Archived:Increasing speed and reducing memory consumption of JPEG decoding using Symbian C++

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Article Metadata
Compatibility
Platform(s): S60 3rd Edition
S60 3rd Edition (initial release)
Article
Created: User:Technical writer 1 (14 Sep 2007)
Last edited: hamishwillee (15 Jun 2012)

Overview

Using CImageDecoder to decode and scale JPEG images can be a slow and memory-consuming process, depending on image size. Here are a few tips which will increase speed and decrease memory consumption.

Solution

A generic way to decode e.g. a 5 megapixel image:

  1. Create a 5 megapixel CFbsBitmap image.
  2. Create the decoder.
  3. Convert the image.
  4. Scale the 5 megapixel output to a smaller resolution size (e.g. QVGA, VGA...)

This is, however, not efficient, since it requires memory to store the 5MP intermediate bitmap image.

Instead, you can do the following:

  1. Create a CFbsBitmap image of the required size (e.g. QVGA, VGA...).
  2. Create the decoder.
  3. Convert the image.

Using this method, bitmap scaling will be handled during decoding, which will increase speed and decrease memory usage.

Note that some JPEG decoders may not support arbitrary scaling. The information for arbitrary scaling support can be obtained from the EFullyScaleable property of TFrameInfo.

If the decoder does not support arbitrary scaling, first perform the best suitable DCT (Discrete Cosine Transform) scaling (e.g. 1, 1/2, 1/4 or 1/8) and then perform a normal bitmap scaling on the resulting CFbsBitmap.

The steps are as follows:

  1. Create the decoder.
  2. Check TFrameInfo flags.
    • If arbitrary scaling supported
      1. Create a CFbsBitmap image of required size (e.g.QVGA, VGA...)
      2. Convert
    • If arbitrary scaling is not supported
      1. Create a CFbsBitmap image of best suitable DCT scaling ratio (e.g. 1, 1/2, 1/4, 1/8).
      2. Convert the image.
      3. Perform CFbsBitmap scaling on the output bitmap in order to get the final image size.


Example on DCT scaling

Original size: 2048x1536

Desired size: QVGA (320x240) - same aspect ratio

Assume that arbitrary scaling is not supported.

If DCT scaling of 1/8 ratio is used, the size of the scaled bitmap is:

2048/8 = 256 and 1536/8 = 192 (256x192)

This would result in a lower than desired resolution; upscaling 256x192 to QVGA will result in poor image quality.

If DCT scaling of 1/4 ratio is used:

2048/4 = 512 and 1536/4 = 384 (512x384)

In this case, the best choice is to use 1/4 scaling and further scale the 512x384 bitmap to 320x240 with CBitmapScaler.

This page was last modified on 15 June 2012, at 01:01.
40 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×