Skip to content

Commit 77bc178

Browse files
committed
Issue nostra13#508 - Fixed "Bitmap too large ..." for all ImageScaleTypes
1 parent f82bf56 commit 77bc178

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

library/src/com/nostra13/universalimageloader/utils/ImageSizeUtils.java

+14
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,24 @@ public static int computeImageSampleSize(ImageSize srcSize, ImageSize targetSize
124124
if (scale < 1) {
125125
scale = 1;
126126
}
127+
scale = considerMaxTextureSize(srcWidth, srcHeight, scale, powerOf2Scale);
127128

128129
return scale;
129130
}
130131

132+
private static int considerMaxTextureSize(int srcWidth, int srcHeight, int scale, boolean powerOf2) {
133+
final int maxWidth = maxBitmapSize.getWidth();
134+
final int maxHeight = maxBitmapSize.getHeight();
135+
while ((srcWidth / scale) > maxWidth || (srcHeight / scale) > maxHeight) {
136+
if (powerOf2) {
137+
scale *= 2;
138+
} else {
139+
scale++;
140+
}
141+
}
142+
return scale;
143+
}
144+
131145
/**
132146
* Computes minimal sample size for downscaling image so result image size won't exceed max acceptable OpenGL
133147
* texture size.<br />

0 commit comments

Comments
 (0)