Reputation: 53
I get the following error message:
01-19 23:31:16.436: E/RenderScript(30603): Unable to open shared library (/data/data/com.example.android.rs.hellocompute//lib/librs.mono.so): Cannot load library: reloc_library[1313]: 1222 cannot locate '_Z9rsForEach9rs_script13rs_allocationS0_'...
01-19 23:31:16.436: E/RenderScript(30603): Unable to open system shared library (/system/lib/librs.mono.so): (null)
01-19 23:31:16.444: D/AndroidRuntime(30603): Shutting down VM
01-19 23:31:16.444: W/dalvikvm(30603): threadid=1: thread exiting with uncaught exception (group=0x40018560)
01-19 23:31:16.585: E/AndroidRuntime(30603): FATAL EXCEPTION: main
01-19 23:31:16.585: E/AndroidRuntime(30603): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.rs.hellocompute/com.example.android.rs.hellocompute.HelloCompute}: android.support.v8.renderscript.RSRuntimeException: Loading of ScriptC script failed.
01-19 23:31:16.585: E/AndroidRuntime(30603): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1696)
01-19 23:31:16.585: E/AndroidRuntime(30603): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1716)
01-19 23:31:16.585: E/AndroidRuntime(30603): at android.app.ActivityThread.access$1500(ActivityThread.java:124)
01-19 23:31:16.585: E/AndroidRuntime(30603): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:968)
01-19 23:31:16.585: E/AndroidRuntime(30603): at android.os.Handler.dispatchMessage(Handler.java:99)
01-19 23:31:16.585: E/AndroidRuntime(30603): at android.os.Looper.loop(Looper.java:130)
01-19 23:31:16.585: E/AndroidRuntime(30603): at android.app.ActivityThread.main(ActivityThread.java:3806)
01-19 23:31:16.585: E/AndroidRuntime(30603): at java.lang.reflect.Method.invokeNative(Native Method)
01-19 23:31:16.585: E/AndroidRuntime(30603): at java.lang.reflect.Method.invoke(Method.java:507)
01-19 23:31:16.585: E/AndroidRuntime(30603): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-19 23:31:16.585: E/AndroidRuntime(30603): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-19 23:31:16.585: E/AndroidRuntime(30603): at dalvik.system.NativeStart.main(Native Method)
01-19 23:31:16.585: E/AndroidRuntime(30603): Caused by: android.support.v8.renderscript.RSRuntimeException: Loading of ScriptC script failed.
01-19 23:31:16.585: E/AndroidRuntime(30603): at android.support.v8.renderscript.ScriptC.(ScriptC.java:69)
01-19 23:31:16.585: E/AndroidRuntime(30603): at com.example.android.rs.hellocompute.ScriptC_mono.(ScriptC_mono.java:41)
01-19 23:31:16.585: E/AndroidRuntime(30603): at com.example.android.rs.hellocompute.HelloCompute.createScript(HelloCompute.java:64)
01-19 23:31:16.585: E/AndroidRuntime(30603): at com.example.android.rs.hellocompute.HelloCompute.onCreate(HelloCompute.java:49)
01-19 23:31:16.585: E/AndroidRuntime(30603): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-19 23:31:16.585: E/AndroidRuntime(30603): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1660)
01-19 23:31:16.585: E/AndroidRuntime(30603): ... 11 more
I guess that this message is created by int id
being 0 in ScriptC_mono.java although it should be R.raw.mono
, but I cannot find out why. Here are my *.rs and MainActivity.java files:
MainActivity:
import android.app.Activity;
import android.os.Bundle;
import android.graphics.BitmapFactory;
import android.graphics.Bitmap;
import android.support.v8.renderscript.*;
import android.widget.ImageView;
public class HelloCompute extends Activity {
private Bitmap mBitmapIn;
private Bitmap mBitmapOut;
private RenderScript mRS;
private Allocation mInAllocation;
private Allocation mOutAllocation;
private ScriptC_mono mScript;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mBitmapIn = loadBitmap(R.drawable.data);
mBitmapOut = Bitmap.createBitmap(mBitmapIn.getWidth(), mBitmapIn.getHeight(),
mBitmapIn.getConfig());
ImageView in = (ImageView) findViewById(R.id.displayin);
in.setImageBitmap(mBitmapIn);
ImageView out = (ImageView) findViewById(R.id.displayout);
createScript();
out.setImageBitmap(mBitmapOut);
}
private void createScript() {
mRS = RenderScript.create(this);
mInAllocation = Allocation.createFromBitmap(mRS, mBitmapIn,
Allocation.MipmapControl.MIPMAP_NONE,
Allocation.USAGE_SCRIPT);
mOutAllocation = Allocation.createFromBitmap(mRS, mBitmapOut,
Allocation.MipmapControl.MIPMAP_NONE,
Allocation.USAGE_SCRIPT);
mScript = new ScriptC_mono(mRS, getResources(), R.raw.mono);
mScript.forEach_root(mInAllocation, mOutAllocation);
mOutAllocation.copyTo(mBitmapOut);
mScript.destroy();
}
private Bitmap loadBitmap(int resource) {
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
return BitmapFactory.decodeResource(getResources(), resource, options);
}}
Mono.rs:
#pragma version(1)
#pragma rs java_package_name(com.android.example.hellocompute)
rs_allocation gIn;
rs_allocation gOut;
rs_script gScript;
const static float3 gMonoMult = {0.299f, 0.587f, 0.114f};
void root(const uchar4 *v_in, uchar4 *v_out, const void *usrData, uint32_t x, uint32_t y) {
float4 f4 = rsUnpackColor8888(*v_in);
float3 mono = dot(f4.rgb, gMonoMult);
*v_out = rsPackColorTo8888(mono);
}
void filter() {
rsForEach(gScript, gIn, gOut, 0);
}
Upvotes: 2
Views: 2376
Reputation: 53
I finally found a solution:
I simply used ScriptIntrinsic and modified a matrix with the specific red components using the method setColorMatrix(3fMatrix m) in ScriptIntrinsicColorMatrix.
Thanks for all of your ideas, this works for me!
Upvotes: 0
Reputation: 2622
This is the same problem that will be fixed in the next SDK release (many others have hit it due to missing rsForEach() and other functions).
Upvotes: 1