summaryrefslogtreecommitdiff
path: root/src/pkg/image/png
diff options
context:
space:
mode:
authorNigel Tao <nigeltao@golang.org>2010-05-28 12:59:21 -0700
committerNigel Tao <nigeltao@golang.org>2010-05-28 12:59:21 -0700
commit93334922153a54990f7b6466cdc1ef827b375d81 (patch)
tree84974801e72a699e2ea3b952a7c1fcd763b18c37 /src/pkg/image/png
parent3197a347dbc083f0a83fb1fb058c750743979feb (diff)
downloadgolang-93334922153a54990f7b6466cdc1ef827b375d81.tar.gz
Make image.Color.RGBA return 16 bit color instead of 32 bit color.
R=rsc CC=golang-dev http://codereview.appspot.com/1388041
Diffstat (limited to 'src/pkg/image/png')
-rw-r--r--src/pkg/image/png/reader_test.go6
-rw-r--r--src/pkg/image/png/writer.go16
2 files changed, 11 insertions, 11 deletions
diff --git a/src/pkg/image/png/reader_test.go b/src/pkg/image/png/reader_test.go
index 68aab7832..1dc45992e 100644
--- a/src/pkg/image/png/reader_test.go
+++ b/src/pkg/image/png/reader_test.go
@@ -76,9 +76,9 @@ func sng(w io.WriteCloser, filename string, png image.Image) {
io.WriteString(w, "PLTE {\n")
for i := 0; i < len(cpm); i++ {
r, g, b, _ := cpm[i].RGBA()
- r >>= 24
- g >>= 24
- b >>= 24
+ r >>= 8
+ g >>= 8
+ b >>= 8
fmt.Fprintf(w, " (%3d,%3d,%3d) # rgb = (0x%02x,0x%02x,0x%02x)\n", r, g, b, r, g, b)
}
io.WriteString(w, "}\n")
diff --git a/src/pkg/image/png/writer.go b/src/pkg/image/png/writer.go
index 06b6dcdc3..e186ca819 100644
--- a/src/pkg/image/png/writer.go
+++ b/src/pkg/image/png/writer.go
@@ -37,7 +37,7 @@ func opaque(m image.Image) bool {
for y := 0; y < m.Height(); y++ {
for x := 0; x < m.Width(); x++ {
_, _, _, a := m.At(x, y).RGBA()
- if a != 0xffffffff {
+ if a != 0xffff {
return false
}
}
@@ -101,13 +101,13 @@ func (e *encoder) writePLTE(p image.PalettedColorModel) {
}
for i := 0; i < len(p); i++ {
r, g, b, a := p[i].RGBA()
- if a != 0xffffffff {
+ if a != 0xffff {
e.err = UnsupportedError("non-opaque palette color")
return
}
- e.tmp[3*i+0] = uint8(r >> 24)
- e.tmp[3*i+1] = uint8(g >> 24)
- e.tmp[3*i+2] = uint8(b >> 24)
+ e.tmp[3*i+0] = uint8(r >> 8)
+ e.tmp[3*i+1] = uint8(g >> 8)
+ e.tmp[3*i+2] = uint8(b >> 8)
}
e.writeChunk(e.tmp[0:3*len(p)], "PLTE")
}
@@ -261,9 +261,9 @@ func writeImage(w io.Writer, m image.Image, ct uint8) os.Error {
for x := 0; x < m.Width(); x++ {
// We have previously verified that the alpha value is fully opaque.
r, g, b, _ := m.At(x, y).RGBA()
- cr[0][3*x+1] = uint8(r >> 24)
- cr[0][3*x+2] = uint8(g >> 24)
- cr[0][3*x+3] = uint8(b >> 24)
+ cr[0][3*x+1] = uint8(r >> 8)
+ cr[0][3*x+2] = uint8(g >> 8)
+ cr[0][3*x+3] = uint8(b >> 8)
}
case ctPaletted:
for x := 0; x < m.Width(); x++ {