diff options
Diffstat (limited to 'libgo/go/image/png/writer.go')
-rw-r--r-- | libgo/go/image/png/writer.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libgo/go/image/png/writer.go b/libgo/go/image/png/writer.go index 2bd4fde..53adc16 100644 --- a/libgo/go/image/png/writer.go +++ b/libgo/go/image/png/writer.go @@ -426,10 +426,11 @@ func (e *encoder) writeImage(w io.Writer, m image.Image, cb int, level int) erro var a uint8 var c int + pixelsPerByte := 8 / bitsPerPixel for x := b.Min.X; x < b.Max.X; x++ { a = a<<uint(bitsPerPixel) | pi.ColorIndexAt(x, y) c++ - if c == 8/bitsPerPixel { + if c == pixelsPerByte { cr[0][i] = a i += 1 a = 0 @@ -437,7 +438,7 @@ func (e *encoder) writeImage(w io.Writer, m image.Image, cb int, level int) erro } } if c != 0 { - for c != 8/bitsPerPixel { + for c != pixelsPerByte { a = a << uint(bitsPerPixel) c++ } |