You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hi, fogleman. Thank you very much for your open source project, but I found a problem.
I need a drawn 'image.Image' object and use GO's native method 'Jpeg. Encode' to convert the 'image.Image' object into an IO.Writer object,then I find that the 'context. DrawImage' method does not modify the 'image.Image' object passed in. I think you may be to ensure the security of the 'image.Image' object. However, I found that there was no function in the project to get the ‘context.im’ object, which caused me some trouble when I just wanted to get the image data for network transfer, not SaveJPG() on my disk. Perhaps adding a method to return the ‘context.im’ is more convenient and flexible to use.
// i use code
// This is a little demo that rotates a circular image
// the test.jpg not rotate
func defaultDrawCore(im image.Image) {
w := im.Bounds().Size().X
h := im.Bounds().Size().Y
dc := gg.NewContext(w, h)
dc.DrawRectangle(0, 0, float64(w), float64(h))
dc.SetRGBA(255, 255, 255, 0)
dc.Fill()
radius := math.Min(float64(w), float64(h)) / 2
dc.DrawCircle(float64(w/2), float64(h/2), radius)
dc.Clip()
dc.RotateAbout(gg.Radians(45), float64(w/2), float64(h/2))
dc.DrawImage(im, 0, 0)
buf := new(bytes.Buffer)
jpeg.Encode(buf, im, &jpeg.Options{Quality: 90})
newim, imErr := jpeg.Decode(buf)
if imErr != nil {
return
}
gg.SaveJPG("test.jpg", newim, 90)
return
}
// Perhaps adding a function will solve this problem
func (dc *Context) GetIM() *image.RGBA {
return dc.im
}
The text was updated successfully, but these errors were encountered:
hi, fogleman. Thank you very much for your open source project, but I found a problem.
I need a drawn 'image.Image' object and use GO's native method 'Jpeg. Encode' to convert the 'image.Image' object into an IO.Writer object,then I find that the 'context. DrawImage' method does not modify the 'image.Image' object passed in. I think you may be to ensure the security of the 'image.Image' object. However, I found that there was no function in the project to get the ‘context.im’ object, which caused me some trouble when I just wanted to get the image data for network transfer, not SaveJPG() on my disk. Perhaps adding a method to return the ‘context.im’ is more convenient and flexible to use.
// i use code
// This is a little demo that rotates a circular image
// the test.jpg not rotate
func defaultDrawCore(im image.Image) {
w := im.Bounds().Size().X
h := im.Bounds().Size().Y
dc := gg.NewContext(w, h)
dc.DrawRectangle(0, 0, float64(w), float64(h))
dc.SetRGBA(255, 255, 255, 0)
dc.Fill()
radius := math.Min(float64(w), float64(h)) / 2
dc.DrawCircle(float64(w/2), float64(h/2), radius)
dc.Clip()
dc.RotateAbout(gg.Radians(45), float64(w/2), float64(h/2))
dc.DrawImage(im, 0, 0)
buf := new(bytes.Buffer)
jpeg.Encode(buf, im, &jpeg.Options{Quality: 90})
newim, imErr := jpeg.Decode(buf)
if imErr != nil {
return
}
gg.SaveJPG("test.jpg", newim, 90)
return
}
// Perhaps adding a function will solve this problem
func (dc *Context) GetIM() *image.RGBA {
return dc.im
}
The text was updated successfully, but these errors were encountered: