Recently, I have been studying the implementation of GIF on Android and have some experiences. Now I want to share it with you.
At first, I saw the implementation of GIF on my mobile phone. It was an application of GIF kuaishou on the iPhone. I felt pretty good and wanted to implement it on Android. I checked it later. In the past, there was also a GIF kuaishou on Android, And the next one provided a good experience. Decompilation (sorry, you should use obfuscated compilation ). JavaAlgorithmBut the encoding is called JNI. Okay, then Google.
There are still a lot of GIF codec codes. I found a Java Algorithm and modified it corresponding to the GIF kuaishou decoding algorithm because AWT is used in the Java Algorithm, so you need to modify it on Android.
The last modification was successful. The general process is as follows:
1. initialize gifdecoder.
2. Set bitmap and the delay time for each frame,
3. Start decode and get framecount,
4. Set delay through handler, get the Buf of each frame, and re-paint ondraw. Good results
CodeI will not post it. If you need it, contact me via QQ,
As for the GIF encoding, it is quite tangled. I use the GIF Decoding demo to push back, so that three images can be added to a GIF file, however, only the first image is displayed, which is a bit depressing. the Java Algorithm of encoding cannot be completely changed to Android. So there will be such a problem.
Well, if it doesn't work, let's change the way. Google saw the support of Microsoft's. Net class library.
Http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.gifbitmapdecoder.aspx
Ah. Not applicable. Seeing the C algorithm or Java algorithm written by others is not very suitable. Please study it together. I have found some materials to study it together to save time.
If you find a proper encoding method, I will make it available in time. please correct me if there is anything wrong. TKs.
Source download