I have the following:
I want to position i1 and i2 over bi with some angle and then produce a final image. I have x and y axis value for i1 and i2 and their expected rotation angle. i1 and i2 may partially overlay on each other. but I have z index for i1 and i2 to know, if in case they overlap then who will be in foreground.
I am trying to achieve this in Golang.
http://golang.org/doc/articles/image_draw.html seems to do this. Anyone knows any similar example of code, that may help. Or can you show me couple of lines in Golang as a pseudo program?
Thanks.
Not sure exactly what you are looking for and I haven't worked with the image package much at all ... but just following the sample code and using graphics-go package (it works for me), I was able to do something at least.
package main
import (
"fmt"
"os"
"image/draw"
"image"
"image/jpeg"
"code.google.com/p/graphics-go/graphics"
)
func main() {
fImg1, _ := os.Open("arrow1.jpg")
defer fImg1.Close()
img1, _, _ := image.Decode(fImg1)
fImg2, _ := os.Open("arrow2.jpg")
defer fImg2.Close()
img2, _, _ := image.Decode(fImg2)
m := image.NewRGBA(image.Rect(0, 0, 800, 600))
draw.Draw(m, m.Bounds(), img1, image.Point{0,0}, draw.Src)
//draw.Draw(m, m.Bounds(), img2, image.Point{-200,-200}, draw.Src)
graphics.Rotate(m, img2, &graphics.RotateOptions{3.5})
toimg, _ := os.Create("new.jpg")
defer toimg.Close()
jpeg.Encode(toimg, m, &jpeg.Options{jpeg.DefaultQuality})
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With