0

你能回复Android中jhlabs图像库的Crystalize或Pointilize过滤器的例子吗?我确实按照自己的风格编写代码,但它没有用。:P

以下代码是我写的。它不起作用。我不知道为什么代码不起作用。

你能告诉我原因吗?

    PointillizeFilter filter = new PointillizeFilter();
    filter.setEdgeColor(Color.BLACK);
    filter.setScale(10f);
    filter.setRandomness(0.1f);
    filter.setAmount(0.1f);
    filter.setFuzziness(0.1f);
    filter.setTurbulence(10f);
    filter.setGridType(PointillizeFilter.SQUARE);
    int[] src = AndroidUtils.bitmapToIntArray(artWork);
    filter.filter(src, width, height);
    Bitmap destImage = Bitmap.createBitmap(src, width, height, Config.ARGB_8888);
4

2 回答 2

2

当您调用方法filter(src,width,height)将其分配给src然后代码将起作用。因为此方法返回IntArrayJHLabs 库中的。因此,代码将是:

PointillizeFilter filter = new PointillizeFilter();
filter.setEdgeColor(Color.BLACK);
filter.setScale(10f);
filter.setRandomness(0.1f);
filter.setAmount(0.1f);
filter.setFuzziness(0.1f);
filter.setTurbulence(10f);
filter.setGridType(PointillizeFilter.SQUARE);
int[] src = AndroidUtils.bitmapToIntArray(artWork);
src=filter.filter(src, width, height);
Bitmap destImage = Bitmap.createBitmap(src, width, height, Config.ARGB_8888);
于 2013-03-05T19:26:48.477 回答
0

这行得通。

PointillizeFilter pointillizeFilter = new PointillizeFilter();
pointillizeFilter.setEdgeThickness(0.45f);
pointillizeFilter.setFadeEdges(false);
pointillizeFilter.setEdgeColor(Color.GRAY);
pointillizeFilter.setFuzziness(1.0f);
int[] src47 = AndroidUtils.bitmapToIntArray(inter);
int width47 = inter.getWidth();
int height47 = inter.getHeight();
int[] dest47 = pointillizeFilter.filter(src47, width47, height47);
Bitmap destBitmap47 = Bitmap.createBitmap(dest47, width47, height47, Bitmap.Config.ARGB_8888);
于 2017-01-22T07:15:11.783 回答