code: func Resample(m image.Image, r image.Rectangle, w, h int) image.Image {
  	if w < 0 || h < 0 {
  		return nil
  	}
  	if w == 0 || h == 0 || r.Dx() <= 0 || r.Dy() <= 0 {
  		return image.NewRGBA64(image.Rect(0, 0, w, h))
  	}
  	img := image.NewRGBA(image.Rect(0, 0, w, h))
  	xStep := float64(r.Dx()) / float64(w)
  	yStep := float64(r.Dy()) / float64(h)
  	for y := 0; y < h; y++ {
  		for x := 0; x < w; x++ {
  			xSrc := int(float64(r.Min.X) + float64(x)*xStep)
  			ySrc := int(float64(r.Min.Y) + float64(y)*yStep)
  			r, g, b, a := m.At(xSrc, ySrc).RGBA()
  			img.SetRGBA(x, y, color.RGBA{
  				R: uint8(r >> 8),
  				G: uint8(g >> 8),
  				B: uint8(b >> 8),
  				A: uint8(a >> 8),
  			})
  		}
  	}
  	return img
  }
docs: // Resample returns a resampled copy of the image slice r of m.
  // The returned image has width w and height h.