This page was last modified 04:43, 24 August 2007.
KIS000303 - Scaling a bitmap without preserving the aspect ratio may lead to application panic
From Forum Nokia Wiki
Scaling a bitmap without preserving the aspect ratio may lead to application panic
| KIS000303
|
Overview
| Using the CBitmapScaler::Scale() method with the aMaintainAspectRatio parameter set to EFalse may lead to application panic.
|
Reported against
| S60 2nd Edition, FP3, N70, N90
|
Date identified
| November 24, 2005
|
Symptoms
| -
|
Detailed 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 Series 60 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); }
|