From d2d30c5aec825310d1cc027ad9d4898779c3c4a8 Mon Sep 17 00:00:00 2001 From: diarmidmackenzie Date: Thu, 5 Feb 2026 15:05:50 +0000 Subject: [PATCH] Fix out-by-one error --- src/components/scene/screenshot.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/scene/screenshot.js b/src/components/scene/screenshot.js index bb07ca52a81..0ce36cff28b 100644 --- a/src/components/scene/screenshot.js +++ b/src/components/scene/screenshot.js @@ -236,10 +236,12 @@ export var Component = registerComponent('screenshot', { var flippedPixels = pixels.slice(0); for (var x = 0; x < width; ++x) { for (var y = 0; y < height; ++y) { - flippedPixels[x * 4 + y * width * 4] = pixels[x * 4 + (height - y) * width * 4]; - flippedPixels[x * 4 + 1 + y * width * 4] = pixels[x * 4 + 1 + (height - y) * width * 4]; - flippedPixels[x * 4 + 2 + y * width * 4] = pixels[x * 4 + 2 + (height - y) * width * 4]; - flippedPixels[x * 4 + 3 + y * width * 4] = pixels[x * 4 + 3 + (height - y) * width * 4]; + var from = x * 4 + (height - y - 1) * width * 4; + var to = x * 4 + y * width * 4; + flippedPixels[to] = pixels[from]; + flippedPixels[to + 1] = pixels[from + 1]; + flippedPixels[to + 2] = pixels[from + 2]; + flippedPixels[to + 3] = pixels[from + 3]; } } return flippedPixels;