I get the image from the database in blob format. I want to convert it to a Bitmap image. The code that I used to convert the bitmap to Blob is placed below. but please tell me how to cancel it. ???
ByteArrayOutputStream boas = new ByteArrayOutputStream(); btmap.compress(Bitmap.CompressFormat.JPEG, 100, boas ); //bm is the bitmap object byte[] byteArrayImage = boas .toByteArray(); String encodedImage = Base64.encodeToString(byteArrayImage, Base64.DEFAULT);
It will work
byte[] byteArray = DBcursor.getBlob(columnIndex); Bitmap bm = BitmapFactory.decodeByteArray(byteArray, 0 ,byteArray.length);
Why not create a helper method :)
public static Bitmap getBitmapFromBytes(byte[] bytes) { if (bytes != null) { return BitmapFactory.decodeByteArray(bytes, 0 ,bytes.length); } return null; }