Множество приложений разрешает совместное использование изображения, которое выбрано из галереи.
Загружают ли они исходный файл изображения? Что такое 1-3 мб? Или они обрабатываются?
В любом случае, как я могу взять изображение из пути к файлу, уменьшить его размер, понизив разрешение и сохранить его где-нибудь еще и попытаться загрузить?
Я пробовал:
Bitmap photo = decodeSampledBitmapFromFile(filePath, DESIRED_WIDTH,
DESIRED_HEIGHT);
FileOutputStream out = new FileOutputStream(filePath);
photo.compress(Bitmap.CompressFormat.JPEG, 100, out);
public static Bitmap decodeSampledBitmapFromFile(String path, int reqWidth,
int reqHeight) {
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(path, options);
final int height = options.outHeight;
final int width = options.outWidth;
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
int inSampleSize = 1;
if (height > reqHeight) {
inSampleSize = Math.round((float) height / (float) reqHeight);
}
int expectedWidth = width / inSampleSize;
if (expectedWidth > reqWidth) {
inSampleSize = Math.round((float) width / (float) reqWidth);
}
options.inSampleSize = inSampleSize;
options.inJustDecodeBounds = false;
return BitmapFactory.decodeFile(path, options);
}
Но это они правильно подходят? Потому что я видел ответы, предлагающие compression operation takes rather big amount of time
здесь