Reprinted please indicate the source:
Louiswang http://blog.csdn.net/louiswangbing/article/details/6606933
I believe this title is attractive enough.
First of all, it should be noted that I hope those who have already implemented the GIF format Image Display Do not spray me, I know how you do it, there are only two types: one is to use the existing GIF Decoding jar package, and the other is to use the open-source GIF Decoding package provided by Google. However, these two methods are used to decode GIF images in applications. I believe everyone knows how efficient Java decoding is.
Here, I want to introduce a method to display GIF images by modifying the android source code.
I believe anyone who has read the android source code knows that android uses a very powerful skia graphics engine, which is lurking in the external directory of the android source code. This engine was born and acquired by Google. It has various legends and mysteries. I will not discuss it in detail here. But Baidu, you will know how powerful this graphic engine is.
Does such a powerful graphics engine support GIF Decoding? No one will believe it.
Yes, it is supported. Obviously, there is a folder named giflib under the external directory of the android source code. It is a GIF decoder that is loaded into skia through plug-ins, but why can't I display a GIF instead of a single frame during application development?
The reason is that android is developed by default Using Simulators, and I also mentioned in the previous article that the memory and CPU resources of the simulator are quite limited, only MB of memory, for applications and functions required by various resources, such resources are obviously far from enough. Therefore, Google wants to ensure that its simulator does not "crash at any time, I quietly made some changes. Unfortunately, this intention was discovered by the monks. Even More coincidentally, this modification was too attractive and subtle, triggering my strong curiosity, so I drilled in. It was a coincidence that I found this change...
Next, I modified some of the WebKit source code (the Image Parsing part of WebKit calls skia Implementation). I was surprised to find that the android browser can play GIF images on Baidu, but obviously, this overload of work simulator is obviously not working properly, I am using the experiment that I mentioned in my previous article on android-x86 systems.
In this way, application developers can use the webview class to display GIF images. Before that, you must do the following:
1, download a android-x86 or android source code (recommended to use android-x86, this is really a very useful and interesting thing, of course, if you insist on using the simulator, I won't block you either. It's your right to eat sweet fruits instead of bitter ones)
2. Modify the source code and compile
If you read my previous article and have already followed the steps I mentioned, you only need to perform Step 2 in the above two steps, and you do not need to do either of the following steps, run the compiled ISO image file directly through the virtual machine, and you will see a miracle in Baidu GIF. If you are stubborn and need to use the simulator, I would like to provide you with the following solutions:
3. compile and generate system. IMG, userdata. IMG, and ramdisk. IMG.
4. Replace these three imgfiles with the three imgfiles in your SDK tool.
Then run the simulator, Baidu GIF, you will also find a miracle, but this "miracle" relative to the android-x86, it is really slow enough "miracle ".