How to programmatically create a “bright” and “gray” version of an icon?

In a win32 application, I want to have a button with an icon that looks gray when the button is disabled and “brighter” when the mouse hesitates.

I know that I can create three bitmaps using the icon editor, but since the icon can be selected and loaded from disk, I would like to create the other two versions programmatically.

So, starting with the image descriptor, I would like to: - Create a new image with all the colors converted to gray.
- Create a new image with all colors shifted to white or yellow.

Can this be done using win32 api calls?

Examples in any language will be appreciated.

+3
source share
2 answers

Perhaps a good enough old DrawState . (For some reason, it is now listed as available only from Win2000, which is not true.)

And maybe not, in which case you can use the SetColorAdjustment function .

+1
source

If the icon is selected by the user, do you control the format? If not, you probably want to include an image library or an external process, such as DevIL or Imagemagick, that handle more formats than the Microsoft APIs, most likely ...

0
source

Source: https://habr.com/ru/post/1727901/