无法解除$ C C使用的电影在Android 2.3.x或更低一些GIF动画文件$ [英] Failed to decode some animated GIF files using Movie on Android 2.3.x or lower
问题描述
我试着用下面的代码片段code脱$ C C与电影类的动画GIF文件$。
I tried using the following snippet code to decode the animated gif file with the Movie class.
URL url;
InputStream is = null;
BufferedInputStream bis = null;
url = new URL("http://emos.plurk.com/aeddddbbf63e980128ab7b3c1fca2798_w48_h48.gif");
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
is = httpURLConnection.getInputStream();
bis = new BufferedInputStream(is);
byte[] array = streamToBytes(bis);
mGifMovie = Movie.decodeByteArray(array, 0, array.length);
和借鉴电影中的overrided的OnDraw方法扩展ImageView的是这样的:
and draw the Movie in the overrided onDraw method in an extended ImageView like this:
if (mGifMovie != null) {
long now = android.os.SystemClock.uptimeMillis();
if (mMovieStart == 0) { // first time
mMovieStart = now;
}
if (mGifMovie != null) {
int dur = mGifMovie.duration();
if (dur == 0) {
dur = 1000;
}
int relTime = (int) ((now - mMovieStart) % dur);
mGifMovie.setTime(relTime);
mGifMovie.draw(canvas, 0, 0);
invalidate();
}
}
有些gif动画作品,但另一些像这样的都没有。 它推出了一些帧未能被取消code。 下面是截图: http://i.imgur.com/HsxcP.png (原始图像: http://emos.plurk.com/aeddddbbf63e980128ab7b3c1fca2798_w48_h48.gif )
Some animated gif works, but some others like this one are not. It came out with some frames are failed to be decode. Here is the screenshot: http://i.imgur.com/HsxcP.png (original image: http://emos.plurk.com/aeddddbbf63e980128ab7b3c1fca2798_w48_h48.gif)
我与市场上其他的应用程序进行测试。 他们去code中的gif动画成功。 我应该怎样做正确的吗?
I tested with some other apps on the market. They decode the animated gif successfully. How should I make it correct?
编辑: 我想取消$ C C的动画GIF $正确像市场上的这些应用程序我2.3.x设备。
I would like to decode the animated Gif correctly on my 2.3.x devices like those apps on the market.
推荐答案
我原来使用自定义的GIF德codeR根据3.0的设备上运行。 下面是Java示例code:的http://www.java2s.com/$c$c/Java/2D-Graphics-GUI/De$c$csaGIFfileintooneormoreframes.htm
I turned out to use custom gif decoder to run on under 3.0 devices. Here is the java sample code: http://www.java2s.com/Code/Java/2D-Graphics-GUI/DecodesaGIFfileintooneormoreframes.htm
这篇关于无法解除$ C C使用的电影在Android 2.3.x或更低一些GIF动画文件$的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!