我希望能够将动画GIF作为输入,计算帧(以及可能的其他元数据),并将每个转换为a BufferedImage.我怎样才能做到这一点?
在动态壁纸中,我有一个Canvas实例,我希望将GIF/WEBP内容绘制成,通过Glide加载.
我想与滑翔做到这一点,原因是它在我过去找到了同样的事情(的解决方案提供了一些优势在这里,仓库在这里):
Glide似乎已经过优化,只能用于普通的UI(视图).它有一些基本的功能,但对我正在尝试做的最重要的功能似乎是私密的.
我使用官方Glide库(v 3.8.0)进行GIF加载,使用GlideWebpDecoder进行WEBP加载(使用相同版本).
加载其中每个的基本调用是这样的:
GIF:
GlideApp.with(this).asGif()
.load("https://res.cloudinary.com/demo/image/upload/bored_animation.gif")
.into(object : SimpleTarget<GifDrawable>() {
override fun onResourceReady(resource: GifDrawable, transition: Transition<in GifDrawable>?) {
//example of usage:
imageView.setImageDrawable(resource)
resource.start()
}
})
Run Code Online (Sandbox Code Playgroud)
WEBP:
GlideApp.with(this).asDrawable()
.load("https://res.cloudinary.com/demo/image/upload/fl_awebp/bored_animation.webp")
// .optionalTransform(WebpDrawable::class.java, WebpDrawableTransformation(CircleCrop()))
.into(object : SimpleTarget<Drawable>() {
override fun onResourceReady(resource: Drawable, transition: Transition<in Drawable>?) {
//example of usage:
imageView.setImageDrawable(resource)
if (resource is Animatable) {
(resource as Animatable).start()
}
}
})
Run Code Online (Sandbox Code Playgroud)
现在,请记住我并没有真正的ImageView,而是我只有一个Canvas,我可以通过surfaceHolder.lockCanvas()调用获得. …
我有一个从原始AR 贴纸 APK 中获取的动画 webp 文件,我想在我的应用程序中显示该文件,以便在 ARCore 中使用。看起来我可以轻松地将 webp 文件的第一帧加载到 imageview 中,但尝试将其解码为Movie对象失败。有没有简单的显示方法?这显然是可能的,因为 AR-Stickers 应用程序在其原始版本中清楚地做到了。我看到 Facebook (Fresco) 的一个库似乎应该能够做到这一点,但据我所知,它为我的应用程序的 APK 增加了相当多的膨胀。是否有任何简单的解决方案?