Answer the question
In order to leave comments, you need to log in
How to qualitatively compress an image?
Tell me how to compress the image better, now I have the following code and the following results:
//путь к изображению
fullPictureObj.get(0).getPath();
File decodeFile = new File(fullPictureObj.get(0).getPath());
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap bitmapFull = BitmapFactory.decodeFile(fullPictureObj.get(0).getPath(), options);
int imageHeight = options.outHeight;
int imageWidth = options.outWidth;
//Ориентация изображения
Bitmap rotateBitmap = rotateBitmap(bitmapFull,
fullPictureObj.get(0).getRealOrientation());
bitmapFull.recycle();
int newWidth = 960;
float k = (float) imageWidth/ (float) newWidth;
float newHeightFloat = ((float) imageHeight/k);
int newHeight = (int) newHeightFloat;
/*
int maxSize = 960;
if(imageWidth > imageHeight){
newWidth = maxSize;
newHeight = (imageHeight * maxSize) / imageWidth;
} else {
newHeight = maxSize;
newWidth = (imageWidth * maxSize) / imageHeight;
}
*/
Bitmap bitmapMini = Bitmap.createScaledBitmap(rotateBitmap, newWidth, newHeight, false);
// rotateBitmap.recycle();
//Сохраняю изображения для сравнения и теста
MediaStore.Images.Media.insertImage(getContext().getContentResolver(),
bitmapMini, "test" , null);
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