Skip to content

Commit

Permalink
Fix misalignment of Sixel image slices (#17724)
Browse files Browse the repository at this point in the history
When we have a series of image slices of differing widths, which also
don't align with the cell boundaries, we can get rounding errors in the
scaling which makes the different slices appear misaligned.

This PR fixes the issue by removing the 4 pixel width alignment that was
enforced in the `ImageSlice` class, since that's not actually necessary
when the pixels themselves are already 4 bytes in size. And without
that, the widths should be correctly aligned with the cell boundaries.

## References and Relevant Issues

The initial Sixel implementation was added in PR #17421.

## Validation Steps Performed

I've confirmed that this fixes the rendering glitches reported in
#17711, and all my existing Sixel tests still work as expected.

Closes #17711
  • Loading branch information
j4james authored Aug 15, 2024
1 parent bf44b6c commit 65219d4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
1 change: 0 additions & 1 deletion src/buffer/out/ImageSlice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ RGBQUAD* ImageSlice::MutablePixels(const til::CoordType columnBegin, const til::
_columnBegin = existingData ? std::min(_columnBegin, columnBegin) : columnBegin;
_columnEnd = existingData ? std::max(_columnEnd, columnEnd) : columnEnd;
_pixelWidth = (_columnEnd - _columnBegin) * _cellSize.width;
_pixelWidth = (_pixelWidth + 3) & ~3; // Renderer needs this as a multiple of 4
const auto bufferSize = _pixelWidth * _cellSize.height;
if (existingData)
{
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/gdi/paint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ try
const auto srcWidth = imageSlice.PixelWidth();
const auto srcHeight = srcCellSize.height;
const auto dstWidth = srcWidth * dstCellSize.width / srcCellSize.width;
const auto dstHeight = srcHeight * dstCellSize.height / srcCellSize.height;
const auto dstHeight = dstCellSize.height;
const auto x = (imageSlice.ColumnOffset() - viewportLeft) * dstCellSize.width;
const auto y = targetRow * dstCellSize.height;

Expand Down

0 comments on commit 65219d4

Please sign in to comment.