Prevent transparent background

This commit is contained in:
David Vogel 2024-01-15 21:31:45 +01:00
parent d82fda528a
commit f22ef05411
3 changed files with 12 additions and 5 deletions

View File

@ -1,4 +1,4 @@
// Copyright (c) 2022-2023 David Vogel
// Copyright (c) 2022-2024 David Vogel
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
@ -8,6 +8,7 @@ package main
import (
"image"
"image/color"
"image/draw"
"runtime"
"sync"
)
@ -69,7 +70,9 @@ func (sic *StitchedImageCache) Regenerate() *image.RGBA {
si := sic.stitchedImage
// Create new image with default background color.
cacheImage := image.NewRGBA(sic.rect)
draw.Draw(cacheImage, cacheImage.Bounds(), &image.Uniform{colorBackground}, cacheImage.Bounds().Min, draw.Src)
// List of tiles that intersect with the to be generated cache image.
intersectingTiles := []*ImageTile{}

View File

@ -1,4 +1,4 @@
// Copyright (c) 2022-2023 David Vogel
// Copyright (c) 2022-2024 David Vogel
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
@ -13,6 +13,10 @@ import (
"time"
)
// The default background color.
// We use a non transparent black.
var colorBackground = color.RGBA{0, 0, 0, 255}
// StitchedImageCacheGridSize defines the worker chunk size when the cache image is regenerated.
var StitchedImageCacheGridSize = 256
@ -116,7 +120,7 @@ func (si *StitchedImage) RGBAAt(x, y int) color.RGBA {
// Determine the cache rowIndex index.
rowIndex := (y + si.cacheRowYOffset) / si.cacheRowHeight
if rowIndex < 0 || rowIndex >= len(si.cacheRows) {
return color.RGBA{}
return colorBackground
}
// Check if we advanced/changed the row index.

View File

@ -1,4 +1,4 @@
// Copyright (c) 2023 David Vogel
// Copyright (c) 2023-2024 David Vogel
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
@ -29,7 +29,7 @@ func (s SubStitchedImage) At(x, y int) color.Color {
func (s SubStitchedImage) RGBAAt(x, y int) color.RGBA {
point := image.Point{X: x, Y: y}
if !point.In(s.bounds) {
return color.RGBA{}
return colorBackground
}
return s.StitchedImage.RGBAAt(x, y)