summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java
diff options
context:
space:
mode:
authorTim Murray <timmurray@google.com>2013-03-07 22:41:46 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-03-07 22:41:46 +0000
commitde72a83d12de1183c8382c609af2da6ac829c011 (patch)
tree7595ca629783114bb2bca069df4baf85b7966246 /src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java
parent62a1046c9482b4ac54d73130623ba7e37da2f275 (diff)
parenta7723fb08098c0c7682b02cf459cafa3792a4ce4 (diff)
downloadandroid_packages_apps_Gallery2-de72a83d12de1183c8382c609af2da6ac829c011.tar.gz
android_packages_apps_Gallery2-de72a83d12de1183c8382c609af2da6ac829c011.tar.bz2
android_packages_apps_Gallery2-de72a83d12de1183c8382c609af2da6ac829c011.zip
Merge "Add convertRGBAtoA." into gb-ub-photos-bryce
Diffstat (limited to 'src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java')
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java
index a3467edde..4373c950a 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java
@@ -20,6 +20,7 @@ import android.app.Activity;
import android.graphics.Bitmap;
import android.support.v8.renderscript.*;
import android.util.Log;
+import com.android.gallery3d.R;
public abstract class ImageFilterRS extends ImageFilter {
private final String LOGTAG = "ImageFilterRS";
@@ -118,4 +119,23 @@ public abstract class ImageFilterRS extends ImageFilter {
sOldBitmap = null;
}
+ public 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);
+
+ if (bitmapTemp.getType().getElement().isCompatible(Element.U8(mRS))) {
+ return bitmapTemp;
+ }
+
+ tb_a8.setX(bitmapTemp.getType().getX());
+ tb_a8.setY(bitmapTemp.getType().getY());
+ Allocation bitmapAlloc = Allocation.createTyped(mRS, tb_a8.create());
+ greyConvert.forEach_RGBAtoA(bitmapTemp, bitmapAlloc);
+
+ return bitmapAlloc;
+
+ }
+
}