Commit 5c2f01f3 authored by Dustin Long's avatar Dustin Long Committed by David Symonds

image/png: interlacing support for png.

Fixes #6293.

Image "testdata/benchRGB-interlace.png" was generated by opening "testdata/benchRGB.png" in the editor Gimp and saving it with interlacing enabled.

Benchmark:
BenchmarkDecodeRGB        	     500	   7014194 ns/op	  37.37 MB/s
ok  	pkg/image/png	4.657s

BenchmarkDecodeInterlacing	     100	  10623241 ns/op	  24.68 MB/s
ok  	pkg/image/png	1.339s

LGTM=nigeltao
R=nigeltao, andybons, matrixik
CC=golang-codereviews
https://golang.org/cl/102130044
parent 0e694298
This diff is collapsed.
......@@ -30,6 +30,7 @@ var filenames = []string{
"basn3p01",
"basn3p02",
"basn3p04",
"basn3p04-31i",
"basn3p08",
"basn3p08-trns",
"basn4a08",
......@@ -186,6 +187,13 @@ func sng(w io.WriteCloser, filename string, png image.Image) {
c = 0
}
}
if c != 0 {
for c != 8/bitdepth {
b = b << uint(bitdepth)
c++
}
fmt.Fprintf(w, "%02x", b)
}
}
io.WriteString(w, "\n")
}
......@@ -348,3 +356,7 @@ func BenchmarkDecodePaletted(b *testing.B) {
func BenchmarkDecodeRGB(b *testing.B) {
benchmarkDecode(b, "testdata/benchRGB.png", 4)
}
func BenchmarkDecodeInterlacing(b *testing.B) {
benchmarkDecode(b, "testdata/benchRGB-interlace.png", 4)
}
#SNG: from basn3p04-31i.png
IHDR {
width: 31; height: 31; bitdepth: 4;
using color palette;
}
gAMA {1.0000}
PLTE {
( 34, 0,255) # rgb = (0x22,0x00,0xff)
( 0,255,255) # rgb = (0x00,0xff,0xff)
(136, 0,255) # rgb = (0x88,0x00,0xff)
( 34,255, 0) # rgb = (0x22,0xff,0x00)
( 0,153,255) # rgb = (0x00,0x99,0xff)
(255,102, 0) # rgb = (0xff,0x66,0x00)
(221, 0,255) # rgb = (0xdd,0x00,0xff)
(119,255, 0) # rgb = (0x77,0xff,0x00)
(255, 0, 0) # rgb = (0xff,0x00,0x00)
( 0,255,153) # rgb = (0x00,0xff,0x99)
(221,255, 0) # rgb = (0xdd,0xff,0x00)
(255, 0,187) # rgb = (0xff,0x00,0xbb)
(255,187, 0) # rgb = (0xff,0xbb,0x00)
( 0, 68,255) # rgb = (0x00,0x44,0xff)
( 0,255, 68) # rgb = (0x00,0xff,0x44)
}
IMAGE {
pixels hex
88885555ccccaaaa77773333eeee9990
88885555ccccaaaa77773333eeee9990
88885555ccccaaaa77773333eeee9990
88885555ccccaaaa77773333eeee9990
5555ccccaaaa77773333eeee99991110
5555ccccaaaa77773333eeee99991110
5555ccccaaaa77773333eeee99991110
5555ccccaaaa77773333eeee99991110
ccccaaaa77773333eeee999911114440
ccccaaaa77773333eeee999911114440
ccccaaaa77773333eeee999911114440
ccccaaaa77773333eeee999911114440
aaaa77773333eeee999911114444ddd0
aaaa77773333eeee999911114444ddd0
aaaa77773333eeee999911114444ddd0
aaaa77773333eeee999911114444ddd0
77773333eeee999911114444dddd0000
77773333eeee999911114444dddd0000
77773333eeee999911114444dddd0000
77773333eeee999911114444dddd0000
3333eeee999911114444dddd00002220
3333eeee999911114444dddd00002220
3333eeee999911114444dddd00002220
3333eeee999911114444dddd00002220
eeee999911114444dddd000022226660
eeee999911114444dddd000022226660
eeee999911114444dddd000022226660
eeee999911114444dddd000022226660
999911114444dddd000022226666bbb0
999911114444dddd000022226666bbb0
999911114444dddd000022226666bbb0
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment