OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 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 // The png package implements a PNG image decoder and encoder. | 5 // The png package implements a PNG image decoder and encoder. |
6 // | 6 // |
7 // The PNG specification is at http://www.libpng.org/pub/png/spec/1.2/PNG-Conten
ts.html | 7 // The PNG specification is at http://www.libpng.org/pub/png/spec/1.2/PNG-Conten
ts.html |
8 package png | 8 package png |
9 | 9 |
10 import ( | 10 import ( |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 pc := abs(p - int(c)) | 199 pc := abs(p - int(c)) |
200 if pa <= pb && pa <= pc { | 200 if pa <= pb && pa <= pc { |
201 return a | 201 return a |
202 } else if pb <= pc { | 202 } else if pb <= pc { |
203 return b | 203 return b |
204 } | 204 } |
205 return c | 205 return c |
206 } | 206 } |
207 | 207 |
208 func (d *decoder) idatReader(idat io.Reader) os.Error { | 208 func (d *decoder) idatReader(idat io.Reader) os.Error { |
209 » r, err := zlib.NewInflater(idat) | 209 » r, err := zlib.NewReader(idat) |
210 if err != nil { | 210 if err != nil { |
211 return err | 211 return err |
212 } | 212 } |
213 defer r.Close() | 213 defer r.Close() |
214 bpp := 0 // Bytes per pixel. | 214 bpp := 0 // Bytes per pixel. |
215 maxPalette := uint8(0) | 215 maxPalette := uint8(0) |
216 var ( | 216 var ( |
217 rgba *image.RGBA | 217 rgba *image.RGBA |
218 nrgba *image.NRGBA | 218 nrgba *image.NRGBA |
219 paletted *image.Paletted | 219 paletted *image.Paletted |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 err1 := <-d.idatDone | 457 err1 := <-d.idatDone |
458 if err == nil { | 458 if err == nil { |
459 err = err1 | 459 err = err1 |
460 } | 460 } |
461 } | 461 } |
462 if err != nil { | 462 if err != nil { |
463 return nil, err | 463 return nil, err |
464 } | 464 } |
465 return d.image, nil | 465 return d.image, nil |
466 } | 466 } |
OLD | NEW |