android-renderscript

Increment a count variable in RenderScript

馋奶兔 提交于 2020-01-05 05:46:06
问题 I want to count the pixels of a bitmap using the following RenderScript code RenderScript Filename: counter.rs #pragma version(1) #pragma rs java_package_name(com.mypackage) #pragma rs_fp_relaxed uint count; // initialized in Java void countPixels(uchar4* unused, uint x, uint y) { rsAtomicInc(&count); } Java Application context = ...; // The application context RenderScript rs = RenderScript.create(applicationContext); Bitmap bitmap = ...; // A random bitmap Allocation allocation = Allocation

Renderscript ScriptIntrinsicYuvToRGB and Bitmap allocation

旧巷老猫 提交于 2019-12-25 03:34:25
问题 I want to make my own SurfaceView and send there a frames which I've obtained from onPreviewFrame(byte[] data, Camera camera) method. To do it, I need to conver frames from Yuv to ARGB and to draw them to a Canvas to my SurfaceView. Here is my onPreviewFrame: public void onPreviewFrame(byte[] data, Camera camera) { if (camera != null) { camera.addCallbackBuffer(data); } // using RenderScript Bitmap bitmap = RenderScriptFilter.convertYuvToRgbIntrinsic(rs, data, PREVIEW_WIDTH, PREVIEW_HEIGHT);

RenderScript No Class Def found, when trying to blur background image

跟風遠走 提交于 2019-12-25 03:13:25
问题 When trying to blur an image I want to use import android.support.v8.renderscript.* So I put this in my build.gradle file: android { compileSdkVersion 23 buildToolsVersion '23.0.1'" defaultConfig { minSdkVersion 14 targetSdkVersion 23 renderscriptTargetApi 18 renderscriptSupportModeEnabled true }} And I use this method to blur the image: public static Bitmap blur(Context ctx, Bitmap image) { int width = Math.round(image.getWidth() * BITMAP_SCALE); int height = Math.round(image.getHeight() *

Renderscript broken with AndroidX?

跟風遠走 提交于 2019-12-14 03:45:12
问题 Since I've migrated to androidx I can't make Renderscript run. I'm getting following exception: 2018-10-12 16:27:58.328 27195-27195/pl.qus.xenoamp2 A/zygote64: java_vm_ext.cc:504] JNI DETECTED ERROR IN APPLICATION: JNI NewGlobalRef called with pending exception java.lang.ClassNotFoundException: Didn't find class "android.support.v8.renderscript.RenderScript" on path: DexPathList[[zip file "/data/app/pl.qus.xenoamp2-xHJAddeg9oM-uGSxlvMp7A==/base.apk"],nativeLibraryDirectories=[/data/app/pl.qus

Changes made to Renderscript File not reflecting in Emulator

喜夏-厌秋 提交于 2019-12-13 03:31:50
问题 Whenever I make changes to Renderscript and try running the emulator, the changes are not reflecting. I tried clean and build, invalidate the cache and restart but nothing helps. The changes reflect only when I delete the renderscript file and recreate the rs file with a different name, but this is cumbersome to do every time. Any fix for this? I'm using build tools version 25.0.3 and API 26 in Emulator. I understand the stack overflow community on renderscript is limited. So any help will be

RenderScript: not matching function rsGetElementAt_uchar4

梦想的初衷 提交于 2019-12-12 04:54:30
问题 I've write very short RS, but after gradle sync Android Studio gives me error Error:(8, 34) error: no matching function for call to 'rsGetElementAt_uchar4' Script: #pragma version(1) #pragma rs java_package_name(xx.xxx.xxxxxxx) uchar4 road = 0; const uchar4 nothing = 0; void init() { road.a = 0xff; } uchar4 __attribute__((kernel)) kernel(uchar4 original, uint32_t x, uint32_t y) { uchar4 masked = rsGetElementAt_uchar4(extra_alloc, x, y)); if (original.r != masked.r || original.g != masked.g ||

How do I select a region by color in a Bitmap?

五迷三道 提交于 2019-12-11 10:22:43
问题 Please suggest an efficient way to select a region by color in a bitmap. Then replace this selected region-color to your desired color. For example, If an image contains four colors say red, green, yellow, orange. Now suppose user clicked on yellow color, so select yellow colored region surrounding to the clicked position and now replace the yellow color to blue. Hope, I explained the question properly. Kindly comment if need any more clarification. As per my knowledge, bitmap is a memory

Android Studio 2.0 Preview 2 issue with Renderscript

夙愿已清 提交于 2019-12-06 18:52:41
问题 I updated Android Studio to 2.0 Preview 2, then I got an error Renderscript support mode is not currently supported with renderscript target 21+ I'm using renderscriptTargetApi 23 回答1: Renderscript isn't currently supported with Target 21+ so simply change the target to API 20 and that should solve the error. So the renderscript related options in your default config section of your gradle file should like : renderscriptTargetApi 20 renderscriptSupportModeEnabled true 回答2: The bug related to

Android Studio 2.0 Preview 2 issue with Renderscript

纵然是瞬间 提交于 2019-12-05 01:40:46
I updated Android Studio to 2.0 Preview 2, then I got an error Renderscript support mode is not currently supported with renderscript target 21+ I'm using renderscriptTargetApi 23 Renderscript isn't currently supported with Target 21+ so simply change the target to API 20 and that should solve the error. So the renderscript related options in your default config section of your gradle file should like : renderscriptTargetApi 20 renderscriptSupportModeEnabled true The bug related to renderscriptTargetApi has been fixed in gradle-plugin 2.1.0 and Build-Tools 23.0.3. Please try it out: