示例#1
0
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)
}
示例#2
0
func main() {
	source := loadFromPngFile("../resource/image/TestAndroid.png")
	dest := image.NewRGBA(image.Rect(0, 0, 1024, 768))
	width, height := float64(source.Bounds().Dx()), float64(source.Bounds().Dy())
	tr := draw2d.NewIdentityMatrix()
	tr.Translate(width/2, height/2)
	tr.Rotate(30 * math.Pi / 180)
	//tr.Scale(3, 3)
	tr.Translate(-width/2, -height/2)
	tr.Translate(200, 5)
	draw2d.DrawImage(source, dest, tr, draw.Over, draw2d.BilinearFilter)
	saveToPngFile("../resource/result/TestDrawImage.png", dest)
}