Ok, I have read all questions and answers about this topic. I have been reading them for a few days and nothing worked for me so I have one straight question. This code generates one String
public String getStringImage(Bitmap bmp){
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.JPEG, 100, baos);
byte[] imageBytes = baos.toByteArray();
input = Base64.encodeToString(imageBytes, Base64.DEFAULT);
return input;
}
And this code generate other String from the same PICTURE,
<?php
$data = file_get_contents('Lake_mapourika_NZ.jpeg');
$nova = base64_encode($data);
echo $nova;
?>
When I insert them into this code back in Java :
public void decodeImage()
{
byte[] decodedByte = Base64.decode(input, Base64.DEFAULT);
bitmap = BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length);
imageView.setImageBitmap(bitmap);
}
First String wont work second works fine. Why ? Why java to java wont work and PHP to java works fine ?
Of course Strings are different that is also good question. Why are they different when they are generated from same bitmap ? To me it seems that Java decode works fine but encode wont work.
I'm using this code to send my pictures from app to server so I cant use online converters every time it has to be encoded to string from app. I don't get any errors and for pictures taken with my phone camera I get out of memory exception. But when change quality to 50 then I get decoded string but it wont work as usual.
Is there any other way to do it ?