KVIrc 5.2.6
Developer APIs
KviAnimatedPixmap Class Reference

#include <KviAnimatedPixmap.h>

+ Inheritance diagram for KviAnimatedPixmap:

Signals

void frameChanged ()
 

Public Member Functions

uint activeFrameNumber () const
 
uint framesCount () const
 
bool isStarted () const
 
bool isValid () const
 
 KviAnimatedPixmap (const KviAnimatedPixmap &source)
 
 KviAnimatedPixmap (QString fileName, int iWidth=0, int iHeight=0)
 
void nextFrame (bool bEmitSignalAndScheduleNext)
 
QPixmap * pixmap ()
 
void resize (QSize newSize, Qt::AspectRatioMode ratioMode)
 
const QSize & size () const
 
void start ()
 
void stop ()
 
virtual ~KviAnimatedPixmap ()
 
- Public Member Functions inherited from KviAnimatedPixmapInterface
virtual ~KviAnimatedPixmapInterface ()
 

Protected Attributes

int m_iStarted
 
KviAnimatedPixmapCache::Datam_pFrameData
 
QString m_szFileName
 
uint m_uCurrentFrameNumber
 

Detailed Description

This class should not be here, because we already have QMovie with the same functionality.

But QMovie is really stupid, bacause: 1) It does not support infinitive animation. It relies on image metadata to determine loop count. So most of pics will be played only once.

2) It duplicates QPixmap while we calls currentFrame(), that's a very big overload for us.

3) If we try to scale QMovie by using built-in scale mechanism, it will manually scale each frame each time, we will call currentFrame(). So if we plan to play movie 10,100,1000 times, it will scale image 10,100,1000 times too:( 4) KviAnimatedPixmap uses internal cache mechanism with KviAnimatedPixmapCache class. It's managed inside KviAnimatedPixmap and KviAnimatedPixmapCache. No other actions needed to perform caching.

So... Here is my workaround. It's working in this way: You should create new pixmap with constructor KviAnimatedPixmap(QString fileName). It will automagically look at cache and use it, if possible.

KviAnimatedPixmap stores animation as a set of QPixmap's, and delays. when started (see start()) it emits frameChanged() events at the frame change.

You should use pixmap() methd to access the current frame.

This class owns all pixmaps. Do not store links to them.

Constructor & Destructor Documentation

◆ KviAnimatedPixmap() [1/2]

KviAnimatedPixmap::KviAnimatedPixmap ( QString fileName,
int iWidth = 0,
int iHeight = 0 )

◆ ~KviAnimatedPixmap()

KviAnimatedPixmap::~KviAnimatedPixmap ( )
virtual

◆ KviAnimatedPixmap() [2/2]

KviAnimatedPixmap::KviAnimatedPixmap ( const KviAnimatedPixmap & source)

Member Function Documentation

◆ activeFrameNumber()

uint KviAnimatedPixmap::activeFrameNumber ( ) const
inline

References m_uCurrentFrameNumber.

◆ frameChanged

void KviAnimatedPixmap::frameChanged ( )
signal

Referenced by nextFrame().

◆ framesCount()

uint KviAnimatedPixmap::framesCount ( ) const
inline

References m_pFrameData.

◆ isStarted()

bool KviAnimatedPixmap::isStarted ( ) const
inline

References m_iStarted.

◆ isValid()

bool KviAnimatedPixmap::isValid ( ) const
inline

References m_pFrameData.

◆ nextFrame()

void KviAnimatedPixmap::nextFrame ( bool bEmitSignalAndScheduleNext)
virtual

◆ pixmap()

◆ resize()

void KviAnimatedPixmap::resize ( QSize newSize,
Qt::AspectRatioMode ratioMode )

◆ size()

const QSize & KviAnimatedPixmap::size ( ) const
inline

References m_pFrameData.

Referenced by resize().

◆ start()

◆ stop()

void KviAnimatedPixmap::stop ( )

References m_iStarted.

Member Data Documentation

◆ m_iStarted

int KviAnimatedPixmap::m_iStarted
protected

◆ m_pFrameData

◆ m_szFileName

QString KviAnimatedPixmap::m_szFileName
protected

◆ m_uCurrentFrameNumber

uint KviAnimatedPixmap::m_uCurrentFrameNumber
protected

The documentation for this class was generated from the following files: