]> Cypherpunks repositories - gostls13.git/commitdiff
image/png: use image-specific methods for checking opacity.
authorNigel Tao <nigeltao@golang.org>
Sun, 1 Aug 2010 23:52:15 +0000 (09:52 +1000)
committerNigel Tao <nigeltao@golang.org>
Sun, 1 Aug 2010 23:52:15 +0000 (09:52 +1000)
R=rsc
CC=golang-dev, mpl
https://golang.org/cl/1894047

src/pkg/image/png/writer.go

index e186ca819b9aaff6e0c64e9ca77d497dd5d65c53..323e66f1143ce9851ded4ae902104057d07160cb 100644 (file)
@@ -32,8 +32,15 @@ func writeUint32(b []uint8, u uint32) {
        b[3] = uint8(u >> 0)
 }
 
+type opaquer interface {
+       Opaque() bool
+}
+
 // Returns whether or not the image is fully opaque.
 func opaque(m image.Image) bool {
+       if o, ok := m.(opaquer); ok {
+               return o.Opaque()
+       }
        for y := 0; y < m.Height(); y++ {
                for x := 0; x < m.Width(); x++ {
                        _, _, _, a := m.At(x, y).RGBA()