From e611489b8685808726d3f603571b763982d92f67 Mon Sep 17 00:00:00 2001 From: Michael Fogleman Date: Fri, 28 Jul 2017 18:55:21 -0400 Subject: [PATCH] concat example --- examples/concat.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 examples/concat.go diff --git a/examples/concat.go b/examples/concat.go new file mode 100644 index 0000000..a57a4a0 --- /dev/null +++ b/examples/concat.go @@ -0,0 +1,30 @@ +package main + +import ( + "math" + + "github.com/fogleman/gg" +) + +func main() { + im1, err := gg.LoadPNG("examples/lenna.png") + if err != nil { + panic(err) + } + + im2, err := gg.LoadPNG("examples/gopher.png") + if err != nil { + panic(err) + } + + s1 := im1.Bounds().Size() + s2 := im2.Bounds().Size() + + width := int(math.Max(float64(s1.X), float64(s2.X))) + height := s1.Y + s2.Y + + dc := gg.NewContext(width, height) + dc.DrawImage(im1, 0, 0) + dc.DrawImage(im2, 0, s1.Y) + dc.SavePNG("out.png") +}