Load embedded icons to SDL_Surface

Is there any way to load embedded icons from rc file on windows to
SDL_Surface? SDL_LoadBMP(iconname) seems to be not working for me.

It depends on which icon you’re talking about.

The different icons you can change is:

  1. The icon that is seen when looking at the exe file in Windows Explorer (and other programs).
  2. The icon that is seen in the task bar when the exe file is started.
  3. The icon that is seen in the programs upper bar (to the left of the window title).

Icon 1 and 2 can easily be changed by choosing Add --> Resource --> Icon in Visual Studio. In there an icon of 16x16 size and an icon of 32x32 size can be created.
If you’re using another IDE, you need to check how to add an icon file.
When the two icons has been created they should be seen in Windows Explorer and in the task bar as soon as the exe has been builded and executed.

Icon 3 is a bit harder to change and according to some pages there’s ways to change it by using some Windows specific code, but then the icon change will only work on Windows. Check these pages for more information:

http://forums.libsdl.org/viewtopic.php?t=8323&sid=4ad14ec89ec998528f309cf0fb7c7842

If you don’t want to go through all that and write Windows-specific code, you can create the icon as a image file, convert it into a raw/binary file and then load it will SDL_LoadBMP_RW. I have never changed the icon on my applications/games but if I will ever do it, I will probably create a binary file containing my icon image file.

It depends on which icon you’re talking about.

The different icons you can change is:

  1. The icon that is seen when looking at the exe file in Windows Explorer (and other programs).
  2. The icon that is seen in the task bar when the exe file is started.
  3. The icon that is seen in the upper bar (to the left of the window title) when the application is started.

Icon 1 and 2 can easily be changed by choosing Add --> Resource --> Icon in Visual Studio. In there an icon of 16x16 size and an icon of 32x32 size can be created.
If you’re using another IDE, you need to check how to add an icon file.
When the two icons has been created they should be seen in Windows Explorer and in the task bar as soon as the exe has been builded and executed.

Icon 3 is a bit harder to change and according to some pages there’s ways to change it by using some Windows specific code, but then the icon change will only work on Windows. Check these pages for more information:

http://forums.libsdl.org/viewtopic.php?t=8323&sid=4ad14ec89ec998528f309cf0fb7c7842

If you don’t want to go through all that and write Windows-specific code, you can create the icon as a image file, convert it into a raw/binary file and then load it will SDL_LoadBMP_RW. I have never changed the icon on my applications/games but if I will ever do it, I will probably create a binary file containing my icon image file.

It depends on which icon you’re talking about.

The different icons you can change is:

  1. The icon that is seen when looking at the exe file in Windows Explorer (and other programs).
  2. The icon that is seen in the task bar when the exe file is started.
  3. The icon that is seen in the upper bar (to the left of the window title) when the application is started.

Icon 1 and 2 can easily be changed by choosing Add --> Resource --> Icon in Visual Studio. In there an icon of 16x16 size and an icon of 32x32 size can be created.
If you’re using another IDE, you need to check how to add an icon file.
When the two icons has been created they should be seen in Windows Explorer and in the task bar as soon as the exe has been builded and executed.

Icon 3 is a bit harder to change and according to some pages there’s ways to change it by using some Windows specific code, but I guess the icon change will only work on Windows then. Check these pages for more information:

http://forums.libsdl.org/viewtopic.php?t=8323&sid=4ad14ec89ec998528f309cf0fb7c7842

If you don’t want to go through all that and write Windows-specific code, you can create the icon as a image file, convert it into a raw/binary file and then load it with SDL_LoadBMP_RW. The icon can then be changed by using SDL_SetWindowIcon and passing the surface that has been created with the function above.
I have never changed the icon in my applications / games but if I will do it, I will probably do it like that.

Hello,

I?m not familiar with RC files per se, but assuming you can figure out how to decode the file, you could do something like:

Use xxd (a command line utility) to dump the icon bitmap data into a C array that you can read back using SDL_RWops [1].

  1. https://wiki.libsdl.org/SDL_LoadBMP_RW?highlight=(\bCategoryAPI\b)|(SDLFunctionTemplate) https://wiki.libsdl.org/SDL_LoadBMP_RW?highlight=(\bCategoryAPI\b)|(SDLFunctionTemplate)

(The SDL_Image extension also has IMG_LoadTyped_RW).

Err, instead of using xxd, you would substitute with the data stream from the RC file. I?m not sure how sane this is in practice, but just an idea in case nothing better comes along! :slight_smile:

Cheers,
Jeffrey Carpenter <@Jeffrey_Carpenter>

-------------- next part --------------
A non-text attachment was scrubbed…
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1572 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20150109/90602ec7/attachment-0001.bin