Key words: Android decode webp sample
When I knocked on the keyboard, I felt a deep sense of shame. I saw Android 4.0 support webp format images, so I was desperate to find what APIs I provided. nnd was hard to find, later, I tried to use bitmapfactory to read it, and the result was no problem. Come to the conclusion that, as a code farmer, dare to think, dare to try and dare to do it!
Webp Decoding
It's no different from decoding JPG. Put the image in drawable or somewhere else and
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.raw.webp); imv.setImageBitmap(bmp);
Put it on the imageview. Of course, this method is only feasible in 4.0. If you want to be compatible with earlier versions (Android devices earlier than 4.0), you need to use JNI. The method provided above stackoverflow is provided here. You can try it if necessary. It is not too troublesome to use JNI encapsulation. Here we will not get it. Give a link and you can get it if necessary.
Http://stackoverflow.com/questions/7032695/webp-for-android
Webp encoding:
Encoding is no different from Bitmap encoding. webp is included in the bitmap. compressformat enumeration of ICS, so it supports encoding in this format. Have fun, good luck!
Source