I am trying to encode/decode an image view and I looked at more than 50 examples but it still does´t work.
I did a simple thing to start with:
1) i am using the simple base 64 data from http://codebeautify.org/base64-to-image-converter#
2) i put it into a blob field of a mysql db (hosted in a remote server)
3) in android I get it correctly via a web service, decode it and show in an image view
public static Bitmap decodeBase64(String input)
{
byte[] decodedByte = Base64.decode(input.getBytes(), Base64.DEFAULT);
return BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length);
}
(so far so good)
4) i am encoding what is in the image view (placed in step 3) and generate a base64 code using
imageGrupo.buildDrawingCache();
Bitmap bitmap = imageGrupo.getDrawingCache();
ByteArrayOutputStream stream=new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 90, stream);
byte[] image=stream.toByteArray();
finalImagemStr = Base64.encodeToString(image, 0);
5) if i compare the generated base64 with the one I received in 3 they are not the same.
They should be right?
6) when placing the base64 string generated in 4) in the remote database and reading it again it says
java.lang.IllegalArgumentException: bad base-64
I am going crazy at this point... Any ideas?
Thanks Regards