Process Hacker Discussion Forum

Posts: 147
Joined: 19 Mar 2011 20:17

Anti-aliased icons?

15 Aug 2012 06:32

Can we pleeeeeeeeeeeeeeeease have them? :D

It's really not that hard... just assume the icon is twice as big, and use StretchBlt (HALFTONE) to shrink it down before displaying it (maybe multiply the brightness by 2 after shrinking, to make up for the loss in brightness in front of the black background).

I just tried it on the CPU usage icon, and it works well. But making the change globally is annoying because it's going to get messed up every time I update.

Pleeeease? :)
User avatar
Posts: 1695
Joined: 17 Jan 2011 05:43

Re: Anti-aliased icons?

15 Aug 2012 10:14

Upload the patch and I'll try sorting it out ;)
Posts: 147
Joined: 19 Mar 2011 20:17

Re: Anti-aliased icons?

15 Aug 2012 11:05

Awesome, thanks for giving it a try! :D

I'm not sure how to upload with SVN (don't really use it and it kinda feels overkill here...) but here's the code...

The patch is small, but definitely ugly. :(

1. In phapp.h, declare
extern LONG PhSmallIconSizeScaleFactor;
2. In main.c, define
LONG PhSmallIconSizeScaleFactor = 2;
3. Look for all usages of
and multiply them by
4. In notifico.c, wherever you see
        SelectObject(hdc, oldBitmap);
        icon = PhNfBitmapToIcon(hNewBitmap);
Replace it with:
        HDC hNewDC = CreateCompatibleDC(hdc);
        HBITMAP hNewBitmap = CreateCompatibleBitmap(hdc, drawInfo.Width / PhSmallIconSizeScaleFactor, drawInfo.Height / PhSmallIconSizeScaleFactor),
                hOldBitmap = SelectBitmap(hNewDC, hNewBitmap);
        SetStretchBltMode(hNewDC, STRETCH_HALFTONE);
        StretchBlt(hNewDC, 0, 0, drawInfo.Width / PhSmallIconSizeScaleFactor, drawInfo.Height / PhSmallIconSizeScaleFactor, hdc, 0, 0, drawInfo.Width, drawInfo.Height, SRCCOPY);

        SelectObject(hdc, oldBitmap);
        icon = PhNfBitmapToIcon(hNewBitmap);

        SelectBitmap(hNewDC, hOldBitmap);


This still misses a few spots (e.g. for registered icons), but it works for CPU usage and maybe one or two others at least.

Hope it's useful.