📄 gifanimationengine.cpp
字号:
/*
* ============================================================================
* Name : CGifAnimationEngine from GifAnimationEngine.cpp
* Part of : GifAnimation
* Created : 30.01.2006 by ToBeReplacedByAuthor
* Implementation notes:
*
* Version :
* Copyright: ToBeReplacedByCopyright
* ============================================================================
*/
// INCLUDE FILES
#include <coemain.h>
#include "GifAnimationEngine.h"
// ================= MEMBER FUNCTIONS =======================
// Two-phased constructor.
CGifAnimationEngine* CGifAnimationEngine::NewL(MObserver& aObserver)
{
CGifAnimationEngine* self = new(ELeave) CGifAnimationEngine(aObserver);
CleanupStack::PushL( self );
self->ConstructL();
CleanupStack::Pop();
return self;
}
// destructor
CGifAnimationEngine::~CGifAnimationEngine()
{
DoCancel();
}
void CGifAnimationEngine::LoadL(const TFileName& aFileName)
{
DoCancel();
iImageDecoder = CImageDecoder::FileNewL(CCoeEnv::Static()->FsSession(), aFileName);
iArray = new(ELeave) CBitmapPointerArray(5);
if(iImageDecoder->FrameCount()>0)
{
iIndex = 0;
LoadFrameL(iIndex);
}
else
{
TRequestStatus* s=&iStatus;
User::RequestComplete(s, KErrCorrupt);
SetActive();
}
}
void CGifAnimationEngine::RunL()
{
// Transfer ownership
iArray->AppendL(iBitmap);
iBitmap = NULL;
iIndex++;
if(iIndex==iImageDecoder->FrameCount())
{
iObserver.OnCompleteL(iArray, iStatus.Int());
iArray = NULL;
DoCancel();
}
else
{
LoadFrameL(iIndex);
}
}
void CGifAnimationEngine::DoCancel()
{
if(iImageDecoder!=NULL)
{
iImageDecoder->Cancel();
}
delete iImageDecoder;
iImageDecoder = NULL;
if(iArray!=NULL)
{
iArray->ResetAndDestroy();
}
delete iArray;
iArray = NULL;
delete iBitmap;
iBitmap = NULL;
iIndex=-1;
}
// constructor
CGifAnimationEngine::CGifAnimationEngine(MObserver& aObserver ) :
CActive(EPriorityStandard), iObserver(aObserver), iIndex(-1)
{
}
// EPOC default constructor can leave.
void CGifAnimationEngine::ConstructL()
{
CActiveScheduler::Add( this );
}
void CGifAnimationEngine::LoadFrameL(TInt aIndex)
{
TFrameInfo frameInfo = iImageDecoder->FrameInfo(aIndex);
TRect rect = frameInfo.iFrameCoordsInPixels;
iBitmap = new(ELeave) CFbsBitmap;
iBitmap->Create(rect.Size(), frameInfo.iFrameDisplayMode);
iImageDecoder->Convert(&iStatus, *iBitmap, aIndex);
SetActive();
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -