mtseeder: Fixed problem that tiles with missing sub tiles were drawn in white entirely.

This commit is contained in:
Sascha L. Teichmann 2014-09-21 09:04:59 +02:00
parent 2709761255
commit d39a948bd4

View File

@ -136,6 +136,22 @@ func createParentLevel(oldDir string, jobs chan pyramidJob) (newDir string, err
return
}
func clip8(x int) int {
switch {
case x < 0:
return 0
case x > 256:
return 256
}
return x
}
func clipRect(r image.Rectangle) image.Rectangle {
return image.Rectangle{
Min: image.Point{X: clip8(r.Min.X), Y: clip8(r.Min.Y)},
Max: image.Point{X: clip8(r.Max.X), Y: clip8(r.Max.Y)}}
}
var dps = [4]image.Point{
image.Pt(0, 256),
image.Pt(0, 0),
@ -148,7 +164,7 @@ func fuseTile(scratch *image.RGBA, job *pyramidJob) (err error) {
img := common.LoadPNG(path)
sr := img.Bounds()
sr := clipRect(img.Bounds())
r := sr.Sub(sr.Min).Add(dps[i])
draw.Draw(scratch, r, img, sr.Min, draw.Src)