Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Format code
  • Loading branch information
beroso committed Jan 12, 2023
commit ed04a7118b01ec14188ebda7780b9aa4f289be69
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ String resizeImageIfNeeded(
try {
String[] pathParts = imagePath.split("/");
String imageName = pathParts[pathParts.length - 1];
options.inSampleSize = calculateInSampleSize(options, maxWidth.intValue(), maxHeight.intValue());
options.inSampleSize =
calculateInSampleSize(options, maxWidth.intValue(), maxHeight.intValue());
options.inJustDecodeBounds = false;
File file = resizedImage(decodeFile(imagePath, options), maxWidth, maxHeight, imageQuality, imageName);
File file =
resizedImage(
decodeFile(imagePath, options), maxWidth, maxHeight, imageQuality, imageName);
copyExif(imagePath, file.getPath());
return file.getPath();
} catch (IOException e) {
Expand Down Expand Up @@ -143,8 +146,7 @@ private int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, i
if (height > reqHeight || width > reqWidth) {
final int halfHeight = height / 2;
final int halfWidth = width / 2;
while ((halfHeight / inSampleSize) >= reqHeight
&& (halfWidth / inSampleSize) >= reqWidth) {
while ((halfHeight / inSampleSize) >= reqHeight && (halfWidth / inSampleSize) >= reqWidth) {
inSampleSize *= 2;
}
}
Expand Down