Important
This project is not supported anymore. But can be reopened if interest will
be in it. Please, let me know if you need something. Just write me email to
igor.mironchik at gmail.com
.
In internals this library uses giflib
library.
No more dependencies. All things are done in place.
This library is just a wrapper to simplify work with GIFs
in Qt
.
This library doesn't allocate more memory then for two complete frames.
Access time to frames and delays are O(1)
. This is done by storing frames on
disk in PNG
files.
Interface is quite simple, look.
//! Gif file wrapper.
class Gif final
: public QObject
{
Q_OBJECT
signals:
//! Write GIF progress.
void writeProgress( int percent );
public:
explicit Gif( QObject * parent = nullptr );
~Gif() = default;
//! Load GIF.
bool load(
//! Input file name.
const QString & fileName );
//! \return Delay interval in millseconds.
int delay( qsizetype idx ) const;
//! \return Delays of frames.
const QVector< int > & delays() const;
//! \return Count of frames.
qsizetype count() const;
//! \return Frame with given index (starting at 0).
QImage at(
//! Index of the requested frame (indexing starts with 0).
qsizetype idx ) const;
//! \return File names of frames.
QStringList fileNames() const;
//! Write GIF from sequence of PNG files.
bool write(
//! Output file name.
const QString & fileName,
//! Sequence of PNG file names.
const QStringList & pngFileNames,
//! Sequence of delays in milliseconds.
const QVector< int > & delays,
//! Animation loop count, 0 means infinite.
unsigned int loopCount );
//! Clean internals.
void clean();
}; // class Gif