summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authornicolasroard <nicolasroard@google.com>2013-03-12 22:48:50 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-03-12 22:48:50 +0000
commitb2fc6a4fb6519fd998d9691e244cdbab3587b54c (patch)
tree476144671ef94aed01840f139cdfe880cab71fd5 /src
parent9a8bf36157644e4f52c9bb3561575e6bdfcdb36a (diff)
parent3243862413deeda922d2a1f087b89ceb789882b5 (diff)
downloadandroid_packages_apps_Snap-b2fc6a4fb6519fd998d9691e244cdbab3587b54c.tar.gz
android_packages_apps_Snap-b2fc6a4fb6519fd998d9691e244cdbab3587b54c.tar.bz2
android_packages_apps_Snap-b2fc6a4fb6519fd998d9691e244cdbab3587b54c.zip
Merge "Add loading resources helper functions to ImageFilterRS" into gb-ub-photos-bryce
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java
index a06c2e022..978bc8bd1 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java
@@ -18,6 +18,7 @@ package com.android.gallery3d.filtershow.filters;
import android.app.Activity;
import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
import android.support.v8.renderscript.*;
import android.util.Log;
import com.android.gallery3d.R;
@@ -119,12 +120,16 @@ public abstract class ImageFilterRS extends ImageFilter {
sOldBitmap = null;
}
- public Allocation convertRGBAtoA(Bitmap bitmap) {
+ private Allocation convertBitmap(Bitmap bitmap) {
+ return Allocation.createFromBitmap(mRS, bitmap,
+ Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
+ }
+
+ private Allocation convertRGBAtoA(Bitmap bitmap) {
Type.Builder tb_a8 = new Type.Builder(mRS, Element.U8(mRS));
ScriptC_grey greyConvert = new ScriptC_grey(mRS, mResources, R.raw.grey);
- Allocation bitmapTemp = Allocation.createFromBitmap(mRS, bitmap);
-
+ Allocation bitmapTemp = convertBitmap(bitmap);
if (bitmapTemp.getType().getElement().isCompatible(Element.U8(mRS))) {
return bitmapTemp;
}
@@ -137,6 +142,28 @@ public abstract class ImageFilterRS extends ImageFilter {
return bitmapAlloc;
}
+ public Allocation loadResourceAlpha(int resource) {
+ final BitmapFactory.Options options = new BitmapFactory.Options();
+ options.inPreferredConfig = Bitmap.Config.ALPHA_8;
+ Bitmap bitmap = BitmapFactory.decodeResource(
+ mRS.getApplicationContext().getResources(),
+ resource, options);
+ Allocation ret = convertRGBAtoA(bitmap);
+ bitmap.recycle();
+ return ret;
+ }
+
+ public Allocation loadResource(int resource) {
+ final BitmapFactory.Options options = new BitmapFactory.Options();
+ options.inPreferredConfig = Bitmap.Config.ARGB_8888;
+ Bitmap bitmap = BitmapFactory.decodeResource(
+ mRS.getApplicationContext().getResources(),
+ resource, options);
+ Allocation ret = convertBitmap(bitmap);
+ bitmap.recycle();
+ return ret;
+ }
+
public boolean isResourcesLoaded() {
return mResourcesLoaded;
}