[SDL+DevIL] - Pixel Data question

Started by
1 comment, last by NM_ 14 years, 4 months ago
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!
Advertisement
What's wrong? Any ideas for _this_ (exactly this) problem?

.

Hmm...perhaps it's easy to transfer data to open gl texture and then create sdl_surface from opengl one.
How can it be done with opengl? (code pls)

.

This topic is closed to new replies.

Advertisement