You Are Here:

Community: Wiki

This page was last modified on 23 March 2009, at 17:55.

Bitmap Conversion and Scaling

From Forum Nokia Wiki

Contents

Purpose

The purpose of this wiki is used to convert a Jpeg Image to a Bitmap. The converted Bitmap is then scaled according to the requirement.

Header Files

#include <ImageConversion.h> //CImageDecoder
#include <Fbs.h> //CFbsBitmap
#include <BitmapTransforms.h> //CBitmapScaler

Link against

LIBRARY         mgfetch.lib
LIBRARY bafl.lib
LIBRARY fbscli.lib
LIBRARY efsrv.lib
LIBRARY imageconversion.lib
LIBRARY bitmaptransforms.lib

Capabilities

capability           ReadUserData // MgFetch::RunL()

Example code

As the API's for conversion and scaling are Asynchronous requests,
and the requirement is for making this Synchronous as scaling should be started only after conversion is done,
we make use of the "CActiveSchedulerWait" class which makes it possible.

The following code explains its usage.

CActiveSchedulerWait* iScheduler = new (ELeave) CActiveSchedulerWait;
//Starts a new wait loop under the control of the current active scheduler.
iScheduler->Start();
//within RunL() call the following code once the request is accomplished
// by checking 'iStatus'
if(iStatus==KErrNone)
{
//Stops the scheduling loop owned by this object
iActiveSchedulerWait.AsyncStop();
}


The following code is used to convert a Jpeg Image to Bitmap.

"CImageDecoder" class has a API "Convert()" will start decoding an image frame asynchronously.

As its an Asynchronous call, we must derive our class from "CActive" class and call the Convert() API.

Initializing and Issuing Request code

//File session for the imagedecoder
//Open a connection to the File Server
RFs iFileSession;
iFileSession.Connect();
//Imagedecoder object
CImageDecoder* iDecoder;
 
//We pass the FileSession instance and the name of the file to be decoded
// It creates a decoder for the image in the named file.
iDecoder=CImageDecoder::FileNewL(iFileSession,iImageFolder);
 
//Retrieve the frame info for a specified frame of the image.
TFrameInfo bmpInfo=iDecoder->FrameInfo();
 
//CFbsBitmap object
CFbsBitmap* iBitmap;
iBitmap=new(ELeave) CFbsBitmap;
//Creates a bitmap with the specified size and display mode.
iBitmap->Create(bmpInfo.iOverallSizeInPixels,bmpInfo.iFrameDisplayMode);//EGray256
 
//start conversion to bitmap
iDecoder->Convert(&iStatus,*iBitmap);
SetActive();


code to be handled after Issuing Request

if(iStatus==KErrNone)
{
if(iDecoder)
{
delete iDecoder;
iDecoder = NULL;
}
}
switch( iState )
{
case EDecoding:
{
if( iStatus == KErrNone )
{
iState = EIdle;
iActiveSchedulerWait.AsyncStop();
break;
}
else if(iStatus == KErrUnderflow )
{
iDecoder->ContinueConvert( &iStatus );
SetActive();
break;
}
else if ( iStatus == KErrCorrupt )
{
iState = EIdle;
//Inform about the error
break;
}
else
{
// Unknown error
//Inform about the error...
break;
}
}
default:
break;
}

The following code is used to Scale the Bitmap

"CBitmapScaler" class has a API "Scale()" which is used for Scaling the Bitmap.
Its an Asynchronous call, so we must derive our class from "CActive" class.

Initializing and Issuing Request code

//CFbsBitmap object
CFbsBitmap* iSrcBitmap;
//CBitmapScaler object
CBitmapScaler* iBmpScale;
iBmpScale = CBitmapScaler::NewL();
//This begins the bitmap re-scaling operation.
//iSrcBitmap, The bitmap to be re-scaled.
//This reference is also the target location for the re-scaled bitmap.
//TSize(100,100), the requested target size for the re-scaled bitmap.
iBmpScale->Scale(&iStatus, *iSrcBitmap, TSize(100,100));
SetActive();
//Finally the iSrcBitmap contains the scaled Bitmap.

Example project

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fInstallingE5fJavaE5fappsE5fandE5fWE52TE5fwidgetsE5fusingE5fsisE5ffilesX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZseriesE5f60Q qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qfnZuserE5ftagQSxs60X qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ