# Colour Problems When Using SDL_Resize()

In a 3D SDL application I inherited (I have little 3D or SDL experience), I have a 'screenshot' routine that either saves a full-size image or a scaled image, depending on the context (differing key-press). To save a full-size (i.e. graphics-mode-sized) screenshot I'm using:

SDL_SaveBMP(SDL_GetVideoSurface(), SDL_RWFromFile(filename.c_str(), "wb"), 1);


This works exactly as-intended, and saves an 8-bit bitmap (the display mode is always 8-bit, for another reason entirely) as expected.

However, in order to resize the image, I'm making use of a library that came heavily recommended in several places when searching for a suitable surface-/image-resizing library for SDL: SDL_Resize.

I'm implementing this as such:

SDL_Surface *toResize = SDL_GetVideoSurface();
SDL_Surface *resized = SDL_Resize(toResize, (int)w, (int)h);

SDL_SaveBMP(resized, SDL_RWFromFile(filename.c_str(), "wb"), 1);
SDL_FreeSurface(resized);


This works mostly as intended. It saves a resized, 8-bit bitmap, seemingly with the correct palette. However, the colours in parts of the image are incorrect, e.g.

Now, I don't need the output images to be 8-bit, I'd be perfectly happy with a 24-bit or 32-bit bitmap, if I could solve this problem; but I can't find out the answer to either of these questions:

• How do I convert an SDL surface to a different bit-depth?
• How do I ensure that the output image displays the colours correctly after resize?

I'm anticipating that I may have to settle for a higher-bit-depth bitmap, and that's fine... but a few pointers in the right direction would be fantastic.

Many thanks!