I am trying to convert a bitmap to base64 using gzip.
I tried the solution here but I got this error GZIP cannot be resolved or is not a field
My solution below is working but the image is being cut at the bottom
this is my code:
Bitmap myBitmap = BitmapFactory.decodeFile("\path\to\file.jpg");
ByteArrayOutputStream stream=new ByteArrayOutputStream();
GZIPOutputStream gzipOstream=null;
try {
gzipOstream=new GZIPOutputStream(stream);
} catch (IOException e) {
e.printStackTrace();
}
myBitmap.compress(Bitmap.CompressFormat.JPEG, 100, gzipOstream);
byte[] byteArry=stream.toByteArray();
String encodedImage = Base64.encodeToString(byteArry, Base64.NO_WRAP);
try {
gzipOstream.close();
stream.close();
} catch (IOException e) {
e.printStackTrace();
}
could this code make the image lose data or is it something on the server side?