Skip to content

Commit b29a985

Browse files
j4jamesDHowett
authored andcommitted
Improve quality of GDI image scaling (#18495)
When Sixel images are rendered, they're automatically scaled to match the 10x20 cell size of the original hardware terminals. If this requires the image to be scaled down, the default GDI stretching mode can produce ugly visual artefacts, particularly for color images. This PR changes the stretching mode to `COLORONCOLOR`, which looks considerably better, but without impacting performance. The initial Sixel implementation was added in PR #17421. ## Validation Steps Performed I've tested with a number of different images using a small font size to trigger the downscaling, and I think the results are generally better, although simple black on white images are still better with the default mode (i.e. `BLACKONWHITE`), which is understandable. I've also checked the performance with a variation of the [sixel-bench] test, and confirmed that the new mode is no worse than the default. [sixel-bench]: https://github.com/jerch/sixel-bench (cherry picked from commit b243fb6) Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgZ0dHA Service-Version: 1.23
1 parent 684b91f commit b29a985

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

.github/actions/spelling/expect/expect.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ codepages
215215
codepath
216216
coinit
217217
colorizing
218+
COLORONCOLOR
218219
COLORREFs
219220
colorschemes
220221
colorspec

src/renderer/gdi/state.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ GdiEngine::~GdiEngine()
128128
// We need the advanced graphics mode in order to set a transform.
129129
SetGraphicsMode(hdcNewMemoryContext, GM_ADVANCED);
130130

131+
// We set the bitmap stretching mode to improve the Sixel image quality.
132+
SetStretchBltMode(hdcNewMemoryContext, COLORONCOLOR);
133+
131134
// If we had an existing memory context stored, release it before proceeding.
132135
if (nullptr != _hdcMemoryContext)
133136
{

0 commit comments

Comments
 (0)