Is there a size limit on the surface submitted to SDL_SetWindowIcon?

See title.

Is it OS specific? Is it auto-scaled down? How pretty is it allowed to be?

Yes, yes, depends =)

On Linux it depends on the Desktop Environment.
Like KDE, GNOME, Enlightenment, etc. or you follow
You can even use svg as source and scale during runtime, but since we are talking of a Window Icon… you wanna have a tiny resolution for the window and as an example a bigger one for the taskswitcher or any panel. You provide a set.


How are you gonna provide a set with SDL_SetWindowIcon()? (You can’t)

Practical advice: It seems safe to use 32bit color surfaces for icons.
I think SDL scales images down if needed; 64x64 pixel icons should look
okayish on most systems (ok, a bit crappy on Hi-DPI displays or if
they’re blown up a lot for task-switch menus, but probably still better
than downscaling a 256x256px image to 32x32 for the actual window icon).

By the way, if you’d like to integrate the icon into your executable
(instead of loading it from a file), I wrote a blog post about that:


No need to correct me. I even provided the 256x256px in the first link.
And ofc you want to provide a set. I know TheBuzzSaw didn’t asked for the needed Icon-Set but he also didn’t ask how to embed an Icon.
I tried to be polite since nobody answered this basic question.

Oh, and btw, you could check the display resolution during runtime and provide an Icon-Set only for the window. And my personal opinion is: embedding any assets, is not the way to go - you can doesn’t mean you should. But that depends on the purpose of the written code, like I think your blog entry was for demonstration only. I tried loading xpm also, but I think we basically left the age where people would do that, if one wants to deploy the software and keep it maintainable.


Maybe I misunderstood what you meant with “set” then - as far as I know, at least on some systems there are native APIs that allow you to provide a set of icons in different resolutions and the system then chooses the most appropriate icon (e.g. a 32x32px icon for the window title and a 128x128px icon in the taskswitcher and 64x64 in the taskbar). This is not supported by SDL currently (would be handy though, especially considering Hi-DPI diplays becoming more popular).

Integrating the icon is easy (and Windows developers often expect to do that because there icons are usually integrated as Windows Resource data), and especially helpful if your game otherwise doesn’t support loading common 32bit image formats (like .png) - or does support those but doesn’t otherwise use SDL_Surfaces, so you’d have to create the surface with your pixeldata yourself.
I know SDL has .bmp support builtin, but support for 32bit (with alpha) bitmaps is often non-existant or broken in software, so it’s probably better to avoid that…