Icon support buggy?

ok so I was playing around with icons…when I run this it cuts part of the image off, and the offset is wrong too.
then the mask is offset by even more. making the image messed up. Try it out!
I can provide a screen shot of the icon if you want it (email me, or I’ll post a url later)
the test program is attached, I suggest you have the latest SDL_image (from cvs) because it uses a new xpm function.
I know it’s not less than 50 lines, but hey, it’s got an image :wink:

OS : Linux
CPU: x86
GUI: X11–
-==-
Jon Atkins
http://jonatkins.org/
-------------- next part --------------
A non-text attachment was scrubbed…
Name: sdlbug.c
Type: application/octet-stream
Size: 2216 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20010918/01c50e40/attachment-0007.obj

here it is, without mime encoding!

/* gcc sdl-config --cflags -o sdlbug sdlbug.c sdl-config --libs -lSDL_image */
#include “SDL.h”
#include “SDL_image.h”

static char * icon_xpm[] = {
“32 32 9 1”,
" c None",
". c #FF0000",
"+ c #FFFF00",
"@ c #00FF00",
"# c #00FFFF",
"$ c #0000FF",
"% c #FF00FF",
"& c #000000",
"* c #FFFFFF",
".+@#$%. .%$#@+.",
"++@#$%. .%$#@++",
"@@@#$%. .%$#@@@",
"####$%. .%$####",
"$$$$$%. .%$$$$$",
"%%%%%%. .%%%%%%",
"… …",
" “,
” “,
” “,
” “,
” &&&&&&&&& &&& “,
” && && “,
” &&&&
&&&&&&&&& &&&&&&&
&& “,
” &
& &&
&&&&&&& “,
” &
& &
&&&
&&
&&&
&&
&& “,
” && &&&&&&&&&&&&& “,
” &
& &&&&&&&& “,
” &
& &&&&&&&&&&&&&& “,
” &
& &&&&&&&&&&&&& “,
” &
& &&
*&&&&*&&&& “,
” &&& &&&&& &&&&& &&&& “,
” “,
” “,
” “,
”… …",
"%%%%%%. .%%%%%%",
"$$$$$%. .%$$$$$",
"####$%. .%$####",
"@@@#$%. .%$#@@@",
"++@#$%. .%$#@++",
".+@#$%. .%$#@+."};

int main(int argc, char **argv)
{
int x,y,i;
Uint8 rgb,a,*mask;
SDL_Surface *icon;
SDL_Event e;

if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_JOYSTICK)!=0)
	return(1);
if(!(icon=IMG_ReadXPMFromArray(icon_xpm)))
	{ SDL_Quit(); return(2); }
mask=(Uint8*)malloc((icon->w*icon->h)/8);
memset(mask,0,(icon->w*icon->h)/8);
for(i=0,y=0;y<icon->h;y++)
	for(x=0;x<icon->w;x++,i++)
	{
		mask[i/8]<<=1;
		if(icon_xpm[y+10][x]!=' ')
			mask[i/8]|=1;
	}
SDL_WM_SetIcon(icon,mask);
SDL_WM_SetCaption("Iconify Me!","Buggin!");
if(!(SDL_SetVideoMode(320,200,0,SDL_ANYFORMAT)))
	{ SDL_Quit(); return(3); }
while(SDL_WaitEvent(&e))
	if(e.type==SDL_QUIT)
		break;
SDL_Quit(); // memory would normally be freed but who cares for this test
return(0);

}–
-==-
Jon Atkins
http://jonatkins.org/