From 0850b690288f67e7e15ce80c56553369a15d2ec1 Mon Sep 17 00:00:00 2001 From: "Sascha L. Teichmann" Date: Sun, 14 Sep 2014 23:10:54 +0200 Subject: [PATCH] Fixed tile fusing. --- cmd/mtseeder/pyramid.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cmd/mtseeder/pyramid.go b/cmd/mtseeder/pyramid.go index 111f339..8e62860 100644 --- a/cmd/mtseeder/pyramid.go +++ b/cmd/mtseeder/pyramid.go @@ -151,21 +151,22 @@ func loadImage(path string) image.Image { return img } -func fuseTile(scratch *image.RGBA, job *pyramidJob) (err error) { +var dps = [4]image.Point{ + image.Pt(0, 256), + image.Pt(0, 0), + image.Pt(256, 256), + image.Pt(256, 0)} - var ofs = [4][2]int{ - {0, 0}, - {0, 256}, - {256, 0}, - {256, 256}} +func fuseTile(scratch *image.RGBA, job *pyramidJob) (err error) { for i, path := range job.src { img := loadImage(path) - draw.Draw(scratch, - image.Rect(ofs[i][0], ofs[i][1], 256, 256), - img, image.ZP, draw.Src) + sr := img.Bounds() + r := sr.Sub(sr.Min).Add(dps[i]) + + draw.Draw(scratch, r, img, sr.Min, draw.Src) } resized := resize.Resize(256, 256, scratch, resize.Bicubic) @@ -184,7 +185,6 @@ func fuseTile(scratch *image.RGBA, job *pyramidJob) (err error) { out.Flush() err = outFile.Close() - return }