[SDL+DevIL] - Pixel Data question
Hi everyone!
Ok, my goal is to create sdl surface and save it by using devil...
So here is the code:
Code:
____________________________________________________________
int memory_needed = w * h * 3 * sizeof(unsigned char);
ILubyte * data = (ILubyte *)malloc(memory_needed);
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... */
ilSaveImage("result.png");
Image = SDL_CreateRGBSurfaceFrom(data, w, h , ilGetInteger(IL_IMAGE_BPP),w* (ilGetInteger(IL_IMAGE_BPP) / 8),0x000000FF,0x0000FF00, 0x00FF0000, 0);
CrapImage = SDL_DisplayFormat( Image );
if ( SDL_SaveBMP(CrapImage, "screen.bmp") < 0 )
printf("Couldn't save screen: %s\n", SDL_GetError());
____________________________________________________________
ilSaveImage does good job while SDL_SaveBMP gets only w and h value(SDL_DisplayFormat) and creates bmp with black background...
How to get that pixel data and fill it into surface?
Thanks for the attention!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement