diff options
Diffstat (limited to 'src/com/android/wallpaper/util/BitmapProcessor.java')
-rw-r--r-- | src/com/android/wallpaper/util/BitmapProcessor.java | 29 |
1 files changed, 3 insertions, 26 deletions
diff --git a/src/com/android/wallpaper/util/BitmapProcessor.java b/src/com/android/wallpaper/util/BitmapProcessor.java index 590164d0..04873461 100644 --- a/src/com/android/wallpaper/util/BitmapProcessor.java +++ b/src/com/android/wallpaper/util/BitmapProcessor.java @@ -15,61 +15,38 @@ */ package com.android.wallpaper.util; -import android.content.Context; import android.graphics.Bitmap; import android.graphics.Rect; import android.util.Log; -import com.google.android.renderscript.Toolkit; - /** * Class with different bitmap processors to apply to bitmaps */ public final class BitmapProcessor { private static final String TAG = "BitmapProcessor"; - private static final float BLUR_RADIUS = 20f; private static final int DOWNSAMPLE = 5; private BitmapProcessor() { } /** - * Function that blurs the content of a bitmap. + * Function that transforms a bitmap into a lower resolution. * - * @param context the Application Context * @param bitmap the bitmap we want to blur. * @param outWidth the end width of the blurred bitmap. * @param outHeight the end height of the blurred bitmap. * @return the blurred bitmap. */ - public static Bitmap blur(Context context, Bitmap bitmap, int outWidth, - int outHeight) { - Bitmap inBitmap = null; - + public static Bitmap createLowResBitmap(Bitmap bitmap, int outWidth, int outHeight) { try { Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); WallpaperCropUtils.fitToSize(rect, outWidth / DOWNSAMPLE, outHeight / DOWNSAMPLE); - inBitmap = Bitmap.createScaledBitmap(bitmap, rect.width(), rect.height(), + return Bitmap.createScaledBitmap(bitmap, rect.width(), rect.height(), true /* filter */); - - // Render script blurs only support ARGB_8888, we need a conversion if we got a - // different bitmap config. - if (inBitmap.getConfig() != Bitmap.Config.ARGB_8888) { - Bitmap oldIn = inBitmap; - inBitmap = oldIn.copy(Bitmap.Config.ARGB_8888, false /* isMutable */); - oldIn.recycle(); - } - - return Toolkit.INSTANCE.blur(inBitmap, (int) BLUR_RADIUS); - } catch (IllegalArgumentException ex) { Log.e(TAG, "error while blurring bitmap", ex); - } finally { - if (inBitmap != null) { - inBitmap.recycle(); - } } return null; |