summaryrefslogtreecommitdiffstats
path: root/sixel.go
diff options
context:
space:
mode:
authorRose Hogenson <rosehogenson@posteo.net>2026-06-11 20:46:54 -0700
committerRose Hogenson <rosehogenson@posteo.net>2026-06-11 20:47:21 -0700
commitfb0d38647a225e5c1c4f210b6daaf1614eb88f6b (patch)
tree670cdfc4e6eff20d141bc884cc00b5e6333844a0 /sixel.go
parent04723f34560234b1ab9aa0251ecd90a02de95c13 (diff)
downloadsixel-main.tar.zst
Ensure that out of bounds pixels are transparentHEADmain
Diffstat (limited to 'sixel.go')
-rw-r--r--sixel.go7
1 files changed, 3 insertions, 4 deletions
diff --git a/sixel.go b/sixel.go
index 180d28c..2fda48e 100644
--- a/sixel.go
+++ b/sixel.go
@@ -79,7 +79,7 @@ func Print(w io.Writer, img image.Image, p color.Palette) error {
}
}
colors := make([]bool, 256)
- for y := y0; y < y0+6; y++ {
+ for y := y0; y < min(y0+6, palettized.Bounds().Max.Y); y++ {
for x := palettized.Bounds().Min.X; x < palettized.Bounds().Max.X; x++ {
colors[palettized.ColorIndexAt(x, y)] = true
}
@@ -109,10 +109,9 @@ func Print(w io.Writer, img image.Image, p color.Palette) error {
)
for x := palettized.Bounds().Min.X; x < palettized.Bounds().Max.X; x++ {
var char byte
- for j := range 6 {
- y := y0 + j
+ for y := y0; y < min(y0+6, palettized.Bounds().Max.Y); y++ {
if palettized.ColorIndexAt(x, y) == c {
- char |= 1 << j
+ char |= 1 << (y - y0)
}
}
char += '?'