Never resize a Bitmap down to 0 at load time

Bug #8313929

Change-Id: Ic9b691319f162228c72ad1afed4dfe0b4181c422
This commit is contained in:
Romain Guy
2013-03-04 17:55:55 -08:00
parent 19d4dd8599
commit fe28ef84f2

View File

@@ -566,8 +566,9 @@ public class BitmapFactory {
float scale = targetDensity / (float) density;
if (scale != 1.0f) {
final Bitmap oldBitmap = bm;
bm = Bitmap.createScaledBitmap(oldBitmap, (int) (bm.getWidth() * scale + 0.5f),
(int) (bm.getHeight() * scale + 0.5f), true);
bm = Bitmap.createScaledBitmap(oldBitmap,
Math.max(1, (int) (bm.getWidth() * scale + 0.5f)),
Math.max(1, (int) (bm.getHeight() * scale + 0.5f)), true);
if (bm != oldBitmap) oldBitmap.recycle();
if (isNinePatch) {