I'm using Qt 5.2 and I have a QImage. If it detects an image url (such as an imgur link) it downloads that image and displays it. I want to also animate it if the image is animated (such as a gif).
I tried going by extension, but some links will end in jpg and still be animated. I'm currently using QImage::format()
to check for Format_ARGB32_Premultiplied
but I've come across some animated images that come back as Format_RGB32
or Format_ARGB32
which is the same format as static images.
Is there a better way that I can check that header info to get more consistent results?
Use QImageReader
to read the image, and QImageReader::supportsAnimation()
and QImageReader::imageCount()
to check if it's an animated image. Once you have only a QImage
, that information will be lost, as QImage
represents only one frame, i.e. a static image.
To display animated images, use QMovie
. In QtQuick, the element AnimatedImage
displays animated images.