我在应用多个过滤器时遇到 ScriptIntrinsicConvolve3x3 的小问题。当我应用过滤器 (B) 时,它会覆盖过滤器 (A)。我想知道是否可以使用 ScriptIntrinsicConvolve3x3 来实现?谢谢!
mRS = android.renderscript.RenderScript.create( app.android.context );
mInAllocation = android.renderscript.Allocation.createFromBitmap(mRS, bitmap, android.renderscript.Allocation.MipmapControl.MIPMAP_NONE, android.renderscript.Allocation.USAGE_SCRIPT);
mOutAllocation = android.renderscript.Allocation.createTyped(mRS, mInAllocation.getType());
//A - First Filter
let a = android.renderscript.ScriptIntrinsicConvolve3x3.create(mRS, android.renderscript.Element.U8_4(mRS));
a.setInput(mInAllocation);
a.setCoefficients(toFloatArray([-2, -1, -0, -1, 1, 1, 0, 1, 2]));
a.forEach(mOutAllocation);
mOutAllocation.copyTo(this.image.bitmap._nativeObject);
//B - Second Filter
let b = android.renderscript.ScriptIntrinsicConvolve3x3.create(mRS, android.renderscript.Element.U8_4(mRS));
b.setInput(mInAllocation);
b.setCoefficients(toFloatArray([-1, -1, -1, -1, 1, -1, -1, -1, -1]));
b.forEach(mOutAllocation);
mOutAllocation.copyTo(this.image.bitmap._nativeObject);
最佳答案
我认为你应该为 B 使用 A 的输出:
let a = android.renderscript.ScriptIntrinsicConvolve3x3.create(mRS, android.renderscript.Element.U8_4(mRS));
a.setInput(mOutAllocation); // fix here
关于android - 在同一位图上应用两个或多个 ScriptIntrinsicConvolve3x3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50745687/