Код: Выделить всё
for (int i = 0; i < current_count; i++) {
index = i;
try {
assert getActivity() != null;
bitmap = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(), uris.get(i));
int width = bitmap.getWidth();
int height = bitmap.getHeight();
Log.d("Logs", "--width, height-" + width + "-" + height + "--");
converetdBitmap = getResizedBitmap(bitmap, 1280);
uploadImagesToDatabase(i, converetdBitmap, current_count);
} catch (IOException e) {
}
}
Код: Выделить всё
public Bitmap getResizedBitmap(Bitmap image, int maxSize) {
int width = image.getWidth();
int height = image.getHeight();
Log.d("Logs", "--width, height-" + width + "-" + height + "--");
float bitmapRatio = (float) width / (float) height;
if (bitmapRatio > 1) {
width = maxSize;
height = (int) (width / bitmapRatio);
} else {
height = maxSize;
width = (int) (height * bitmapRatio);
}
Log.d("logs", "-- width, height-" + width + "-" + height + "--");
return Bitmap.createScaledBitmap(image, width, height, true);
}
bitmap = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(), uris.get(i));
Пожалуйста помогите мне в этом. Спасибо!
Подробнее здесь: https://stackoverflow.com/questions/792 ... lways-rota