code: func Resample(m image.Image, r image.Rectangle, w, h int) *image.RGBA {
  	if w < 0 || h < 0 {
  		return nil
  	}
  	if w == 0 || h == 0 || r.Dx() <= 0 || r.Dy() <= 0 {
  		return image.NewRGBA(image.Rect(0, 0, w, h))
  	}
  	curw, curh := r.Dx(), r.Dy()
  	img := image.NewRGBA(image.Rect(0, 0, w, h))
  	for y := 0; y < h; y++ {
  		for x := 0; x < w; x++ {
  			// Get a source pixel.
  			subx := x * curw / w
  			suby := y * curh / h
  			r32, g32, b32, a32 := m.At(subx, suby).RGBA()
  			r := uint8(r32 >> 8)
  			g := uint8(g32 >> 8)
  			b := uint8(b32 >> 8)
  			a := uint8(a32 >> 8)
  			img.SetRGBA(x, y, color.RGBA{r, g, b, a})
  		}
  	}
  	return img
  }
docs: // Resample returns a resampled copy of the image slice r of m.
  // The returned image has width w and height h.