package image

import (
	"image"

	"golang.org/x/image/draw"
)

const (
	ScaleNot              = iota // skips image interpolation
	ScaleNearestNeighbour        // nearest neighbour interpolation
	ScaleBilinear                // bilinear interpolation
)

func Resize(scaleType int, src *image.RGBA, out *image.RGBA) {
	// !to do set it once instead switching on each iteration
	switch scaleType {
	case ScaleBilinear:
		draw.ApproxBiLinear.Scale(out, out.Bounds(), src, src.Bounds(), draw.Src, nil)
	case ScaleNot:
		fallthrough
	case ScaleNearestNeighbour:
		fallthrough
	default:
		draw.NearestNeighbor.Scale(out, out.Bounds(), src, src.Bounds(), draw.Src, nil)
	}
}
