如何使用动画图像或其他方式对超过 256 种颜色(即不是 GIF)的图像进行动画处理



我可以在Qt 5.9中使用AnimatedImage,它可以在这样的GIF上使用;

import QtQuick 2.7
import QtQuick.Controls 2.2
ApplicationWindow
{
visible: true
width: 640
height: 480
Rectangle 
{
width: animation.width; 
height: animation.height + 8
AnimatedImage 
{
id: animation;
source: "myanimation.gif"
}
Rectangle {
height: 8
width: animation.currentFrame/animation.frameCount * animation.width
y: animation.height
color: "red"
Component.onCompleted: console.log("framecount ", animation.frameCount);
}
}
}

我也收到很多错误消息。这是一遍又一遍地打印的;

QQmlExpression: Expression qrc:/main.qml:26:20 depends on non-NOTIFYable properties:
QQuickAnimatedImage::frameCount

我从这里获取了我的示例代码;http://doc.qt.io/qt-5/qml-qtquick-animatedimage.html

这根本不起作用,将frameCount放入属性中存在问题,所以我在我的版本中更改了它。

我想像apng一样制作png动画。显然曾经有mng支持,但现在不存在了。

所以我调用QMovie::supportedFormats它只返回GIF(在Windows上(。

我的问题:

我如何在支持非浅色(例如 png 等(的格式上使用AnimatedImage或者是否有另一种方法可以对图像进行动画处理?

感谢您提供任何信息。

似乎这些图像格式没有随Qt/QML的标准安装一起提供。但是,您可以将它们安装为插件。

看:

  • 文档:Qt图像格式
  • 代码/GitRepository

最新更新