Firemonkey 中的动画 GIF [英] Animated GIF in Firemonkey

查看:24
本文介绍了Firemonkey 中的动画 GIF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 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:

  1. 创建 TGIFImage 实例并加载 GIF 图片

  1. create TGIFImage instance and load the GIF image

遍历 gif.images:

loop through gif.images:

一个.将当前图像保存到流

a. save current image to stream

B.Image1.bitmap.loadFromStream [Image1 是 FMX:TImage]

b. Image1.bitmap.loadFromStream [Image1 is FMX:TImage]

有没有更聪明的解决方案?

Is there any smarter solution?

推荐答案

您可以将 TBitmapListAnimation 与单个图像一起使用,该图像的每一帧动画都在一个长条中.例如,如果您的动画有 4 帧并且是 32 像素 x 32 像素,那么您需要创建一个 128 像素宽 x 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并加载您的动画图像条

Double click AnimationBitmap and load your animation image strip

下拉PropertyName并选择位图

在此示例中将 AnimationCount 设置为 4 并将 AnimationRowCount 设置为 1

Set AnimationCount to 4 and AnimationRowCount 1 for this example

设置启用为真

TBitmapListAnimation 可以很好地控制动画帧速率、反转、循环和插值.我找不到在 FireMonkey2 中获得 .gif 动画的方法,但如果您有办法将动画 .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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆