Görüntünüz kare, çünkü width = 960
ve height = 960
ayarlıyorsunuz. Zaten bellekte özgün bit eşlem varsa
public static Bitmap lessResolution (String filePath, int width, int height) {
int reqHeight = height;
int reqWidth = width;
BitmapFactory.Options options = new BitmapFactory.Options();
// First decode with inJustDecodeBounds=true to check dimensions
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(filePath, options);
// Calculate inSampleSize
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
// Decode bitmap with inSampleSize set
options.inJustDecodeBounds = false;
return BitmapFactory.decodeFile(filePath, options);
}
private static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) {
final int height = options.outHeight;
final int width = options.outWidth;
int inSampleSize = 1;
if (height > reqHeight || width > reqWidth) {
// Calculate ratios of height and width to requested height and width
final int heightRatio = Math.round((float) height/(float) reqHeight);
final int widthRatio = Math.round((float) width/(float) reqWidth);
// Choose the smallest ratio as inSampleSize value, this will guarantee
// a final image with both dimensions larger than or equal to the
// requested height and width.
inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio;
}
return inSampleSize;
}
Yorumunuzu detaylandırır mısınız? "Bu görüntü için tek kullanım ölçeklenmiş bir versiyonsa, Tobiel'in cevabını kullanarak daha iyi misiniz?" – EGHDK
Yani, sadece * ölçeklenmiş kullanıyorsanız, diğer cevabı kullanın. Bu şekilde kullanıyorsan daha verimli. Zaten tam ölçekli bir sürümünü yüklüyorsanız/görüntülüyorsanız, bu yöntem iyidir, çünkü her iki durumda da belleğe ihtiyacınız olacaktır. – Geobits
Gotcha. Bunu temizlediğiniz için teşekkürler. – EGHDK