Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Image provider for animated images?
Qt 6.11 is out! See what's new in the release blog

Image provider for animated images?

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 3 Posters 5.2k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    coyotte508
    wrote on last edited by
    #1

    Is there any way to use an image provider for those?

    Taken from the doc of "AnimatedImage":http://qt-project.org/doc/qt-4.8/qml-animatedimage.html:

    @source : url

    This property holds the URL that refers to the source image.

    AnimatedImage can handle any image format supported by Qt, loaded from any URL scheme supported by Qt.

    See also QDeclarativeImageProvider.
    @

    Yet I can't see any way to load an animated sprite from a QDeclarativeImageProvider. (I need that because my sprites are zipped)

    Thanks.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlong
      wrote on last edited by
      #2

      If you implemented your own subclass of QDeclarativeImageProvider, it would be responsible for loading your sprites, unzipping them, and providing them in an AnimatedImage-compatible format (which can be determined through "QMovie::supportedFormats()":/doc/qt-4.8/qmovie.html#supportedFormats )

      Can you provide more detail on the aspects of the scenario you're having trouble with?

      Software Engineer
      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        coyotte508
        wrote on last edited by
        #3

        I don't think you can store an animated image in a QImage.

        Anyway I tried:

        @QImage PokemonInfoAccessor::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
        {
        (void) requestedSize;

        QImage ret;
        
        qDebug() << QImageReader::supportedImageFormats();
        
        ret = QImage("500.gif"); //for now let's try with a hardcoded url
        *size = ret.size();
        
        return ret;
        

        }@

        and in the qml file

        @AnimatedImage {
        anchors.horizontalCenter: parent.horizontalCenter;
        anchors.bottom: parent.bottom;

            source: "image://pokeinfo/test"
        
            smooth: false
        }@
        

        And I get this output:

        bq. ("BW", "EPS", "EPSF", "EPSI", "EXR", "PCX", "PSD", "RAS", "RGB", "RGBA", "SGI", "TGA", "XCF", "bmp", "bw", "dds", "eps", "epsf", "epsi", "exr", "gif", "ico", "jp2", "jpeg", "jpg", "mng", "pbm", "pcx", "pgm", "pic", "png", "ppm", "psd", "ras", "rgb", "rgba", "sgi", "svg", "svgz", "tga", "tif", "tiff", "xbm", "xcf", "xpm", "xv")
        Reading ras files from sequential devices not supported
        Reading ras files from sequential devices not supported
        file:///home/path/to/file.qml:63:5: QML QDeclarativeAnimatedImage_QML_15: Error Reading Animated Image File QUrl("image://pokeinfo/test")

        So there's an error even though gif is in the supported formats. When I load the gif directly in the qml file it works.

        Also the image provider class is clearly called from the error messages so there's no problem there.

        As for my scenario, I am simply trying to load an animated image through an image provider. If this doesn't work, I'll probably load a non-animated image temporarily and load the animated image from an http url, or I'll extract the image from the zip and write it into a temporary file before loading it :(. At the moment i'm just loading non-animated images from the zip with my current image provider.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mlong
          wrote on last edited by
          #4

          bq. I don’t think you can store an animated image in a QImage.

          Ah, you're right. I hadn't thought the repercussions of that through.

          Software Engineer
          My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Schluchti
            wrote on last edited by
            #5

            Hi,

            sorry for bringing the old thread back to life, but does anyone know if there is now a way to accomplish this? My problem is, that I receive a gif over network that I want to assign to an Animated Image. For normal images I subclassed ImageProvider which works pretty well. But unfortunately it doesn't work for gifs.

            Any ideas?

            Want to read more about Qt?

            https://gympulsr.com/blog/qt/

            Latest Article: https://gympulsr.com/blog/qt/2017/06/14/ios-background-music-qt.html

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved