diff --git a/bin/stitch/stitched-image-cache.go b/bin/stitch/stitched-image-cache.go index fd68714..729016e 100644 --- a/bin/stitch/stitched-image-cache.go +++ b/bin/stitch/stitched-image-cache.go @@ -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{} diff --git a/bin/stitch/stitched-image.go b/bin/stitch/stitched-image.go index c3d0914..a9b2d05 100644 --- a/bin/stitch/stitched-image.go +++ b/bin/stitch/stitched-image.go @@ -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. diff --git a/bin/stitch/sub-stitched-image.go b/bin/stitch/sub-stitched-image.go index 3eca3fe..f147845 100644 --- a/bin/stitch/sub-stitched-image.go +++ b/bin/stitch/sub-stitched-image.go @@ -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)