Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(68)

Side by Side Diff: src/image/gif/writer_test.go

Issue 147730043: code review 147730043: image/gif: fix GIF encoding of sub-images. (Closed)
Patch Set: diff -r a92a99ba40fb030955680fc19b1a489548049121 https://code.google.com/p/go/ Created 9 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/image/gif/writer.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Go Authors. All rights reserved. 1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package gif 5 package gif
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "image" 9 "image"
10 "image/color" 10 "image/color"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 95 }
96 // Compare the average delta to the tolerance level. 96 // Compare the average delta to the tolerance level.
97 avgDelta := averageDelta(m0, m1) 97 avgDelta := averageDelta(m0, m1)
98 if avgDelta > tc.tolerance { 98 if avgDelta > tc.tolerance {
99 t.Errorf("%s: average delta is too high. expected: %d, g ot %d", tc.filename, tc.tolerance, avgDelta) 99 t.Errorf("%s: average delta is too high. expected: %d, g ot %d", tc.filename, tc.tolerance, avgDelta)
100 continue 100 continue
101 } 101 }
102 } 102 }
103 } 103 }
104 104
105 func TestSubImage(t *testing.T) {
106 m0, err := readImg("../testdata/video-001.gif")
107 if err != nil {
108 t.Fatalf("readImg: %v", err)
109 }
110 m0 = m0.(*image.Paletted).SubImage(image.Rect(0, 0, 50, 30))
111 var buf bytes.Buffer
112 err = Encode(&buf, m0, nil)
113 if err != nil {
114 t.Fatalf("Encode: %v", err)
115 }
116 m1, err := Decode(&buf)
117 if err != nil {
118 t.Fatalf("Decode: %v", err)
119 }
120 if m0.Bounds() != m1.Bounds() {
121 t.Fatalf("bounds differ: %v and %v", m0.Bounds(), m1.Bounds())
122 }
123 if averageDelta(m0, m1) != 0 {
124 t.Fatalf("images differ")
125 }
126 }
127
105 var frames = []string{ 128 var frames = []string{
106 "../testdata/video-001.gif", 129 "../testdata/video-001.gif",
107 "../testdata/video-005.gray.gif", 130 "../testdata/video-005.gray.gif",
108 } 131 }
109 132
110 func TestEncodeAll(t *testing.T) { 133 func TestEncodeAll(t *testing.T) {
111 g0 := &GIF{ 134 g0 := &GIF{
112 Image: make([]*image.Paletted, len(frames)), 135 Image: make([]*image.Paletted, len(frames)),
113 Delay: make([]int, len(frames)), 136 Delay: make([]int, len(frames)),
114 LoopCount: 5, 137 LoopCount: 5,
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 255, 218 255,
196 }) 219 })
197 } 220 }
198 } 221 }
199 b.SetBytes(640 * 480 * 4) 222 b.SetBytes(640 * 480 * 4)
200 b.StartTimer() 223 b.StartTimer()
201 for i := 0; i < b.N; i++ { 224 for i := 0; i < b.N; i++ {
202 Encode(ioutil.Discard, img, nil) 225 Encode(ioutil.Discard, img, nil)
203 } 226 }
204 } 227 }
OLDNEW
« no previous file with comments | « src/image/gif/writer.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b