Qt 4.8
qmovie.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
205 #include "qglobal.h"
206 
207 #ifndef QT_NO_MOVIE
208 
209 #include "qmovie.h"
210 #include "qimage.h"
211 #include "qimagereader.h"
212 #include "qpixmap.h"
213 #include "qrect.h"
214 #include "qdatetime.h"
215 #include "qtimer.h"
216 #include "qpair.h"
217 #include "qmap.h"
218 #include "qlist.h"
219 #include "qbuffer.h"
220 #include "qdir.h"
221 #include "private/qobject_p.h"
222 
223 #define QMOVIE_INVALID_DELAY -1
224 
226 
228 {
229 public:
231  int delay;
232  bool endMark;
233  inline QFrameInfo(bool endMark)
234  : pixmap(QPixmap()), delay(QMOVIE_INVALID_DELAY), endMark(endMark)
235  { }
236 
237  inline QFrameInfo()
238  : pixmap(QPixmap()), delay(QMOVIE_INVALID_DELAY), endMark(false)
239  { }
240 
241  inline QFrameInfo(const QPixmap &pixmap, int delay)
242  : pixmap(pixmap), delay(delay), endMark(false)
243  { }
244 
245  inline bool isValid()
246  {
247  return endMark || !(pixmap.isNull() && (delay == QMOVIE_INVALID_DELAY));
248  }
249 
250  inline bool isEndMarker()
251  { return endMark; }
252 
253  static inline QFrameInfo endMarker()
254  { return QFrameInfo(true); }
255 };
256 
258 {
260 
261 public:
262  QMoviePrivate(QMovie *qq);
263  bool isDone();
264  bool next();
265  int speedAdjustedDelay(int delay) const;
266  bool isValid() const;
267  bool jumpToFrame(int frameNumber);
268  int frameCount() const;
269  bool jumpToNextFrame();
270  QFrameInfo infoForFrame(int frameNumber);
271  void reset();
272 
273  inline void enterState(QMovie::MovieState newState) {
274  movieState = newState;
275  emit q_func()->stateChanged(newState);
276  }
277 
278  // private slots
279  void _q_loadNextFrame();
280  void _q_loadNextFrame(bool starting);
281 
283  int speed;
298 
300 };
301 
305  : reader(0), speed(100), movieState(QMovie::NotRunning),
306  currentFrameNumber(-1), nextFrameNumber(0), greatestFrameNumber(-1),
307  nextDelay(0), playCounter(-1),
308  cacheMode(QMovie::CacheNone), haveReadAll(false), isFirstIteration(true)
309 {
310  q_ptr = qq;
312 }
313 
317 {
319  if (reader->device())
321  currentFrameNumber = -1;
322  nextFrameNumber = 0;
323  greatestFrameNumber = -1;
324  nextDelay = 0;
325  playCounter = -1;
326  haveReadAll = false;
327  isFirstIteration = true;
328  frameMap.clear();
329 }
330 
334 {
335  return (playCounter == 0);
336 }
337 
350 {
351  return int( (qint64(delay) * qint64(100) ) / qint64(speed) );
352 }
353 
370 {
371  if (frameNumber < 0)
372  return QFrameInfo(); // Invalid
373 
374  if (haveReadAll && (frameNumber > greatestFrameNumber)) {
375  if (frameNumber == greatestFrameNumber+1)
376  return QFrameInfo::endMarker();
377  return QFrameInfo(); // Invalid
378  }
379 
380  if (cacheMode == QMovie::CacheNone) {
381  if (frameNumber != currentFrameNumber+1) {
382  // Non-sequential frame access
383  if (!reader->jumpToImage(frameNumber)) {
384  if (frameNumber == 0) {
385  // Special case: Attempt to "rewind" so we can loop
386  // ### This could be implemented as QImageReader::rewind()
387  if (reader->device()->isSequential())
388  return QFrameInfo(); // Invalid
391  QIODevice *device = reader->device();
392  QColor bgColor = reader->backgroundColor();
393  QSize scaledSize = reader->scaledSize();
394  delete reader;
395  if (fileName.isEmpty())
396  reader = new QImageReader(device, format);
397  else
398  reader = new QImageReader(absoluteFilePath, format);
399  (void)reader->canRead(); // Provoke a device->open() call
401  reader->setBackgroundColor(bgColor);
402  reader->setScaledSize(scaledSize);
403  } else {
404  return QFrameInfo(); // Invalid
405  }
406  }
407  }
408  if (reader->canRead()) {
409  // reader says we can read. Attempt to actually read image
410  QImage anImage = reader->read();
411  if (anImage.isNull()) {
412  // Reading image failed.
413  return QFrameInfo(); // Invalid
414  }
415  if (frameNumber > greatestFrameNumber)
416  greatestFrameNumber = frameNumber;
417  QPixmap aPixmap = QPixmap::fromImage(anImage);
418  int aDelay = reader->nextImageDelay();
419  return QFrameInfo(aPixmap, aDelay);
420  } else if (frameNumber != 0) {
421  // We've read all frames now. Return an end marker
422  haveReadAll = true;
423  return QFrameInfo::endMarker();
424  } else {
425  // No readable frames
426  haveReadAll = true;
427  return QFrameInfo();
428  }
429  }
430 
431  // CacheMode == CacheAll
432  if (frameNumber > greatestFrameNumber) {
433  // Frame hasn't been read from file yet. Try to do it
434  for (int i = greatestFrameNumber + 1; i <= frameNumber; ++i) {
435  if (reader->canRead()) {
436  // reader says we can read. Attempt to actually read image
437  QImage anImage = reader->read();
438  if (anImage.isNull()) {
439  // Reading image failed.
440  return QFrameInfo(); // Invalid
441  }
443  QPixmap aPixmap = QPixmap::fromImage(anImage);
444  int aDelay = reader->nextImageDelay();
445  QFrameInfo info(aPixmap, aDelay);
446  // Cache it!
447  frameMap.insert(i, info);
448  if (i == frameNumber) {
449  return info;
450  }
451  } else {
452  // We've read all frames now. Return an end marker
453  haveReadAll = true;
454  return QFrameInfo::endMarker();
455  }
456  }
457  }
458  // Return info for requested (cached) frame
459  return frameMap.value(frameNumber);
460 }
461 
477 {
478  QTime time;
479  time.start();
481  if (!info.isValid())
482  return false;
483  if (info.isEndMarker()) {
484  // We reached the end of the animation.
485  if (isFirstIteration) {
486  if (nextFrameNumber == 0) {
487  // No frames could be read at all (error).
488  return false;
489  }
490  // End of first iteration. Initialize play counter
492  isFirstIteration = false;
493  }
494  // Loop as appropriate
495  if (playCounter != 0) {
496  if (playCounter != -1) // Infinite?
497  playCounter--; // Nope
498  nextFrameNumber = 0;
499  return next();
500  }
501  // Loop no more. Done
502  return false;
503  }
504  // Image and delay OK, update internal state
506  QSize scaledSize = reader->scaledSize();
507  if (scaledSize.isValid() && (scaledSize != info.pixmap.size()))
508  currentPixmap = QPixmap::fromImage( info.pixmap.toImage().scaled(scaledSize) );
509  else
510  currentPixmap = info.pixmap;
512  // Adjust delay according to the time it took to read the frame
513  int processingTime = time.elapsed();
514  if (processingTime > nextDelay)
515  nextDelay = 0;
516  else
517  nextDelay = nextDelay - processingTime;
518  return true;
519 }
520 
524 {
525  _q_loadNextFrame(false);
526 }
527 
529 {
530  Q_Q(QMovie);
531  if (next()) {
532  if (starting && movieState == QMovie::NotRunning) {
534  emit q->started();
535  }
536 
537  if (frameRect.size() != currentPixmap.rect().size()) {
539  emit q->resized(frameRect.size());
540  }
541 
542  emit q->updated(frameRect);
543  emit q->frameChanged(currentFrameNumber);
544 
547  } else {
548  // Could not read another frame
549  if (!isDone()) {
550  emit q->error(reader->error());
551  }
552 
553  // Graceful finish
554  if (movieState != QMovie::Paused) {
555  nextFrameNumber = 0;
556  isFirstIteration = true;
557  playCounter = -1;
559  emit q->finished();
560  }
561  }
562 }
563 
568 {
569  return (greatestFrameNumber >= 0) // have we seen valid data
570  || reader->canRead(); // or does the reader see valid data
571 }
572 
576 bool QMoviePrivate::jumpToFrame(int frameNumber)
577 {
578  if (frameNumber < 0)
579  return false;
580  if (currentFrameNumber == frameNumber)
581  return true;
582  nextFrameNumber = frameNumber;
586  return (nextFrameNumber == currentFrameNumber+1);
587 }
588 
593 {
594  int result;
595  if ((result = reader->imageCount()) != 0)
596  return result;
597  if (haveReadAll)
598  return greatestFrameNumber+1;
599  return 0; // Don't know
600 }
601 
606 {
608 }
609 
617  : QObject(*new QMoviePrivate(this), parent)
618 {
619  Q_D(QMovie);
620  d->reader = new QImageReader;
621  connect(&d->nextImageTimer, SIGNAL(timeout()), this, SLOT(_q_loadNextFrame()));
622 }
623 
633  : QObject(*new QMoviePrivate(this), parent)
634 {
635  Q_D(QMovie);
636  d->reader = new QImageReader(device, format);
637  d->initialDevicePos = device->pos();
638  connect(&d->nextImageTimer, SIGNAL(timeout()), this, SLOT(_q_loadNextFrame()));
639 }
640 
650  : QObject(*new QMoviePrivate(this), parent)
651 {
652  Q_D(QMovie);
653  d->absoluteFilePath = QDir(fileName).absolutePath();
654  d->reader = new QImageReader(fileName, format);
655  if (d->reader->device())
656  d->initialDevicePos = d->reader->device()->pos();
657  connect(&d->nextImageTimer, SIGNAL(timeout()), this, SLOT(_q_loadNextFrame()));
658 }
659 
664 {
665  Q_D(QMovie);
666  delete d->reader;
667 }
668 
676 {
677  Q_D(QMovie);
678  d->reader->setDevice(device);
679  d->reset();
680 }
681 
689 {
690  Q_D(const QMovie);
691  return d->reader->device();
692 }
693 
701 {
702  Q_D(QMovie);
703  d->absoluteFilePath = QDir(fileName).absolutePath();
704  d->reader->setFileName(fileName);
705  d->reset();
706 }
707 
716 {
717  Q_D(const QMovie);
718  return d->reader->fileName();
719 }
720 
732 {
733  Q_D(QMovie);
734  d->reader->setFormat(format);
735 }
736 
744 {
745  Q_D(const QMovie);
746  return d->reader->format();
747 }
748 
756 {
757  Q_D(QMovie);
758  d->reader->setBackgroundColor(color);
759 }
760 
768 {
769  Q_D(const QMovie);
770  return d->reader->backgroundColor();
771 }
772 
779 {
780  Q_D(const QMovie);
781  return d->movieState;
782 }
783 
791 {
792  Q_D(const QMovie);
793  return d->frameRect;
794 }
795 
826 {
827  Q_D(const QMovie);
828  return d->currentPixmap;
829 }
830 
845 {
846  Q_D(const QMovie);
847  return d->currentPixmap.toImage();
848 }
849 
854 bool QMovie::isValid() const
855 {
856  Q_D(const QMovie);
857  return d->isValid();
858 }
859 
924 {
925  Q_D(const QMovie);
926  return d->frameCount();
927 }
928 
934 {
935  Q_D(const QMovie);
936  return d->nextDelay;
937 }
938 
944 {
945  Q_D(const QMovie);
946  return d->currentFrameNumber;
947 }
948 
953 {
954  Q_D(QMovie);
955  return d->jumpToNextFrame();
956 }
957 
962 bool QMovie::jumpToFrame(int frameNumber)
963 {
964  Q_D(QMovie);
965  return d->jumpToFrame(frameNumber);
966 }
967 
977 int QMovie::loopCount() const
978 {
979  Q_D(const QMovie);
980  return d->reader->loopCount();
981 }
982 
990 void QMovie::setPaused(bool paused)
991 {
992  Q_D(QMovie);
993  if (paused) {
994  if (d->movieState == NotRunning)
995  return;
996  d->enterState(Paused);
997  d->nextImageTimer.stop();
998  } else {
999  if (d->movieState == Running)
1000  return;
1001  d->enterState(Running);
1002  d->nextImageTimer.start(nextFrameDelay());
1003  }
1004 }
1005 
1019 void QMovie::setSpeed(int percentSpeed)
1020 {
1021  Q_D(QMovie);
1022  d->speed = percentSpeed;
1023 }
1024 
1025 int QMovie::speed() const
1026 {
1027  Q_D(const QMovie);
1028  return d->speed;
1029 }
1030 
1041 {
1042  Q_D(QMovie);
1043  if (d->movieState == NotRunning) {
1044  d->_q_loadNextFrame(true);
1045  } else if (d->movieState == Paused) {
1046  setPaused(false);
1047  }
1048 }
1049 
1061 {
1062  Q_D(QMovie);
1063  if (d->movieState == NotRunning)
1064  return;
1065  d->enterState(NotRunning);
1066  d->nextImageTimer.stop();
1067  d->nextFrameNumber = 0;
1068 }
1069 
1081 {
1082  Q_D(QMovie);
1083  return d->reader->scaledSize();
1084 }
1085 
1096 void QMovie::setScaledSize(const QSize &size)
1097 {
1098  Q_D(QMovie);
1099  d->reader->setScaledSize(size);
1100 }
1101 
1113 {
1115  QMutableListIterator<QByteArray> it(list);
1116  QBuffer buffer;
1117  buffer.open(QIODevice::ReadOnly);
1118  while (it.hasNext()) {
1119  QImageReader reader(&buffer, it.next());
1120  if (!reader.supportsAnimation())
1121  it.remove();
1122  }
1123  return list;
1124 }
1125 
1151 {
1152  Q_D(const QMovie);
1153  return d->cacheMode;
1154 }
1155 
1157 {
1158  Q_D(QMovie);
1159  d->cacheMode = cacheMode;
1160 }
1161 
1166 {
1167  Q_D(QMovie);
1168  return d->cacheMode;
1169 }
1170 
1172 
1173 #include "moc_qmovie.cpp"
1174 
1175 #endif // QT_NO_MOVIE
The QDir class provides access to directory structures and their contents.
Definition: qdir.h:58
QColor backgroundColor() const
Returns the background color that&#39;s used when reading an image.
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
void setSingleShot(bool singleShot)
Definition: qtimer.h:108
QImage toImage() const
Converts the pixmap to a QImage.
Definition: qpixmap.cpp:542
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
Definition: qpixmap.cpp:2197
QFrameInfo()
Definition: qmovie.cpp:237
~QMovie()
Destructs the QMovie object.
Definition: qmovie.cpp:663
QMovie::MovieState movieState
Definition: qmovie.cpp:284
QMap< int, QFrameInfo > frameMap
Definition: qmovie.cpp:296
static mach_timebase_info_data_t info
static QList< QByteArray > supportedImageFormats()
Returns the list of image formats supported by QImageReader.
QPixmap pixmap
Definition: qmovie.cpp:230
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QMoviePrivate(QMovie *qq)
Definition: qmovie.cpp:304
void stop()
Stops the movie.
Definition: qmovie.cpp:1060
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
QSize size() const
Returns the size of the pixmap.
Definition: qpixmap.cpp:661
bool jumpToNextFrame()
Definition: qmovie.cpp:605
QTimer nextImageTimer
Definition: qmovie.cpp:299
QMovie(QObject *parent=0)
Constructs a QMovie object, passing the parent object to QObject&#39;s constructor.
Definition: qmovie.cpp:616
#define it(className, varName)
QObject * q_ptr
Definition: qobject.h:91
void setScaledSize(const QSize &size)
Sets the scaled size of the image to size.
#define QMOVIE_INVALID_DELAY
Definition: qmovie.cpp:223
QFrameInfo(bool endMark)
Definition: qmovie.cpp:233
void start()
Sets this time to the current time.
Definition: qdatetime.cpp:2070
QString fileName() const
Returns the name of the file that QMovie reads image data from.
Definition: qmovie.cpp:715
QPixmap currentPixmap
Definition: qmovie.cpp:286
void _q_loadNextFrame()
Definition: qmovie.cpp:523
bool open(OpenMode openMode)
Reimplemented Function
Definition: qbuffer.cpp:338
int speedAdjustedDelay(int delay) const
Given the original delay, this function returns the actual number of milliseconds to delay according ...
Definition: qmovie.cpp:349
bool isNull() const
Returns true if it is a null image, otherwise returns false.
Definition: qimage.cpp:1542
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
Q_CORE_EXPORT QTextStream & reset(QTextStream &s)
#define SLOT(a)
Definition: qobjectdefs.h:226
virtual qint64 pos() const
For random-access devices, this function returns the position that data is written to or read from...
Definition: qiodevice.cpp:624
QRect frameRect
Definition: qmovie.cpp:285
bool isValid()
Definition: qmovie.cpp:245
bool isFirstIteration
Definition: qmovie.cpp:295
static QFrameInfo endMarker()
Definition: qmovie.cpp:253
QColor backgroundColor() const
Returns the background color of the movie.
Definition: qmovie.cpp:767
static QList< QByteArray > supportedFormats()
Returns the list of image formats supported by QMovie.
Definition: qmovie.cpp:1112
bool jumpToImage(int imageNumber)
For image formats that support animation, this function skips to the image whose sequence number is i...
The QBuffer class provides a QIODevice interface for a QByteArray.
Definition: qbuffer.h:57
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool endMark
Definition: qmovie.cpp:232
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_D(Class)
Definition: qglobal.h:2482
void setBackgroundColor(const QColor &color)
For image formats that support it, this function sets the background color to color.
Definition: qmovie.cpp:755
QSize scaledSize()
Returns the scaled size of frames.
Definition: qmovie.cpp:1080
void setFormat(const QByteArray &format)
Sets the format that QMovie will use when decoding image data, to format.
Definition: qmovie.cpp:731
#define Q_Q(Class)
Definition: qglobal.h:2483
void reset()
Definition: qmovie.cpp:316
QPixmap currentPixmap() const
Returns the current frame as a QPixmap.
Definition: qmovie.cpp:825
#define SIGNAL(a)
Definition: qobjectdefs.h:227
The QTime class provides clock time functions.
Definition: qdatetime.h:148
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
int currentFrameNumber() const
Returns the sequence number of the current frame.
Definition: qmovie.cpp:943
qint64 initialDevicePos
Definition: qmovie.cpp:292
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QString absolutePath() const
Returns the absolute path (a path that starts with "/" or with a drive specification), which may contain symbolic links, but never contains redundant ".", ".." or multiple separators.
Definition: qdir.cpp:619
void setCacheMode(CacheMode mode)
Definition: qmovie.cpp:1156
const T value(const Key &key) const
Returns the value associated with the key key.
Definition: qmap.h:499
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
#define emit
Definition: qobjectdefs.h:76
int nextImageDelay() const
For image formats that support animation, this function returns the number of milliseconds to wait un...
QString absoluteFilePath
Definition: qmovie.cpp:297
void setPaused(bool paused)
If paused is true, QMovie will enter Paused state and emit stateChanged(Paused); otherwise it will en...
Definition: qmovie.cpp:990
int loopCount() const
Returns the number of times the movie will loop before it finishes.
Definition: qmovie.cpp:977
QFrameInfo(const QPixmap &pixmap, int delay)
Definition: qmovie.cpp:241
bool isValid() const
Definition: qmovie.cpp:567
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
int greatestFrameNumber
Definition: qmovie.cpp:289
QFrameInfo infoForFrame(int frameNumber)
Returns the QFrameInfo for the given frameNumber.
Definition: qmovie.cpp:369
void start()
Starts the movie.
Definition: qmovie.cpp:1040
void enterState(QMovie::MovieState newState)
Definition: qmovie.cpp:273
__int64 qint64
Definition: qglobal.h:942
QByteArray format() const
Returns the format QImageReader uses for reading images.
void setDevice(QIODevice *device)
Sets the current device to device.
Definition: qmovie.cpp:675
QImageReader * reader
Definition: qmovie.cpp:282
The QImageReader class provides a format independent interface for reading images from files or other...
Definition: qimagereader.h:62
virtual bool isSequential() const
Returns true if this device is sequential; otherwise returns false.
Definition: qiodevice.cpp:454
CacheMode cacheMode() const
bool canRead() const
Returns true if an image can be read for the device (i.e., the image format is supported, and the device seems to contain valid data); otherwise returns false.
int elapsed() const
Returns the number of milliseconds that have elapsed since the last time start() or restart() was cal...
Definition: qdatetime.cpp:2123
int loopCount() const
For image formats that support animation, this function returns the number of times the animation sho...
MovieState
This enum describes the different states of QMovie.
Definition: qmovie.h:82
int nextFrameNumber
Definition: qmovie.cpp:288
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
QImage currentImage() const
Returns the current frame as a QImage.
Definition: qmovie.cpp:844
bool isValid() const
Returns true if the movie is valid (e.g., the image data is readable and the image format is supporte...
Definition: qmovie.cpp:854
QIODevice * device() const
Returns the device QMovie reads image data from.
Definition: qmovie.cpp:688
bool jumpToFrame(int frameNumber)
Definition: qmovie.cpp:576
QIODevice * device() const
Returns the device currently assigned to QImageReader, or 0 if no device has been assigned...
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
Definition: qmap.h:559
void setScaledSize(const QSize &size)
Sets the scaled frame size to size.
Definition: qmovie.cpp:1096
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
QSize scaledSize() const
Returns the scaled size of the image.
QByteArray format() const
Returns the format that QMovie uses when decoding image data.
Definition: qmovie.cpp:743
int nextFrameDelay() const
Returns the number of milliseconds QMovie will wait before updating the next frame in the animation...
Definition: qmovie.cpp:933
int currentFrameNumber
Definition: qmovie.cpp:287
bool next()
Attempts to advance the animation to the next frame.
Definition: qmovie.cpp:476
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
bool isValid() const
Returns true if both the width and height is equal to or greater than 0; otherwise returns false...
Definition: qsize.h:123
void setSpeed(int percentSpeed)
Definition: qmovie.cpp:1019
MovieState state() const
Returns the current state of QMovie.
Definition: qmovie.cpp:778
QRect rect() const
Returns the pixmap&#39;s enclosing rectangle.
Definition: qpixmap.cpp:676
bool isDone()
Definition: qmovie.cpp:333
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
QObject * parent
Definition: qobject.h:92
int speed() const
bool jumpToFrame(int frameNumber)
Jumps to frame number frameNumber.
Definition: qmovie.cpp:962
bool jumpToNextFrame()
Jumps to the next frame.
Definition: qmovie.cpp:952
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
int frameCount() const
Definition: qmovie.cpp:592
The QTimer class provides repetitive and single-shot timers.
Definition: qtimer.h:56
void setFileName(const QString &fileName)
Sets the name of the file that QMovie reads image data from, to fileName.
Definition: qmovie.cpp:700
ImageReaderError error() const
Returns the type of error that occurred last.
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
QImage scaled(int w, int h, Qt::AspectRatioMode aspectMode=Qt::IgnoreAspectRatio, Qt::TransformationMode mode=Qt::FastTransformation) const
Definition: qimage.h:232
bool isEndMarker()
Definition: qmovie.cpp:250
void setBackgroundColor(const QColor &color)
Sets the background color to color.
The QIODevice class is the base interface class of all I/O devices in Qt.
Definition: qiodevice.h:66
void stop()
Stops the timer.
Definition: qtimer.cpp:284
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
Definition: qtimer.cpp:249
int frameCount() const
Returns the number of frames in the movie.
Definition: qmovie.cpp:923
virtual bool seek(qint64 pos)
For random-access devices, this function sets the current position to pos, returning true on success...
Definition: qiodevice.cpp:659
static QString fileName(const QString &fileUrl)
QImage read()
Reads an image from the device.
void clear()
Removes all items from the map.
Definition: qmap.h:444
QRect frameRect() const
Returns the rect of the last frame.
Definition: qmovie.cpp:790
int delay
Definition: qmovie.cpp:231
int imageCount() const
For image formats that support animation, this function returns the total number of images in the ani...
int playCounter
Definition: qmovie.cpp:291
bool haveReadAll
Definition: qmovie.cpp:294
CacheMode
This enum describes the different cache modes of QMovie.
Definition: qmovie.h:87
QString fileName() const
If the currently assigned device is a QFile, or if setFileName() has been called, this function retur...
QMovie::CacheMode cacheMode
Definition: qmovie.cpp:293