Skip to content

Commit 6fb24e2

Browse files
committed
Correct brightness and contrast matrices
1 parent befa74e commit 6fb24e2

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

ImageEditor/MainActivity.cs

+9-9
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,12 @@ void BrightnessChanged(object sender, SeekBar.ProgressChangedEventArgs e)
103103
return;
104104
}
105105

106-
var value = GetAdjustedValue(e);
107-
var brightness = value / (float)100;
108-
106+
var brightness = GetAdjustedValue(e);
107+
109108
_colorMatrix.Set(new float[] {
110-
1, 0, 0, brightness, 0,
111-
0, 1, 0, brightness, 0,
112-
0, 0, 1, brightness, 0,
109+
1, 0, 0, 0, brightness,
110+
0, 1, 0, 0, brightness,
111+
0, 0, 1, 0, brightness,
113112
0, 0, 0, 1, 0 });
114113

115114
UpdateImage();
@@ -128,11 +127,12 @@ void ContrastChanged(object sender, SeekBar.ProgressChangedEventArgs e)
128127
float scale = input + 1f;
129128
float contrast = (-0.5f * scale + 0.5f) * 255f;
130129
_colorMatrix.Set(new float[] {
131-
1, 0, 0, 0, contrast,
132-
0, 1, 0, 0, contrast,
133-
0, 0, 1, 0, contrast,
130+
scale, 0, 0, 0, contrast,
131+
0, scale, 0, 0, contrast,
132+
0, 0, scale, 0, contrast,
134133
0, 0, 0, 1, 0 });
135134

135+
136136
UpdateImage();
137137
}
138138

0 commit comments

Comments
 (0)