繁体   English   中英

ScriptC脚本加载失败/无法加载库-Renderscript Android

[英]Loading of ScriptC script failed / cannot load library - Renderscript Android

我收到以下错误消息:

01-19 23:31:16.436:E / RenderScript(30603):无法打开共享库(/data/data/com.example.android.rs.hellocompute//lib/librs.mono.so):无法加载库:reloc_library [1313]:1222无法找到'_Z9rsForEach9rs_script13rs_allocationS0 _'...

01-19 23:31:16.436:E / RenderScript(30603):无法打开系统共享库(/system/lib/librs.mono.so):(空)

01-19 23:31:16.444:D / AndroidRuntime(30603):关闭VM

01-19 23:31:16.444:W / dalvikvm(30603):threadid = 1:线程以未捕获的异常退出(group = 0x40018560)

01-19 23:31:16.585:E / AndroidRuntime(30603):致命异常:主

01-19 23:31:16.585:E / AndroidRuntime(30603):java.lang.RuntimeException:无法启动活动ComponentInfo {com.example.android.rs.hellocompute / com.example.android.rs.hellocompute.HelloCompute} :android.support.v8.renderscript.RSRuntimeException:ScriptC脚本加载失败。

01-19 23:31:16.585:E / AndroidRuntime(30603):位于android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1696)

01-19 23:31:16.585:E / AndroidRuntime(30603):位于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):位于android.app.ActivityThread $ H.handleMessage(ActivityThread.java:968)

01-19 23:31:16.585:E / AndroidRuntime(30603):位于android.os.Handler.dispatchMessage(Handler.java:99)

01-19 23:31:16.585:E / AndroidRuntime(30603):位于android.os.Looper.loop(Looper.java:130)

01-19 23:31:16.585:E / AndroidRuntime(30603):位于android.app.ActivityThread.main(ActivityThread.java:3806)

01-19 23:31:16.585:E / AndroidRuntime(30603):at java.lang.reflect.Method.invokeNative(本机方法)

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):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)

01-19 23:31:16.585:E / AndroidRuntime(30603):在dalvik.system.NativeStart.main(本机方法)

01-19 23:31:16.585:E / AndroidRuntime(30603):原因:android.support.v8.renderscript.RSRuntimeException:ScriptC脚本加载失败。

01-19 23:31:16.585:E / AndroidRuntime(30603):位于android.support.v8.renderscript.ScriptC。(ScriptC.java:69)

01-19 23:31:16.585:E / AndroidRuntime(30603):在com.example.android.rs.hellocompute.ScriptC_mono。(ScriptC_mono.java:41)

01-19 23:31:16.585:E / AndroidRuntime(30603):位于com.example.android.rs.hellocompute.HelloCompute.createScript(HelloCompute.java:64)

01-19 23:31:16.585:E / AndroidRuntime(30603):在com.example.android.rs.hellocompute.HelloCompute.onCreate(HelloCompute.java:49)

01-19 23:31:16.585:E / AndroidRuntime(30603):位于android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)

01-19 23:31:16.585:E / AndroidRuntime(30603):位于android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1660)

01-19 23:31:16.585:E / AndroidRuntime(30603):...还有11个

我猜想这条消息是由ScriptC_mono.java中的int id为0创建的,尽管它应该是R.raw.mono ,但是我不知道为什么。 这是我的* .rs和MainActivity.java文件:

主要活动:

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);
}

这是在下一个SDK版本中将解决的相同问题(由于缺少rsForEach()和其他函数,许多其他问题已解决)。

我终于找到了解决方案:

我只是简单地使用ScriptIntrinsic,并使用ScriptIntrinsicColorMatrix中的setColorMatrix(3fMatrix m)方法使用特定的红色成分修改了矩阵。

感谢您的所有想法,这对我有用!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM