Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Revision as of 02:41, 6 August 2012 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

CBitmapRotator

From Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Nokia N95
CompatibilityArticle
Keywords: CBitmapRotator
Created: tepaa (18 Mar 2008)
Last edited: hamishwillee (06 Aug 2012)

Contents

Overview

CBitmapRotator helps when have to rotate the bitmaps.

MMP file

Following libraries are needed

LIBRARY bitmaptransforms.lib

Header

#include <e32base.h>
#include <BitmapTransforms.h>
 
class CBitmapRotator;
 
class MBitmapRotatorObserver
{
public:
virtual void RotateComplete( TInt aError ) = 0;
};
 
class CBitmapRotatorHandler : public CActive
{
public:
static CBitmapRotatorHandler* NewL(MBitmapRotatorObserver& aObserver);
virtual ~CBitmapRotatorHandler();
 
private:
CBitmapRotatorHandler(MBitmapRotatorObserver& aObserver);
void ConstructL();
 
private: // From CActive
void DoCancel();
void RunL();
TInt RunError(TInt aError);
 
public: // New functions
// Rotates a bitmap by a specified angle
void Rotate(CFbsBitmap& aBitmap,
CBitmapRotator::TRotationAngle aAngle);
 
private: // Data
MBitmapRotatorObserver& iObserver;
CBitmapRotator* iBitmapRotator;
};

Source

#include "CBitmapRotatorHandler.h"
 
CBitmapRotatorHandler* CBitmapRotatorHandler::NewL(MBitmapRotatorObserver& aObserver)
{
CBitmapRotatorHandler* self = new (ELeave) CBitmapRotatorHandler( aObserver );
CleanupStack::PushL( self );
self->ConstructL();
CleanupStack::Pop();
return self;
}
 
CBitmapRotatorHandler::~CBitmapRotatorHandler()
{
if (IsActive())
{
Cancel();
}
 
if (iBitmapRotator)
{
delete iBitmapRotator;
iBitmapRotator = NULL;
}
}
 
CBitmapRotatorHandler::CBitmapRotatorHandler(MBitmapRotatorObserver& aObserver)
:CActive( CActive::EPriorityHigh ),
iObserver( aObserver )
{
}
 
void CBitmapRotatorHandler::ConstructL()
{
CActiveScheduler::Add( this );
iBitmapRotator = CBitmapRotator::NewL();
}
 
void CBitmapRotatorHandler::DoCancel()
{
if( iBitmapRotator )
{
iBitmapRotator->Cancel();
}
}
 
void CBitmapRotatorHandler::RunL()
{
iObserver.RotateComplete( iStatus.Int() );
}
 
TInt CBitmapRotatorHandler::RunError( TInt aError )
{
return KErrNone;
}
 
 
// Rotates a bitmap by a specified angle.
// This variant of CBitmapRotator::Rotate() schedules a rotate operation
// by a specified number of degrees on the bitmap specified in aBitmap
// and overwrites the original bitmap with the new rotated image.
// This operation is asynchronous, the result is stored in a
// location pointed to by iStatus.
void CBitmapRotatorHandler::Rotate(CFbsBitmap& aBitmap,
CBitmapRotator::TRotationAngle aAngle)
{
if( iBitmapRotator )
{
if( !IsActive() )
{
SetActive();
iBitmapRotator->Rotate( &iStatus, aBitmap, aAngle );
}
}
}


Using CBitmapRotatorHandler

iBitmapRotator = CBitmapRotatorHandler::NewL(*this);
iBitmapRotator->Rotate(*iCurrentImage,
CBitmapRotator::ERotation90DegreesClockwise);

Postconditions

Bitmap is rotated.

This page was last modified on 6 August 2012, at 02:41.
63 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×