SDL set window icon ( ohter ways )

Feb 17, 2014 at 4:56pm
Hello everyone!

This is how i set icon right now:


1
2
3
SDL_Surface*image;
image = fp_SDL_LoadBMP_RW(fp_SDL_RWFromFile("resource/fantasyplanet.bmp", "rb"), 1);
fp_SDL_WM_SetIcon(image, 0);



Problem is that .bmp is really bad. It has bad transparency.
I've managed to create mask but transparency is still really bad.
Is there possible to do this with some ohter ways?
( Like somehow using ico or png )

Window is created inside of dll and .exe create windows console.
Thanks!
Last edited on Feb 17, 2014 at 4:57pm
Feb 17, 2014 at 5:25pm
fp_SDL_WM_SetIcon? Isn't the name SDL_WM_SetIcon? Well, at least that is what I have been using.

Anyhow...

If you use the SDL_image library you can use IMG_Load to load BMP files.



Feb 17, 2014 at 7:36pm
i use loadlibary so i need to rename functions.
Anyway. I readed somewhere that SDL_image cant be used
Source: http://sdl.beuc.net/sdl.wiki/SDL_WM_SetIcon
Feb 17, 2014 at 9:49pm
Anyway. I readed somewhere that SDL_image cant be used
I've used SDL_Image for icons plenty of times, try it anyway.

i use loadlibary so i need to rename functions.
No you don't. Just do this for the function pointer type (Assuming you're using a Windows box):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
typedef int (*PSDLINIT)(Uint32);

//...

PSDLINIT SDL_Init;

//....

// Open the library
HMODULE sdl_module = LoadLibrary("SDL.dll");
if(sdl_module == nullptr)
	// Error handling goes here

SDL_Init = (PSDLINIT)GetProcAddress("SDL_Init");
if(SDL_Init == nullptr)
	// Error handling goes here 


Last edited on Feb 17, 2014 at 10:57pm
Feb 17, 2014 at 10:52pm
Gyiove wrote:
Anyway. I readed somewhere that SDL_image cant be used
Source: http://sdl.beuc.net/sdl.wiki/SDL_WM_SetIcon

I have read that as well but never understood why you can't use SDL_image before calling SDL_SetVideoMode. Why would you even need a window at all to use SDL_image? The SDL_image docs says nothing about it. I have been using SDL_image to load the icon and it has worked without problems on Windows and Linux.
Topic archived. No new replies allowed.