【问题标题】:Samsung S9+ and RenderScript Intrinsics三星 S9+ 和 RenderScript Intrinsics
【发布时间】:2020-03-02 08:46:55
【问题描述】:

我使用此脚本将 YUV_420_888 图像转换为位图。在我的三星 S8 上一切正常。我在我的 S9+ 上尝试了 RenderScript,结果是一个黑色位图。没有错误,没有警告只是一个黑色的位图。我将 S9+ 更新为 Android Pie,但一切仍然是黑色的。我真的无法解释 S9+ 设备出了什么问题...

        int W = mImage.getWidth();
        int H = mImage.getHeight();

        Image.Plane Y = mImage.getPlanes()[0];
        Image.Plane U = mImage.getPlanes()[1];
        Image.Plane V = mImage.getPlanes()[2];

        int Yb = Y.getBuffer().remaining();
        int Ub = U.getBuffer().remaining();
        int Vb = V.getBuffer().remaining();

        byte[] data = new byte[Yb + Ub + Vb];

        Y.getBuffer().get(data, 0, Yb);
        V.getBuffer().get(data, Yb, Vb);
        U.getBuffer().get(data, Yb + Vb, Ub);

        RenderScript rs = RenderScript.create(Main2Activity.this);
        ScriptIntrinsicYuvToRGB yuvToRgbIntrinsic = ScriptIntrinsicYuvToRGB.create(rs, Element.U8_4(rs));

        Type.Builder yuvType = new Type.Builder(rs, Element.U8(rs)).setX(data.length);
        Allocation in = Allocation.createTyped(rs, yuvType.create(), Allocation.USAGE_SCRIPT);

        Type.Builder rgbaType = new Type.Builder(rs, Element.RGBA_8888(rs)).setX(W).setY(H);
        Allocation out = Allocation.createTyped(rs, rgbaType.create(), Allocation.USAGE_SCRIPT);

        final Bitmap bmpout = Bitmap.createBitmap(W, H, Bitmap.Config.ARGB_8888);

        in.copyFromUnchecked(data);

        yuvToRgbIntrinsic.setInput(in);
        yuvToRgbIntrinsic.forEach(out);
        out.copyTo(bmpout);

**编辑:**我将 mImage 的分辨率更改为 2.960 x 1.440 像素并收到一些崩溃。当应用程序崩溃时,我再次安装了应用程序,当应用程序崩溃时显示位图。我认为问题不在于代码。我认为 S9+ 无法正常运行渲染脚本。

【问题讨论】:

    标签: java android c++ image-processing android-renderscript


    【解决方案1】:

    似乎 S9+ 在我放置在 ImagView 上的 TextureView 存在问题。删除 TextureView 后,应用程序工作得很好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-06
      • 1970-01-01
      相关资源
      最近更新 更多