I write this class to load and draw bmp image save on TDes8 ,but it is vary slow; if you have new way to make it and it is faster send it ?
this is my class,
***************************************************
/* Copyright (c) 2001, Nokia Mobile Phones. All rights reserved */
#include <eikenv.h>
#include <gdi.h>
#include "LoadBitmap.h"
#include <s32file.h>
#include <f32file.h>
static const TDisplayMode KDeviceColourDepth = EColor4K;
//gif file frame index (in this case there is only one frame)
static const TInt KGifFrameIndex = 0;
void CLoadBitmap::ConstructL()
{
iBitmap = new (ELeave) CFbsBitmap();
iScaler = CMdaBitmapScaler::NewL();
iConverter = CMdaImageDescToBitmapUtility::NewL(*this);
//Start an asynchronous process to open the gif file
delete iScaler;
iScaler = NULL;
delete iConverter;
iConverter = NULL;
delete iBitmap;
iBitmap = NULL;
}
//Draw this applications view to the screen
CFbsBitmap* CLoadBitmap::getBitmap(){
//if the bitmap is not currently being processed in any way
if (iConvertState == EConvertStateReady ){
return iBitmap;
}else{
return NULL;}
}//end Save
//This function is called when the gif file has been opened or an error has occured in the process
void CLoadBitmap::MiuoOpenComplete(TInt aError)
{
if (aError == KErrNone)
{
iConvertState = EConvertStateConvertingFromGif;
TFrameInfo frameInfo;
//Get the frame info
iConverter->FrameInfo(KGifFrameIndex,frameInfo);
//Create a bitmap based on the size of the gif
TInt err = iBitmap->Create(frameInfo.iOverallSizeInPixels,KDeviceColourDepth);
if (err == KErrCouldNotConnect)
{
//NEikonEnvironment::MessageBox(_L("Could not connect to font and bitmap server"));
return;
}
if (err == KErrArgument)
{
//NEikonEnvironment::MessageBox(_L("Illegal Gif file size"));
return;
}
//Convert the gif into a bitmap
TRAPD(convertErr,iConverter->ConvertL(*iBitmap,KGifFrameIndex));
//Trap error as this function cannot leave
if (convertErr != KErrNone)
{
//NEikonEnvironment::MessageBox(_L("Cannot initiate converter"));
}
}
else if (aError == KErrUnderflow)
{
//This error occurs if the gif file contains insufficient information
//This is usually because the file is being opened in a cache so a futher attempt to open
//should be performed
TRAPD(err,iConverter->OpenL(*iDes));
if (err !=KErrNone)
{
//NEikonEnvironment::MessageBox(_L("Gif file contains insufficient information, cannot retry"));
}
}
//This function is called whenever a conversion process has finished
void CLoadBitmap::MiuoConvertComplete(TInt aError)
{
switch (iConvertState)
{
//Finished converting gif file to bitmap
case EConvertStateConvertingFromGif:
ConvertingFromGifFinished(aError);
break;
//Finished Scaling file
case EConvertStateScaling:
ScalingFinished(aError);
iView.iBitmap=getBitmap();
iView.DrawNow();
/**/
break;
case EConvertStateNull:
default:
ASSERT(FALSE);
}
}
//This function is called when the bitmap (output) file has been created
void CLoadBitmap::MiuoCreateComplete(TInt aError)
{
if (aError == KErrNone)
{
}
else
{
//Reset state so that other operations can still be performed
iConvertState = EConvertStateReady;
//NEikonEnvironment::MessageBox(_L("File Could not be created"));
}
}
//This function is called when conversion has finished
void CLoadBitmap::ConvertingFromGifFinished(TInt aError)
{
if (aError == KErrNone)
{
TRAPD(err,iScaler->ScaleL(*this,*iBitmap,TSize(KNewImageWidth,KNewImageHeight)));
if (err == KErrNone)
{
iConvertState = EConvertStateScaling;
}
else
{
//NEikonEnvironment::MessageBox(_L("Cannnot re scale image"));
}
}
else
{
//NEikonEnvironment::MessageBox(_L("Error converting file"));
}
}
//This function is called when scaling has finished
void CLoadBitmap::ScalingFinished(TInt aError)
{
if (aError == KErrNone)
{
iConvertState = EConvertStateReady;
// iView->d();
// DrawNow();
}
else
{
//NEikonEnvironment::MessageBox(_L("Error resizing image"));
}
}