From cbdd925c303e65bd2ae701e2ae337507d856d088 Mon Sep 17 00:00:00 2001 From: David Vogel Date: Sat, 23 Dec 2023 01:09:50 +0100 Subject: [PATCH] Correct image.Rectangle downscaling --- bin/stitch/image-tile.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/stitch/image-tile.go b/bin/stitch/image-tile.go index ddff8db..ce74dfe 100644 --- a/bin/stitch/image-tile.go +++ b/bin/stitch/image-tile.go @@ -36,6 +36,7 @@ type ImageTile struct { } // NewImageTile returns an image tile object that represents the image at the given path. +// The filename will be used to determine the top left x and y coordinate of the tile. // This will not load the image into RAM. func NewImageTile(path string, scaleDivider int) (ImageTile, error) { if scaleDivider < 1 { @@ -71,7 +72,7 @@ func NewImageTile(path string, scaleDivider int) (ImageTile, error) { fileName: path, modTime: modTime, scaleDivider: scaleDivider, - image: image.Rect(x/scaleDivider, y/scaleDivider, (x+width)/scaleDivider, (y+height)/scaleDivider), + image: image.Rect(DivideFloor(x, scaleDivider), DivideFloor(y, scaleDivider), DivideCeil(x+width, scaleDivider), DivideCeil(y+height, scaleDivider)), imageMutex: &sync.RWMutex{}, invalidationChan: make(chan struct{}, 1), timeoutChan: make(chan struct{}, 1),