I am trying to upload an image to mysql database as blob, and then upload this image which will be displayed in ImageView. The code I use to encode an image using Base64 is:
ByteArrayOutputStream baos = new ByteArrayOutputStream();
screen.compress(Bitmap.CompressFormat.PNG, 100, baos);
byte[] imageBytes = baos.toByteArray();
encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT);
and the code that I use to display the image after downloading it is:
byte[] decodedString = Base64.decode(encodedImage, Base64.URL_SAFE);
currentImage = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
I have tried some solutions posted by other users, including using FlushedInputStream. Does anyone have any ideas?
source
share