func (d *decoder) Read(p []byte) (int, error) {
	if len(p) == 0 {
		return 0, nil
	}
	for d.idatLength == 0 {
		// We have exhausted an IDAT chunk. Verify the checksum of that chunk.
		if err := d.verifyChecksum(); err != nil {
			return 0, err
		}
		// Read the length and chunk type of the next chunk, and check that
		// it is an IDAT chunk.
		if _, err := io.ReadFull(d.r, d.tmp[:8]); err != nil {
			return 0, err
		}
		d.idatLength = binary.BigEndian.Uint32(d.tmp[:4])
		if string(d.tmp[4:8]) != "IDAT" {
			return 0, FormatError("not enough pixel data")
		}
		d.crc.Reset()
		d.crc.Write(d.tmp[4:8])
	}
	if int(d.idatLength) < 0 {
		return 0, UnsupportedError("IDAT chunk length overflow")
	}
	n, err := d.r.Read(p[:min(len(p), int(d.idatLength))])
	d.crc.Write(p[:n])
	d.idatLength -= uint32(n)
	return n, err
}
func (d *decoder) Read(p []byte) (int, error) {
	if len(p) == 0 {
		return 0, nil
	}
	for d.idatLength == 0 {
		
		if err := d.verifyChecksum(); err != nil {
			return 0, err
		}
		
		
		if _, err := io.ReadFull(d.r, d.tmp[:8]); err != nil {
			return 0, err
		}
		d.idatLength = binary.BigEndian.Uint32(d.tmp[:4])
		if string(d.tmp[4:8]) != "IDAT" {
			return 0, FormatError("not enough pixel data")
		}
		d.crc.Reset()
		d.crc.Write(d.tmp[4:8])
	}
	if int(d.idatLength) < 0 {
		return 0, UnsupportedError("IDAT chunk length overflow")
	}
	n, err := d.r.Read(p[:min(len(p), int(d.idatLength))])
	d.crc.Write(p[:n])
	d.idatLength -= uint32(n)
	return n, err
}
func ( d * decoder ) Read ( p [ ] byte ) ( int , error ) { if len ( p ) == 0 { return 0 , nil } for d . idatLength == 0 { // We have exhausted an IDAT chunk. Verify the checksum of that chunk. if err := d . verifyChecksum ( ) ; err != nil { return 0 , err } // Read the length and chunk type of the next chunk, and check that // it is an IDAT chunk. if _ , err := io . ReadFull ( d . r , d . tmp [ : 8 ] ) ; err != nil { return 0 , err } d . idatLength = binary . BigEndian . Uint32 ( d . tmp [ : 4 ] ) if string ( d . tmp [ 4 : 8 ] ) != " " { return 0 , FormatError ( " " ) } d . crc . Reset ( ) d . crc . Write ( d . tmp [ 4 : 8 ] ) } if int ( d . idatLength ) < 0 { return 0 , UnsupportedError ( " " ) } n , err := d . r . Read ( p [ : min ( len ( p ) , int ( d . idatLength ) ) ] ) d . crc . Write ( p [ : n ] ) d . idatLength -= uint32 ( n ) return n , err }
// Read presents one or more IDAT chunks as one continuous stream (minus the
// intermediate chunk headers and footers). If the PNG data looked like:
//   ... len0 IDAT xxx crc0 len1 IDAT yy crc1 len2 IEND crc2
// then this reader presents xxxyy. For well-formed PNG data, the decoder state
// immediately before the first Read call is that d.r is positioned between the
// first IDAT and xxx, and the decoder state immediately after the last Read
// call is that d.r is positioned between yy and crc1.
Read presents one or more IDAT chunks as one continuous stream ( minus the intermediate chunk headers and footers ) . If the PNG data looked like : ... len0 IDAT xxx crc0 len1 IDAT yy crc1 len2 IEND crc2 then this reader presents xxxyy . For well - formed PNG data the decoder state immediately before the first Read call is that d . r is positioned between the first IDAT and xxx and the decoder state immediately after the last Read call is that d . r is positioned between yy and crc1 .