Problem Description:
I write a simple demo using RenderScrip for image process. In my demo, when I use a one-kernal renderscript, it works fine. Yet when I use a script group to connect two rs-kernals for execution, I found the output bitmap with horizontal stripes. Especially when you chose a bitmap with small size.
The output bitmap when I use a one-kernal renderscript:
The output bitmap when I use a script group to connect two rs-kernals. Note these two rs-kernals are just the same as the one I use above:
Codes:
I believe my codes in rs-kernal are correct. Otherwise I can't can't the right output picture when using a single-kernal renderscript. The problem is about script group.
Here is some codes about how I connect the rs-kernals in script group:
Type.Builder tb = new Type.Builder(mRs, Element.RGBA_8888(mRs));
tb.setX(baseBitmapWidth);// the size of bitmap never changes during the whole process
tb.setY(baseBitmapHeight);
Type t = tb.create();
ScriptGroup.Builder b = new ScriptGroup.Builder(mRs);
int i = 0;
for (i = 0; i < mOps.size(); i++) {
RSOp op = mOps.get(i);
b.addKernel(op.rsGetKernalID());
}
for (i = 1; i < mOps.size(); i++) {
b.addConnection(t, mOps.get(i - 1).rsGetKernalID(), mOps.get(i)
.rsGetKernalID());
}
mScriptGroup = b.create();
Here is some codes about how the script group is executed:
Bitmap preparedBitmap = baseBitmap.copy(baseBitmap.getConfig(), true);
mInAllocation = Allocation.createFromBitmap(mRs, baseBitmap, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
mOutAllocation = Allocation.createTyped(mRs, mInAllocation.getType());
mScriptGroup.setInput(mOps.get(0).rsGetKernalID(), mInAllocation);
mScriptGroup.setOutput(mOps.get(mOps.size() - 1).rsGetKernalID(),
mOutAllocation);
mScriptGroup.execute();
mOutAllocation.copyTo(preparedBitmap);
Have found a solution: Just used many one-kernal renderscripts instead. Use the output bitmap of the previous script as the input of the later.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.