Skip to content

Commit d2e9475

Browse files
Fix out-by-one error (#5790)
1 parent 5e98e2d commit d2e9475

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/components/scene/screenshot.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,12 @@ export var Component = registerComponent('screenshot', {
236236
var flippedPixels = pixels.slice(0);
237237
for (var x = 0; x < width; ++x) {
238238
for (var y = 0; y < height; ++y) {
239-
flippedPixels[x * 4 + y * width * 4] = pixels[x * 4 + (height - y) * width * 4];
240-
flippedPixels[x * 4 + 1 + y * width * 4] = pixels[x * 4 + 1 + (height - y) * width * 4];
241-
flippedPixels[x * 4 + 2 + y * width * 4] = pixels[x * 4 + 2 + (height - y) * width * 4];
242-
flippedPixels[x * 4 + 3 + y * width * 4] = pixels[x * 4 + 3 + (height - y) * width * 4];
239+
var from = x * 4 + (height - y - 1) * width * 4;
240+
var to = x * 4 + y * width * 4;
241+
flippedPixels[to] = pixels[from];
242+
flippedPixels[to + 1] = pixels[from + 1];
243+
flippedPixels[to + 2] = pixels[from + 2];
244+
flippedPixels[to + 3] = pixels[from + 3];
243245
}
244246
}
245247
return flippedPixels;

0 commit comments

Comments
 (0)