无法解除$ C C使用的电影在Android 2.3.x或更低一些GIF动画文件$更低、文件、动画、电影

2023-09-05 09:59:54 作者:百裹行者

我试着用下面的代码片段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("https://m.xsw88.com/allimgs/daicuo/20230905/2061.png.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。 下面是截图: https://m.xsw88.com/allimgs/daicuo/20230905/2062.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: https://m.xsw88.com/allimgs/daicuo/20230905/2062.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