DrawImage with RotationMatrix leave a black hole
Closed this issue · 3 comments
GoogleCodeExporter commented
Here is my code:
//load background image
file, err := os.Open("android.png")
if err != nil {
log.Fatal(err)
}
defer file.Close()
a, _, err := image.Decode(file)
//load go icon image
file2, err := os.Open("go.png")
if err != nil {
log.Fatal(err)
}
defer file2.Close()
g, _, err := image.Decode(file2)
if err != nil {
log.Fatal(err)
}
ar := a.Bounds()
w, h, x := ar.Dx(), ar.Dy(), 30.0
i := image.NewRGBA(image.Rect(0, 0, w, h))
draw.Draw(i, ar, a, ar.Min, draw.Src)
tr := draw2d.NewRotationMatrix(x*(math.Pi / 180.0))
draw2d.DrawImage(g, i, tr, draw.Src, draw2d.LinearFilter)
saveToPngFile("Test2", i)
I'm trying to rotate + paste an small image to the background image.
But you can see like the attachment image, why it leave the ugly black hole??
This is a bug or my misstake?
Thanks for your help!
Original issue reported on code.google.com by nvcn...@gmail.com
on 23 Apr 2012 at 3:40
Attachments:
GoogleCodeExporter commented
it seems that is a bug,
but try to use draw2d.DrawImage(g, i, tr, draw.Over, draw2d.LinearFilter), this
may suit your need using draw.Over against drawSrc
it will compose image
Original comment by legoff.l...@gmail.com
on 23 Apr 2012 at 8:09
- Changed state: Accepted
- Added labels: Priority-High
- Removed labels: Priority-Medium
GoogleCodeExporter commented
please update draw2d bug fix
Original comment by legoff.l...@gmail.com
on 24 Apr 2012 at 8:30
- Changed state: Fixed
GoogleCodeExporter commented
110% OK!
Thanks!
Original comment by nvcn...@gmail.com
on 24 Apr 2012 at 1:15