1
0
mirror of https://github.com/golang/go synced 2024-11-22 00:14:42 -07:00

image/png: use image-specific methods for checking opacity.

R=rsc
CC=golang-dev, mpl
https://golang.org/cl/1894047
This commit is contained in:
Nigel Tao 2010-08-02 09:52:15 +10:00
parent 6d37724c15
commit 55badd474b

View 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()