分割成GIF帧GIF

2023-09-05 10:26:20 作者:我要感谢你,赠我空欢喜

想在这里玩的GIF动画在Android上(请参阅http://stackoverflow.com/questions/809878/android-how-do-a-display-a-large-animated-gif-given-a-url).这是很不顺利。在Android 1.5中,Movie.de codeStream()/德codeFILE()返回一个空。在Android 1.6,与GIF文件,我已经有了,它返回一个零大小电影与零时间 - 显然不足以

Trying to play animated GIFs on Android here (see http://stackoverflow.com/questions/809878/android-how-do-a-display-a-large-animated-gif-given-a-url). It's anything but smooth. On Android 1.5, the Movie.decodeStream()/decodeFile() returns a null. On Android 1.6, with the GIF files I've got, it returns a zero-sized movie with zero duration - clearly not adequate.

引用的问题,建议拆分成GIF帧(然后渲染这些)。究竟如何做我实现这个目标,好吗?

The referenced question suggests splitting the GIF into frames (and then rendering these). How exactly do i accomplish that, please?

编辑:试图打开我的GIF与GNU giflib在Windows之一。它哽咽的第一帧。该GIF本身是好的,所有的浏览器(SAVE Android的)显示器和精美的动画吧。

tried opening one of my GIFs with GNU giflib in Windows. It choked on the very first frame. The GIF itself is all right, all browsers (save Android's) display and animate it fine.

EDIT2:与giflib 4.1.4工作。不知道在4.1.6被打破,但你去那里。下一步:通过NDK编译giflib为Android,不知何故与Bitmap类整合

worked with giflib 4.1.4. Not sure what was broken in 4.1.6, but there you go. Next step: build giflib for Android via NDK, somehow integrate with the Bitmap class.

EDIT3:giflib它。在同一起选择Bitmap.copyPixelsFromBuffer。这些颜色都是歪的权利,但基本的设计似乎是可行的。

giflib it is. In conjuction with Bitmap.copyPixelsFromBuffer. The colors are all askew right now, but the basic design seems workable.

推荐答案

giflib 4.1.4和NDK。您必须手动解决调色板颜色的GIF,以配合Android的ARGBxxxx格式中的一种,然后通过像素阵列到位图对象通过 copyPixelsFromBuffer( )。如果你想要的透明度和/或动画,你必须要经过extsntion块,寻找一个与code 0xf9。

giflib 4.1.4 and NDK. You have to manually resolve the palette colors in the GIF to match one of Android's ARGBxxxx formats, then pass the pixel array to a Bitmap object via copyPixelsFromBuffer(). If you want transparency and/or animation, you have to go through extsntion blocks and look for the one with code 0xf9.

我的共享code,以及指导,此处的http://rathertech.blogspot.com/2014/04/splitting-gif-into-frames-on-android.html

Shared my code, along with guidance, here: http://rathertech.blogspot.com/2014/04/splitting-gif-into-frames-on-android.html

 
精彩推荐
图片推荐