I was wondering, it is possible to load pixel data from image and make a sdl surface from it?
(result.png works fine, but SDL bmp have only w, h and black background)
ilCopyPixels(0, 0, 0,w, h,
1, IL_RGB, IL_UNSIGNED_BYTE, data);
ilSetPixels(0, 0, 0, w, h, 1, IL_RGB, IL_UNSIGNED_BYTE, data);
/* and dump them to the disc… */
Image = SDL_CreateRGBSurfaceFrom(data,
w* (ilGetInteger(IL_IMAGE_BPP) / 8),
CrapImage = SDL_DisplayFormat( Image );
if ( SDL_SaveBMP(CrapImage, "screen.bmp") < 0 )
printf("Couldn't save screen: %s\n", SDL_GetError());
Ups, forgot. Maybe there something with the data value?
int memory_needed = w * h * 3 * sizeof(unsigned char);
ILubyte * data = (ILubyte *)malloc(memory_needed);
I can't tell you much about SDL since I don't work with it.However, we have a ILUT SDL example that could interest you (it is supposed to be in the 'examples' section of the .tar.gz distribution of DevIL)
Although the DevIL stuff seems to be a little bit broken to me ATM, the SDL one is the more robust of them…
Log in to post a comment.