mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-06-28 06:12:08 +02:00
Use github.com/bamiaux/rez instead of github.com/nfnt/resize for resampling the pyramid tiles. It is much faster but needs some testing.
This commit is contained in:
@ -6,7 +6,6 @@ package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"image"
|
||||
"image/draw"
|
||||
"log"
|
||||
@ -17,7 +16,7 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/nfnt/resize"
|
||||
"github.com/bamiaux/rez"
|
||||
|
||||
"bytes"
|
||||
|
||||
@ -215,9 +214,10 @@ func (tu *tileUpdater) doUpdates() {
|
||||
func updatePyramidTiles(level int, baseDir string, jobs chan xzm, done *sync.WaitGroup) {
|
||||
defer done.Done()
|
||||
scratch := image.NewRGBA(image.Rect(0, 0, 256, 256))
|
||||
resized := image.NewRGBA(image.Rect(0, 0, 128, 128))
|
||||
|
||||
for job := range jobs {
|
||||
if err := updatePyramidTile(scratch, level, baseDir, job); err != nil {
|
||||
if err := updatePyramidTile(scratch, resized, level, baseDir, job); err != nil {
|
||||
log.Printf("Updating pyramid tile failed: %s\n", err)
|
||||
}
|
||||
}
|
||||
@ -243,7 +243,7 @@ var ofs = [4][2]int{
|
||||
|
||||
var windowSize = image.Pt(128, 128)
|
||||
|
||||
func updatePyramidTile(scratch *image.RGBA, level int, baseDir string, j xzm) error {
|
||||
func updatePyramidTile(scratch, resized *image.RGBA, level int, baseDir string, j xzm) error {
|
||||
|
||||
var orig image.Image
|
||||
|
||||
@ -251,8 +251,9 @@ func updatePyramidTile(scratch *image.RGBA, level int, baseDir string, j xzm) er
|
||||
baseDir,
|
||||
strconv.Itoa(level),
|
||||
strconv.Itoa(int(j.P.X)),
|
||||
fmt.Sprintf("%d.png", j.P.Z))
|
||||
strconv.Itoa(int(j.P.Z))+".png")
|
||||
|
||||
sr := resized.Bounds()
|
||||
for i := uint16(0); i < 4; i++ {
|
||||
if j.Mask&(1<<i) != 0 {
|
||||
//log.Printf("level %d: modified %d\n", level, i)
|
||||
@ -264,10 +265,11 @@ func updatePyramidTile(scratch *image.RGBA, level int, baseDir string, j xzm) er
|
||||
strconv.Itoa(bx+o[0]),
|
||||
strconv.Itoa(bz+o[1])+".png")
|
||||
img := common.LoadPNG(path)
|
||||
img = resize.Resize(128, 128, img, resize.Lanczos3)
|
||||
sr := img.Bounds()
|
||||
if err := rez.Convert(resized, img, common.ResizeFilter); err != nil {
|
||||
return err
|
||||
}
|
||||
r := sr.Sub(sr.Min).Add(dps[i])
|
||||
draw.Draw(scratch, r, img, sr.Min, draw.Src)
|
||||
draw.Draw(scratch, r, resized, sr.Min, draw.Src)
|
||||
} else {
|
||||
// Load lazy
|
||||
if orig == nil {
|
||||
|
Reference in New Issue
Block a user