Detailed explanation of Android webp codec

key words:android decode webp sample

When I knocked down the keyboard, I felt a deep sense of shame. I saw that Android 4.0 supported webp format images, so I desperately looked for what kind of API was provided, NND, but I couldn't find it. Later, I tried to read it with bitmapfactory, and the result was no problem. Come to a conclusion, as a code farmer, you should dare to think, try and do!

Webp decoding

It's no different from decoding jpg. Put the picture in drawable or somewhere else, and then

Bitmap bmp = BitmapFactory. decodeResource(getResources(),R.raw.webp); imv. setImageBitmap(bmp);

After this, it's put on ImageView. Of course, this method is only feasible in 4.0. If you want to be compatible with older versions (Android devices under 4.0), you need to use JNI. Here is the method provided above for stack overflow. You can try it if you need it. It's not much trouble to encapsulate it with JNI. Don't get it here. Give me a link. You can get it if you need it.

http://stackoverflow.com/questions/7032695/webp-for-android

Webp Code:

The coding is no different from your bitmap coding, ICS's bitmap Compressformat has webp in the enumeration, so it supports encoding into this format. have fun,good luck!

The above is about the data sorting of Android webp codec. We will continue to supplement relevant data in the future. Thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>