When generating shaded tiles draw to pix buffer directly instead of calling Set() for each pixel. Set resize filter for generating pyramid tiles to Lanczos3 because of better visual results.

This commit is contained in:
Sascha L. Teichmann 2014-09-16 00:08:31 +02:00
parent 0850b69028
commit 90bfc225b8
2 changed files with 17 additions and 7 deletions

View File

@ -169,7 +169,7 @@ func fuseTile(scratch *image.RGBA, job *pyramidJob) (err error) {
draw.Draw(scratch, r, img, sr.Min, draw.Src)
}
resized := resize.Resize(256, 256, scratch, resize.Bicubic)
resized := resize.Resize(256, 256, scratch, resize.Lanczos3)
var outFile *os.File
if outFile, err = os.Create(job.dst); err != nil {

View File

@ -346,11 +346,20 @@ func (r *Renderer) CreateShadedImage(
stride := pw - width
istride := image.Stride + 4*width
iofs := image.PixOffset(0, height-1)
pix := image.Pix
for z := height - 1; z >= 0; z-- {
for x := 0; x < width; x++ {
colIdx := r.cBuffer[ofs]
if colIdx < 0 || colIdx >= numCols {
image.Set(x, z, background)
pix[iofs] = background.R
pix[iofs+1] = background.G
pix[iofs+2] = background.B
pix[iofs+3] = 0xff
} else {
var y, y1, y2 int32
y = r.yBuffer[ofs]
@ -369,15 +378,16 @@ func (r *Renderer) CreateShadedImage(
d = 36
}
col := colors[colIdx]
image.Set(x, z, color.RGBA{
R: safeColor(int32(col.R) + d),
G: safeColor(int32(col.G) + d),
B: safeColor(int32(col.B) + d),
A: 0xff})
pix[iofs] = safeColor(int32(col.R) + d)
pix[iofs+1] = safeColor(int32(col.G) + d)
pix[iofs+2] = safeColor(int32(col.B) + d)
pix[iofs+3] = 0xff
}
iofs += 4
ofs++
}
ofs += stride
iofs -= istride
}
return image
}