File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,9 @@ func (dc *Context) Contrast(per int) {
5252 }
5353 case 100 < per && per <= 200 : // 增益
5454 gain := 200 - per
55+ if gain == 0 {
56+ gain = 1
57+ }
5558 for i , v := range dc .im .Pix {
5659 if i % 4 == 3 { // alpha
5760 continue
Original file line number Diff line number Diff line change @@ -13,10 +13,15 @@ func TestBrightness(t *testing.T) {
1313 }
1414 dc := NewContextForImage (im )
1515 dc .Brightness (- 50 )
16- if err := saveImage (dc , "TestBrightness" ); err != nil {
16+ if err := saveImage (dc , "TestBrightness-50 " ); err != nil {
1717 t .Fatal (err )
1818 }
1919 checkHash (t , dc , "<gg.Context 30e0b039be47de836a9fb4c8b9825ce8>" )
20+ dc .Brightness (70 ) // 70-50=20
21+ if err := saveImage (dc , "TestBrightness+20" ); err != nil {
22+ t .Fatal (err )
23+ }
24+ checkHash (t , dc , "<gg.Context d8aaf7a3d0aeb11dce3adc72ae9fb464>" )
2025}
2126
2227func TestContrast (t * testing.T ) {
@@ -26,8 +31,13 @@ func TestContrast(t *testing.T) {
2631 }
2732 dc := NewContextForImage (im )
2833 dc .Contrast (- 50 )
29- if err := saveImage (dc , "TestContrast" ); err != nil {
34+ if err := saveImage (dc , "TestContrast-50 " ); err != nil {
3035 t .Fatal (err )
3136 }
3237 checkHash (t , dc , "<gg.Context e6f161e094f0d95603aad891c51c0b6b>" )
38+ dc .Contrast (100 )
39+ if err := saveImage (dc , "TestContrast+100" ); err != nil {
40+ t .Fatal (err )
41+ }
42+ checkHash (t , dc , "<gg.Context e1608d9268930ac4f80bd5cb82af927a>" )
3343}
You can’t perform that action at this time.
0 commit comments