diff --git a/issue23/Test2.png b/issue23/Test2.png new file mode 100644 index 0000000..108f01c Binary files /dev/null and b/issue23/Test2.png differ diff --git a/issue23/android.png b/issue23/android.png new file mode 100644 index 0000000..ffa068b Binary files /dev/null and b/issue23/android.png differ diff --git a/issue23/go.png b/issue23/go.png new file mode 100644 index 0000000..6ee5238 Binary files /dev/null and b/issue23/go.png differ diff --git a/issue23/issue23.go b/issue23/issue23.go new file mode 100644 index 0000000..c037d91 --- /dev/null +++ b/issue23/issue23.go @@ -0,0 +1,64 @@ +package main + +import ( + "bufio" + "fmt" + "log" + "os" + + "code.google.com/p/draw2d/draw2d" + "image" + "image/draw" + "image/png" + "math" +) + +func saveToPngFile(filePath string, m image.Image) { + f, err := os.Create(filePath) + if err != nil { + log.Println(err) + os.Exit(1) + } + defer f.Close() + b := bufio.NewWriter(f) + err = png.Encode(b, m) + if err != nil { + log.Println(err) + os.Exit(1) + } + err = b.Flush() + if err != nil { + log.Println(err) + os.Exit(1) + } + fmt.Printf("Wrote %s OK.\n", filePath) +} +func main() { + 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.Over, draw2d.LinearFilter) + saveToPngFile("Test2.png", i) +} \ No newline at end of file