【发布时间】:2014-07-19 17:34:27
【问题描述】:
我正在尝试使用 RenderScript 类对图像应用模糊。这是我使用的代码(this.image 是原始位图)
Bitmap inputImage = this.image;
int height = inputImage.getHeight();
int width = inputImage.getWidth();
Bitmap blurredImage = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
RenderScript rs = RenderScript.create(context);
ScriptIntrinsicBlur theIntrinsic = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
Allocation tmpIn = Allocation.createFromBitmap(rs, inputImage);
Allocation tmpOut = Allocation.createFromBitmap(rs, blurredImage);
theIntrinsic.setRadius(25.f);
theIntrinsic.setInput(tmpIn);
theIntrinsic.forEach(tmpOut);
tmpOut.copyTo(blurredImage);
this.image = blurredImage;
return true;
这是函数的输入和输出 http://imgur.com/a/EWJv6
由于某种原因,它似乎将图像加倍,然后只保留绿色通道或其他东西。摆弄模糊半径不起作用,我找不到我的代码有什么问题(从一个工作示例复制而来)
【问题讨论】:
-
输入位图是什么格式?这几乎看起来好像输入是 16 位的。 RS 模糊仅支持每通道 8 位位图。
-
有没有发现哪里出了问题? @deepCover
标签: java android renderscript