Android webp Codec

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.