English 中文(简体)
Fail to decode some animated GIF file using pornography on 2.3.x or low
原标题:Failed to decode some animated GIF files using Movie on Android 2.3.x or lower

我尝试使用以下刀具编码,将 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.

最佳回答

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

问题回答

What version of Android are you running on? Support for animated GIF in the Movie class was quite limited before this commit is merged into the AOSP code around September 2010, which I believe is after the first Gingerbread release (API level 9).

Most likely the other apps that works have their own internal GIF decoding code and did not use the Movie class.

UPDATE:我走过前面,并测试了关于roid-10(GB MR2)和roid-14(ICS)的代用品。 关于roid-10的推介器,图像仍然不适当地编码,但对于roid--14的推介器来说,它进行罚款。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签