Flutter 在颤振中将图像由黑转白
我有一个黑白色的位图图像,我只需要反转图像并显示如何转换和显示图像。我在java中使用了反转位图图像,有谁能建议我如何在颤振中执行此操作Flutter 在颤振中将图像由黑转白,flutter,flutter-image,Flutter,Flutter Image,我有一个黑白色的位图图像,我只需要反转图像并显示如何转换和显示图像。我在java中使用了反转位图图像,有谁能建议我如何在颤振中执行此操作 private Bitmap createInvertedBitmap(Bitmap src) { ColorMatrix colorMatrix_Inverted = new ColorMatrix(new float[] { -1, 0, 0, 0
private Bitmap createInvertedBitmap(Bitmap src) {
ColorMatrix colorMatrix_Inverted =
new ColorMatrix(new float[] {
-1, 0, 0, 0, 255,
0, -1, 0, 0, 255,
0, 0, -1, 0, 255,
0, 0, 0, 1, 0});
ColorFilter ColorFilter_Sepia = new ColorMatrixColorFilter(
colorMatrix_Inverted);
Bitmap bitmap = Bitmap.createBitmap(src.getWidth(), src.getHeight(),
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
paint.setColorFilter(ColorFilter_Sepia);
canvas.drawBitmap(src, 0, 0, paint);
return bitmap;
}
现在可以通过以下方式更改/反转颜色: 有关更多详细信息,请参阅本博客: 另一个解决方案 您可以尝试使用,并尝试将其传递到相应的
着色器
,例如InvertColorShader
。目前,没有着色器可以执行此操作
同时也检查一下,以达到你想要的结果