Archived:Scaling a bitmap without preserving the aspect ratio may lead to application panic on S60 2nd Edition FP3 (Known Issue)
The article is believed to be still valid for the original topic scope.
Article Metadata
Compatibility
Article
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);
}


(no comments yet)