Fix misalignment of Sixel image slices (#17724)

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
This commit is contained in:
James Holderness 2024-08-15 17:39:28 +01:00 committed by GitHub
parent bf44b6c360
commit 65219d40ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 1 additions and 2 deletions

View File

@ -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)
{

View File

@ -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;