Skip to content

Commit 26875ff

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_lADOAF3p4s4AmhmQzgZ0dHI Service-Version: 1.22
1 parent 6ffde34 commit 26875ff

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
@@ -214,6 +214,7 @@ codepages
214214
codepath
215215
coinit
216216
colorizing
217+
COLORONCOLOR
217218
COLORREFs
218219
colorschemes
219220
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)