我尝试使用以下刀具编码,将 an酸 file文档与电影类别编码。
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);
a. 在《图像评论》中,以压倒多数的“Draw”方法制作的电影:
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();
}
}
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: https://i.stack.imgur.com/le4bC.png (original image: http://emos.plurk.com/aeddddbbf63e980128ab7b3c1fca2798_w48_h48.gif)
I tested with some other apps on the market. They decode the animated gif successfully. How should I make it correct?
EDIT: I would like to decode the animated Gif correctly on my 2.3.x devices like those apps on the market.