Reputation: 25
I need to display a CameraPreview widget and an image (separately) with the contrast adjusted on both. I've been looking into the ColorFiltered and ShaderMask widgets but I'm not sure what blend mode to use or if it will be helpful to change the blend mode. Does anyone have any examples of changing the contrast?
Upvotes: 1
Views: 1496
Reputation: 6135
I used Camera plugin and there was no inbuilt feature in package to set contrast/brightness so I have set it by ColorFiltered widget as:
ColorFiltered(
colorFilter: const ColorFilter.mode(
Colors.white,
BlendMode.softLight,
// BlendMode.overlay,
),
child: CameraPreview(camController),
)
It worked for me. I hope, this solution will also help you. Thanks a lot for asking this question.
Upvotes: 0
Reputation: 2187
Hey I would recommend you to use you a color matrix to achieve your desired contrast. You could use following Color matrix within an ColoFiltered widget:
class CustomSubFilters extends ColorFilter {
CustomSubFilters.matrix(List<double> matrix) : super.matrix(matrix);
factory CustomSubFilters.contrast(double c) {
num t = (1.0 - (1 + c)) / 2.0 * 255;
return CustomSubFilters.matrix(<double>[
1 + c,
0,
0,
0,
t,
0,
1 + c,
0,
0,
t,
0,
0,
1 + c,
0,
t,
0,
0,
0,
1,
0,
]);
}
}
Simply just wrap your widget within a ColorFiltered widget and use this colormatrix.
Upvotes: 4