diff options
author | Dianne Hackborn <hackbod@google.com> | 2009-07-24 16:08:52 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2009-07-24 16:08:52 -0700 |
commit | 131c48dc74e714280ec5cde7d9b24734563216dc (patch) | |
tree | 3a34fa55c05d4aa23f91cf2d560d8cf8e7b3f4e0 | |
parent | 0b5d53f28b884f30d4d61b499f8019ff53493319 (diff) | |
parent | 32ce7f17a85abf9b175f773371308876f7401547 (diff) | |
download | packages_apps_trebuchet-131c48dc74e714280ec5cde7d9b24734563216dc.zip packages_apps_trebuchet-131c48dc74e714280ec5cde7d9b24734563216dc.tar.gz packages_apps_trebuchet-131c48dc74e714280ec5cde7d9b24734563216dc.tar.bz2 |
am 32ce7f17: Update launcher to use new bitmap density API.
Merge commit '32ce7f17a85abf9b175f773371308876f7401547'
* commit '32ce7f17a85abf9b175f773371308876f7401547':
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(); |