Skip to content

fix: high-quality sampling for downscaled app icons - #832

Open
xav-ie wants to merge 1 commit into
FelixKratz:masterfrom
xav-ie:pr/app-icon-hq-sampling
Open

fix: high-quality sampling for downscaled app icons#832
xav-ie wants to merge 1 commit into
FelixKratz:masterfrom
xav-ie:pr/app-icon-hq-sampling

Conversation

@xav-ie

@xav-ie xav-ie commented Jul 3, 2026

Copy link
Copy Markdown

Problem

App icons in the bar (icon.background.image=app.<bundle-id>) render with
visible jagged/aliased edges instead of a clean downscaled icon.

The bar's window context is created with kCGInterpolationNone (window.c),
which is the right default for the bar's pixel-exact PNG/alias icons — they are
drawn 1:1 and stay crisp. App icons are the exception: workspace_icon_for_app
returns the app's NSImage at its native representation size (often 128px+),
which then gets scaled down to the item's icon size at draw time. Downscaling
with nearest-neighbour sampling decimates the image, producing the aliasing.

Fix

In image_draw, sample only the sources that are genuinely rescaled — app
icons, space previews, and linked media artwork — with kCGInterpolationHigh
for the CGContextDrawImage call, then restore kCGInterpolationNone.

File-backed image icons and text are unaffected: they draw 1:1 or ignore
interpolation quality entirely, so they stay pixel-crisp as before.

Notes

  • Scoped by checking image->path for the app./space. prefixes (plus the
    image->link media-artwork case), so the crisp default is preserved for
    everything else.
  • No API/config surface change; purely a rendering-quality fix.

Testing

Before/after screenshots of a front_app-style item showing the app icon:

before after_
sketchybar-app-icon-before sketchybar-app-icon-after

The bar context uses kCGInterpolationNone so pixel-exact PNG icons stay
crisp, but app icons come from NSImage at native size and get scaled down,
so nearest-neighbour sampling leaves them jagged. Draw the scaled sources
(app icons, space previews, media artwork) with kCGInterpolationHigh.
@xav-ie
xav-ie marked this pull request as ready for review July 3, 2026 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant