位图无法正常显示android?

时间:2015-01-15 23:07:04

标签: android matrix bitmap convolution renderscript

我试图显示通过ScriptIntrinsicConvolve3x3边缘检测矩阵处理过的位图。但是,不是你想象的卷积的暗图像,它显示非常光。

继承人截图: http://tinypic.com/r/x4etl1/8

与我想要的相比: http://chiuki.github.io/android-shaders-filters/#/46

这是我处理图片的代码:

private void renderImage(){
    renderScript = RenderScript.create(this);
    renderedImage = Bitmap.createBitmap(originalImage.getWidth(), originalImage.getHeight(), Bitmap.Config.ARGB_8888);
    tempIn = Allocation.createFromBitmap(renderScript, originalImage);
    tempOut = Allocation.createFromBitmap(renderScript, renderedImage);
    convolve = ScriptIntrinsicConvolve3x3.create(renderScript, Element.U8_4(renderScript));
    float[] coefficients = {-1f, -1f, -1f, -1f, 8f, -1f, -1f, -1f, -1f};
    convolve.setCoefficients(coefficients);
    convolve.setInput(tempIn);
    convolve.forEach(tempOut);
    tempOut.copyTo(renderedImage);

    renderScript.destroy();

}

private void setView(){
    ImageView imgView = new ImageView(this);

    imgView.setImageBitmap(renderedImage);


    setContentView(imgView);
}

有关为何发生这种情况的任何建议? 我尝试过拍摄像素样本,位图以0为主,但不应该是黑色吗?

0 个答案:

没有答案