【发布时间】:2020-10-24 08:21:52
【问题描述】:
我想从图像中提取主色,以便我可以将其作为混合应用到其他图像中。我怎样才能做到这一点??
在我当前的代码中,我手动指定了颜色,但我希望它由应用程序生成。
class MyApp extends StatelessWidget {
Color face = new HexColor("a8a8a8");
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text("Image from assets"),
),
body: Column (
mainAxisAlignment: MainAxisAlignment.center,
children:<Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.start,
children:<Widget>[
new Image.asset('assets/images/6.jpg',
color: face, colorBlendMode:BlendMode.modulate ,
fit:BoxFit.cover,
height: 50,
width: 50,
),
new Image.asset('assets/images/1.jpg',
color: face, colorBlendMode: BlendMode.modulate,
fit:BoxFit.cover,
height: 200,
width: 200,
),
]),
])),
);
}
}
【问题讨论】:
标签: image flutter dart colors color-palette