0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[Flutter] DecorationImageのColorFilterで画像加工する

Posted at

Flutterのアプリ開発で実装したことを記事にしました。
ColorFilterは、DecorationImageの画像の色味を変化させたいときに使います。

具体的には、下の画像の様にすることができます。

スクリーンショット.jpg

DecorationImageの画像にColorFilterを追加する

Container(
            decoration: BoxDecoration(
              image: DecorationImage(
                image: AssetImage('assets/images/test_image.jpg'),
                fit: BoxFit.cover,
                colorFilter: ColorFilter.mode(
                  Colors.white.withOpacity(0.2),
                  BlendMode.srcATop,
                ), // colorFilterを追加
              ),
            ),
          ),

ColorFilter.mode( Color color, BlendMode blendMode )

を変更すれば、画像に様々なフィルターをかけることをできますが、

BlendModeはバリエーションが多く、全ては理解できませんでした。

画像に指定した色を重ねるなら、BlendMode.srcATopがわかりやすと思います。

白黒写真の様にするには、

ColorFilter.mode(Colors.grey, BlendMode.saturation)

が使えます。

スクリーンショット 2022-01-29 14.44.50.jpg

参考にしたサイト

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?