mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-12-24 01:00:18 +01:00
mtwebmapper: Reduced the amount of copying from old tile. Code still reads a bit clumpsy.
This commit is contained in:
parent
8b6470fc9c
commit
11a4b9f471
@ -194,38 +194,20 @@ var ofs = [4][2]int{
|
||||
{0, 1},
|
||||
{1, 1}}
|
||||
|
||||
/*
|
||||
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 windowSize = image.Pt(128, 128)
|
||||
var windowSize = image.Pt(128, 128)
|
||||
|
||||
func updatePyramidTile(scratch *image.RGBA, level int, baseDir string, j xzm) error {
|
||||
|
||||
var orig image.Image
|
||||
|
||||
origPath := filepath.Join(
|
||||
baseDir, strconv.Itoa(level), strconv.Itoa(int(j.P.X)), fmt.Sprintf("%d.png", j.P.Z))
|
||||
baseDir,
|
||||
strconv.Itoa(level),
|
||||
strconv.Itoa(int(j.P.X)),
|
||||
fmt.Sprintf("%d.png", j.P.Z))
|
||||
|
||||
if j.numChanges() < 4 {
|
||||
orig = common.LoadPNG(origPath)
|
||||
sr := orig.Bounds()
|
||||
r := sr.Sub(sr.Min)
|
||||
draw.Draw(scratch, r, orig, sr.Min, draw.Src)
|
||||
}
|
||||
|
||||
for i := uint16(0); i < 4; i++ {
|
||||
@ -234,19 +216,20 @@ func updatePyramidTile(scratch *image.RGBA, level int, baseDir string, j xzm) er
|
||||
o := ofs[i]
|
||||
bx, bz := int(2*j.P.X), int(2*j.P.Z)
|
||||
path := filepath.Join(
|
||||
baseDir, strconv.Itoa(level+1), strconv.Itoa(bx+o[0]), fmt.Sprintf("%d.png", bz+o[1]))
|
||||
baseDir,
|
||||
strconv.Itoa(level+1),
|
||||
strconv.Itoa(bx+o[0]),
|
||||
fmt.Sprintf("%d.png", bz+o[1]))
|
||||
img := common.LoadPNG(path)
|
||||
img = resize.Resize(128, 128, img, resize.Lanczos3)
|
||||
sr := img.Bounds()
|
||||
r := sr.Sub(sr.Min).Add(dps[i])
|
||||
draw.Draw(scratch, r, img, sr.Min, draw.Src)
|
||||
} else {
|
||||
/*
|
||||
log.Printf("level %d: copied %d", level, i)
|
||||
dp := dps[i].Add(scratch.Bounds().Min)
|
||||
r := image.Rectangle{dp, dp.Add(windowSize)}
|
||||
//log.Printf("level %d: copied %d", level, i)
|
||||
min := orig.Bounds().Min.Add(dps[i])
|
||||
r := image.Rectangle{min, min.Add(windowSize)}
|
||||
draw.Draw(scratch, r, orig, orig.Bounds().Min.Add(dps[i]), draw.Src)
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user