43. Android Base64Util

Source: Internet
Author: User

43. Android Base64Util
43. Android Base64Util

Public class Base64Util {/*** convert bitmap to base64 ** @ param bitmap * @ return base64 */public String bitmapToBase64 (Bitmap bitmap) {// convert Bitmap to String base64; ByteArrayOutputStream bStream = new ByteArrayOutputStream (); bitmap. compress (Bitmap. compressFormat. PNG, 100, bStream); byte [] bytes = bStream. toByteArray (); base64 = Base64.encodeToString (bytes, Base64.DEFAULT); return base64 ;} /*** convert base64 to bitmap ** @ param base64 base64 * @ return bitmap */public Bitmap base64ToBitmap (String base64) {// convert String to Bitmap type Bitmap bitmap = null; try {byte [] bitmapArray; bitmapArray = Base64.decode (base64, Base64.DEFAULT); bitmap = BitmapFactory. decodeByteArray (bitmapArray, 0, bitmapArray. length);} catch (Exception e) {e. printStackTrace () ;}return bitmap ;}}

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.