gg
gg copied to clipboard
Can't scale an image
I can't figure out how to scale an image. No matter which x, y
parameters I feed to Scale
, this method seems to be a no-op.
package main
import "github.com/fogleman/gg"
func main() {
dc := gg.NewContext(1000, 1000)
dc.DrawCircle(500, 500, 400)
dc.SetRGB(0, 0, 0)
dc.Fill()
dc.Scale(10, 10)
dc.SavePNG("out.png")
}
Maybe I've forgotten to call some other method that performs actual scaling?
@Hirrolot Try this.
package main
import (
"github.com/fogleman/gg"
"github.com/nfnt/resize"
)
func main() {
dc := gg.NewContext(1000, 1000)
dc.DrawCircle(500, 500, 400)
dc.SetRGB(0, 0, 0)
dc.Fill()
//dc.Scale(10, 10)
img := resize.Resize(10, 10, dc.Image(), resize.Lanczos2)
dc = gg.NewContextForImage(img)
dc.SavePNG("out.png")
}