Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't scale an image #186

Open
Hirrolot opened this issue Mar 31, 2023 · 1 comment
Open

Can't scale an image #186

Hirrolot opened this issue Mar 31, 2023 · 1 comment

Comments

@Hirrolot
Copy link

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?

@mazznoer
Copy link
Contributor

@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")
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants