Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix misalignment of Sixel image slices #17724

Merged
merged 2 commits into from
Aug 15, 2024

Conversation

j4james
Copy link
Collaborator

@j4james j4james commented Aug 15, 2024

Summary of the Pull Request

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.

PR Checklist

@microsoft-github-policy-service microsoft-github-policy-service bot added Issue-Bug It either shouldn't be doing this or needs an investigation. Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues Product-Terminal The new Windows Terminal. labels Aug 15, 2024
Comment on lines 686 to +688
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;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a little optimization that I noticed when investigating the rounding problems. The srcHeight is always srcCellSize.height, so the dstHeight should always be dstCellSize.height.

@j4james j4james marked this pull request as ready for review August 15, 2024 16:15
@j4james
Copy link
Collaborator Author

j4james commented Aug 15, 2024

I'm assuming the audit failure is because the build server has a new version of the compiler.

Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, that's subtle. Thanks!

@DHowett
Copy link
Member

DHowett commented Aug 15, 2024

Don't worry about audit mode - #17723

@DHowett DHowett merged commit 65219d4 into microsoft:main Aug 15, 2024
13 of 15 checks passed
@PhMajerus
Copy link

PhMajerus commented Aug 16, 2024

Thanks for this fix!
I can confirm it fixed my test file, as well as my original observation that made me investigate the issue:
image
image

Being able to display icons in the terminal is so nice, so many new possibilities, I have to write a Sixel conversion component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue with sixel rendering: stretched bands
4 participants