Android examples for User Interface:ImageView
Do base64 Encode ImageView
//package com.java2s; import java.io.ByteArrayOutputStream; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.util.Base64; import android.widget.ImageView; public class Main { public static String base64Encode(ImageView imageView) { if (imageView.getDrawable() != null) { Bitmap avatarBitmap = ((BitmapDrawable) imageView.getDrawable()) .getBitmap();//from w w w . j a va2 s . c o m ByteArrayOutputStream baos = new ByteArrayOutputStream(); avatarBitmap.compress(Bitmap.CompressFormat.PNG, 70, baos); byte[] avatarByteArray = baos.toByteArray(); return Base64.encodeToString(avatarByteArray, Base64.DEFAULT); } else { return null; } } }