Image provider for animated images?



  • 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.


  • Moderators

    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?



  • 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.


  • Moderators

    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.



  • 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?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.