Answer the question
In order to leave comments, you need to log in
Why can meta information be lost in a bitmap?
New to android.
The task is this: take an image by uri, resize it to reasonable sections, and send it to the server.
I came across such a moment that meta information is lost during resizing (well, or somewhere around). look pliz more experienced comrades, what's the jamb?
is = cr.openInputStream(uri);
Bitmap bm = BitmapFactory.decodeStream(is);
bm = scaleImage(bm, 2000, false);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.PNG, 100, stream);
byteArray = stream.toByteArray();
// Потом прикрепляю этот массив к AsyncHttpClient
params.put("image", new ByteArrayInputStream(byteArray));
public static Bitmap scaleImage(Bitmap realImage, float maxImageSize,
boolean filter) {
float ratio = Math.min(
(float) maxImageSize / realImage.getWidth(),
(float) maxImageSize / realImage.getHeight());
int width = Math.round((float) ratio * realImage.getWidth());
int height = Math.round((float) ratio * realImage.getHeight());
Bitmap newBitmap = Bitmap.createScaledBitmap(realImage, width,
height, filter);
return newBitmap;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question