Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions picasso/src/main/java/com/squareup/picasso/BitmapHunter.java
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ static void calculateInSampleSize(int reqWidth, int reqHeight, int width, int he
BitmapFactory.Options options) {
int sampleSize = 1;
if (height > reqHeight || width > reqWidth) {
final int heightRatio = Math.round((float) height / (float) reqHeight);
final int widthRatio = Math.round((float) width / (float) reqWidth);
final int heightRatio = (int) Math.floor((float) height / (float) reqHeight);
final int widthRatio = (int) Math.floor((float) width / (float) reqWidth);
sampleSize = heightRatio < widthRatio ? heightRatio : widthRatio;
}
options.inSampleSize = sampleSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import static android.graphics.Bitmap.Config.ARGB_8888;
import static android.graphics.Bitmap.Config.RGB_565;
import static com.squareup.picasso.BitmapHunter.calculateInSampleSize;
import static com.squareup.picasso.BitmapHunter.createBitmapOptions;
import static com.squareup.picasso.BitmapHunter.forRequest;
import static com.squareup.picasso.BitmapHunter.requiresInSampleSize;
Expand Down Expand Up @@ -388,6 +389,12 @@ public class BitmapHunterTest {
assertThat(requiresInSampleSize(justBounds)).isTrue();
}

@Test public void calculateInSampleSizeNoResize() {
final BitmapFactory.Options options = new BitmapFactory.Options();
calculateInSampleSize(100, 100, 150, 150, options);
assertThat(options.inSampleSize).isEqualTo(1);
}

@Test public void nullBitmapOptionsIfNoResizing() {
// No resize must return no bitmap options
final Request noResize = new Request.Builder(URI_1).build();
Expand Down