diff options
author | Tim Murray <timmurray@google.com> | 2013-03-07 22:41:46 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-03-07 22:41:46 +0000 |
commit | e0a55d0735fd6f2fc48b1d960b6d353c2d8e72e9 (patch) | |
tree | 25622a5abcc2fdcccb9fc87dbacecc6690a6e192 /src/com | |
parent | 37dae82890a04fd4912d3a704066cb800712686f (diff) | |
parent | cc3d6dcfdf3070f78fbef2b458349db71d32844b (diff) | |
download | android_packages_apps_Snap-e0a55d0735fd6f2fc48b1d960b6d353c2d8e72e9.tar.gz android_packages_apps_Snap-e0a55d0735fd6f2fc48b1d960b6d353c2d8e72e9.tar.bz2 android_packages_apps_Snap-e0a55d0735fd6f2fc48b1d960b6d353c2d8e72e9.zip |
Merge "Add convertRGBAtoA." into gb-ub-photos-bryce
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java | 20 | ||||
-rw-r--r-- | src/com/android/gallery3d/filtershow/filters/grey.rs | 22 |
2 files changed, 42 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; + + } + } diff --git a/src/com/android/gallery3d/filtershow/filters/grey.rs b/src/com/android/gallery3d/filtershow/filters/grey.rs new file mode 100644 index 000000000..e01880360 --- /dev/null +++ b/src/com/android/gallery3d/filtershow/filters/grey.rs @@ -0,0 +1,22 @@ + /* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma version(1) +#pragma rs java_package_name(com.android.gallery3d.filtershow.filters) + +uchar __attribute__((kernel)) RGBAtoA(uchar4 in) { + return in.r; +} |