I need to save my static image view to the shared preference, so that i can fit in the image to the HTML document. I even did try by encoding and decoding the Bitmap image using Base64.
public static String encodeToBase64(Bitmap image) {
Bitmap bImage = image;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bImage.compress(Bitmap.CompressFormat.PNG, 100, baos);
byte[] bytes = baos.toByteArray();
String imageEncoded = Base64.encodeToString(bytes, Base64.DEFAULT);
return imageEncoded;
}
public static Bitmap decodeBase64(String input) {
byte[] decodeByte = Base64.decode(input, 0);
return BitmapFactory.decodeByteArray(decodeByte, 0, decodeByte.length);
}