SDL_SetIcon transparent .png

I’m using libpng to load 32-bit PNG’s. How do I set the icon with the pixel data? I tried SDL_SetIcon but it says unknown pixel format.

Guess I could just convert to BMP and use pink for transparency. How do I set the executable file icon though? On Windows I just have to include an .ico as a resource in the executable file.

Never mind, got it

Code:
SDL_Surface* surf = SDL_CreateRGBSurfaceFrom(pixels->data, pixels->sizeX, pixels->sizeY, pixels->channels8, pixels->channelspixels->sizeX, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);

There is a .desktop spec.

On OS X the CFBundleIconFile Info.plist property pointing to the icns file that you packaged in the Resources folder
On Linux you set the Icon= property of the .desktop file to set the path to the icon file there.

To set the WINDOW icon (while the application is running) you use SDL_SetWindowIcon and specify the loaded SDL_Surface with your RGBA icon. (note, on OS X this isn’t needed, as the Info.plist icon file is used by default when running too)…

Generally I have a block of code like this.

SDL_Surface *pIcon = SDL_LoadPNG(“GameIcon.png”);
if (icon)
{
SDL_SetWindowIcon(pMyWindow, pIcon);
SDL_FreeSurface(pIcon);
}

(SDL_LoadPNG is a method I have that loads a PNG via LodePNG ( http://lodev.org/lodepng/ ) and puts the data in an SDL Surface via SDL_CreateRGBSurface )

Edward Rudd
OutOfOrder.cc
Skype: outoforder_cc
317-366-7906On May 24, 2014, at 6:26 PM, polyfrag wrote:

Guess I could just convert to BMP and use pink for transparency. How do I set the executable file icon though? On Windows I just have to include an .ico as a resource in the executable file.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org