Hello!
I need some help with a program I’m writing. I’m doing a function that
it supposed to resize an image to twice the size (i.e. double the
pixels). To do this, I must first create a new surface that has twice
the width and height of the original surface. This is where my problem
starts. What I basically have is:
void CreateImageSurface(SDL_Surface *surface, int width, int height) {
Uint32 rmask, gmask, bmask, amask;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
rmask = 0xff000000;
gmask = 0x00ff0000;
bmask = 0x0000ff00;
amask = 0x000000ff;
#else
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = 0xff000000;
#endif
surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 24,
rmask, gmask, bmask, amask);
}
I then call from anywhere in my program first:
SDL_Surface *new_image;
And then:
CreateImageSurface(new_image, 640, 480);
But when I try to blit to the new created surface, nothing happens. It’s
just black. And if I use SDL_FillRect() on the new surface, the program
will exit with “segmentation fault” error and dump.
Can anyone tell me what I am doing wrong?
Best regards
// David Karlgren