Namespaces
Variants
Actions

Archived:Scaling a bitmap without preserving the aspect ratio may lead to application panic on S60 2nd Edition FP3 (Known Issue)

Jump to: navigation, search
Archived.png
Archived: 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}}.

The article is believed to be still valid for the original topic scope.
Article Metadata

Compatibility
Platform(s): S60 2nd Edition, FP3, N70, N90

Article
Created: User:Technical writer 1 (24 Nov 2005)
Last edited: hamishwillee (21 Jun 2012)

Contents

Overview

Using the CBitmapScaler::Scale() method with the aMaintainAspectRatio parameter set to EFalse may lead to application panic.

Description

An application may terminate with USER 21 panic when a bitmap image (e.g., of size 132x176) is scaled (e.g., to 176x144) using the Scale method from CBitmapScaler with the aMaintainAspectRatio parameter set to EFalse.

How to reproduce

(See above)

Solution

If all that is needed is for the scaled image to be rendered on the screen, you can use the CGraphicContext::DrawBitmap method.
If the scaled bitmap is to be retained for further processing, the same method can be used to render the image on a CBitmapContext object and then keep the bitmap on which this was constructed. The following is a sample code for testing that can be integrated into the S60 Developer Platform 2.0: Image Converter Example application.

void CImageConverterEngine::ScaleL(TSize aSize)
{
CWsBitmap *newBitmap = new (ELeave)
CWsBitmap(CEikonEnv::Static()->WsSession());
CleanupStack::PushL(newBitmap);
User::LeaveIfError(newBitmap->Create(
aSize,CEikonEnv::Static()->DefaultDisplayMode()));
 
CFbsBitmapDevice* bitDev =
CFbsBitmapDevice::NewL(newBitmap);
CleanupStack::PushL(bitDev);
 
CBitmapContext* bgc = NULL;
User::LeaveIfError(bitDev->CreateBitmapContext(bgc));
 
bgc->DrawBitmap(TRect(TPoint(0,0), aSize), iBitmap);
delete bgc;
 
CleanupStack::PopAndDestroy(2); // bitDev, newBitmap
 
delete iBitmap;
iBitmap = newBitmap;
 
iController->NotifyCompletion(KErrNone);
}
This page was last modified on 21 June 2012, at 03:53.
92 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved