code: func (d *decoder) decode() (image.Image, error) {
  	r, err := zlib.NewReader(d)
  	if err != nil {
  		return nil, err
  	}
  	defer r.Close()
  	var img image.Image
  	if d.interlace == itNone {
  		img, err = d.readImagePass(r, 0, false)
  		if err != nil {
  			return nil, err
  		}
  	} else if d.interlace == itAdam7 {
  		// Allocate a blank image of the full size.
  		img, err = d.readImagePass(nil, 0, true)
  		if err != nil {
  			return nil, err
  		}
  		for pass := 0; pass < 7; pass++ {
  			imagePass, err := d.readImagePass(r, pass, false)
  			if err != nil {
  				return nil, err
  			}
  			if imagePass != nil {
  				d.mergePassInto(img, imagePass, pass)
  			}
  		}
  	}
  
  	// Check for EOF, to verify the zlib checksum.
  	n := 0
  	for i := 0; n == 0 && err == nil; i++ {
  		if i == 100 {
  			return nil, io.ErrNoProgress
  		}
  		n, err = r.Read(d.tmp[:1])
  	}
  	if err != nil && err != io.EOF {
  		return nil, FormatError(err.Error())
  	}
  	if n != 0 || d.idatLength != 0 {
  		return nil, FormatError("too much pixel data")
  	}
  
  	return img, nil
  }
docs: // decode decodes the IDAT data into an image.