Example #1
0
// Clones the image if resize is not necessary.
func resizeIfNec(size image.Point, im image.Image, interp resize.InterpolationFunction) image.Image {
	if size.Eq(im.Bounds().Size()) {
		return clone(im)
	}
	log.Printf("resize %v to %v", im.Bounds().Size(), size)
	return resize.Resize(uint(size.X), uint(size.Y), im, interp)
}
Example #2
0
func (obj *Image) SetCentre(p image.Point) {
	p = p.Sub(centreDist(obj.Bbox()))
	if p.Eq(obj.item.R.Min) {
		return
	}
	obj.backing.Atomically(func(flush FlushFunc) {
		r := obj.item.R
		obj.item.R = r.Add(p.Sub(r.Min))
		flush(r, nil)
		flush(obj.item.R, nil)
	})
}