1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
16 func diff(m0, m1 image.Image) os.Error {
17 b0, b1 := m0.Bounds(), m1.Bounds()
19 return fmt.Errorf("dimensions differ: %v vs %v", b0, b1)
21 for y := b0.Min.Y; y < b0.Max.Y; y++ {
22 for x := b0.Min.X; x < b0.Max.X; x++ {
23 r0, g0, b0, a0 := m0.At(x, y).RGBA()
24 r1, g1, b1, a1 := m1.At(x, y).RGBA()
25 if r0 != r1 || g0 != g1 || b0 != b1 || a0 != a1 {
26 return fmt.Errorf("colors differ at (%d, %d): %v vs %v", x, y, m0.At(x, y), m1.At(x, y))
33 func TestWriter(t *testing.T) {
34 // The filenames variable is declared in reader_test.go.
35 for _, fn := range filenames {
36 qfn := "testdata/pngsuite/" + fn + ".png"
38 m0, err := readPng(qfn)
43 // Read the image again, and push it through a pipe that encodes at the write end, and decodes at the read end.
48 m1, err := readPng(qfn)
73 func BenchmarkEncodePaletted(b *testing.B) {
75 img := image.NewPaletted(640, 480,
77 image.RGBAColor{0, 0, 0, 255},
78 image.RGBAColor{255, 255, 255, 255},
81 buffer := new(bytes.Buffer)
82 for i := 0; i < b.N; i++ {