diff options
author | Dianne Hackborn <hackbod@google.com> | 2009-07-22 21:56:50 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2009-07-23 20:09:20 -0700 |
commit | 32ce7f17a85abf9b175f773371308876f7401547 (patch) | |
tree | 937347b8382722b143591e220d640d2d6b2c4fd5 | |
parent | 142868a4a48a10dca5a0429c9631b8c57911a529 (diff) | |
download | packages_apps_trebuchet-32ce7f17a85abf9b175f773371308876f7401547.zip packages_apps_trebuchet-32ce7f17a85abf9b175f773371308876f7401547.tar.gz packages_apps_trebuchet-32ce7f17a85abf9b175f773371308876f7401547.tar.bz2 |
Update launcher to use new bitmap density API.
-rw-r--r-- | src/com/android/launcher/Utilities.java | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/com/android/launcher/Utilities.java b/src/com/android/launcher/Utilities.java index 33b084b..4a22cba 100644 --- a/src/com/android/launcher/Utilities.java +++ b/src/com/android/launcher/Utilities.java @@ -25,6 +25,7 @@ import android.graphics.Canvas; import android.graphics.PaintFlagsDrawFilter; import android.graphics.Paint; import android.graphics.Rect; +import android.util.DisplayMetrics; import android.content.res.Resources; import android.content.Context; @@ -54,6 +55,7 @@ final class Utilities { Bitmap centered = Bitmap.createBitmap(bitmapWidth < width ? width : bitmapWidth, bitmapHeight < height ? height : bitmapHeight, Bitmap.Config.RGB_565); + centered.setDensity(bitmap.getDensity()); Canvas canvas = new Canvas(centered); canvas.drawColor(color); canvas.drawBitmap(bitmap, (width - bitmapWidth) / 2.0f, (height - bitmapHeight) / 2.0f, @@ -93,16 +95,11 @@ final class Utilities { painter.setIntrinsicWidth(width); painter.setIntrinsicHeight(height); } else if (icon instanceof BitmapDrawable) { - float displayDensity = context.getResources().getDisplayMetrics().density; + // Ensure the bitmap has a density. BitmapDrawable bitmapDrawable = (BitmapDrawable) icon; Bitmap bitmap = bitmapDrawable.getBitmap(); - float iconDensity = bitmap.getDensityScale(); - scale = displayDensity / iconDensity; - - // Scale the bitmap to the screen density size if it's not loaded at the same density. - if (scale != 1.0f) { - icon = bitmapDrawable = new BitmapDrawable(bitmap); - bitmapDrawable.setDensityScale(scale); + if (bitmap.getDensity() == Bitmap.DENSITY_NONE) { + bitmapDrawable.setTargetDensity(context.getResources().getDisplayMetrics()); } } int iconWidth = icon.getIntrinsicWidth(); |