问题描述
我正在使用TImage在Firemonkey HD表单中显示动画GIF,但我没有看到任何动画方法。
I'm trying to display an animated GIF in a Firemonkey HD form using TImage but I do not see any methods for animation.
使用Vcl.Imaging.gifImg不是一个选项,因为类型不同。
Using Vcl.Imaging.gifImg is not an option because types differ.
有人可以建议一种方法来解决这个问题,或者可能是为了在Firemonkey下动画GIF图像的组件?
Can someone suggest a way to solve this problem or probably component to animate GIF images under Firemonkey?
我现在找到的唯一方法是:
The only way I find for now is:
-
创建TGIFImage实例并加载GIF图像
create TGIFImage instance and load the GIF image
循环通过gif.images:
loop through gif.images:
a。将当前图像保存到流
a. save current image to stream
b。 Image1.bitmap.loadFromStream [Image1是FMX:TImage]
b. Image1.bitmap.loadFromStream [Image1 is FMX:TImage]
有没有更聪明的解决方案? b $ b
Is there any smarter solution?
推荐答案
您可以将 TBitmapListAnimation 与单个图像一起使用,该图像将动画的每个框架放在长条中。例如,如果你的动画有4帧,32像素乘32像素,那么你需要创建128像素宽32像素高的图像并排添加每帧...
You can use TBitmapListAnimation with a single image which has each frame of the animation inside a long strip. eg, if your animation has 4 frames and is 32px by 32px then you need to create an image 128px wide by 32px high and add each frame side by side...
然后向表单添加 TImage (您不必在其中加载位图)
Then add a TImage to the form (you don't have to load a bitmap into this)
添加一个 TBitmapListAnimation 与TImage的父母
Add a TBitmapListAnimation with the TImage as it's parent
双击 AnimationBitmap 并加载动画图像条
下拉 PropertyName 并选择位图
将 AnimationCount 设置为4, AnimationRowCount 1为此示例
Set AnimationCount to 4 and AnimationRowCount 1 for this example
设置启用为true
TBitmapListAnimation可以很好地控制动画帧速率, ,循环和插值。我无法找到一个方法来获取.gif动画在FireMonkey2,但如果你有手段将一个动画的.gif转换为一个卡通片,那么这是一个很好的方法来做动画。
TBitmapListAnimation has good control over animation frame rates, reversing, looping and interpolation. I couldn't find a way to get a .gif to animate in FireMonkey2 but if you have the means to convert an animated .gif into a 'cartoon strip' then this is a good way to do animations.
PS这是Delphi XE3 ...所以不能说这些组件是否存在于以前的版本中。
PS This is Delphi XE3...so can't say if these components existed in previous version.
这篇关于Firemonkey中的动画GIF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!