So I’m working on an image resampler. Right now, I’m trying to get nearest
neighbor resampling to work. The result is almost successful, except the
red and the blue channels of the final image are swapped.
Right now, I have no idea why. Can someone please explain why the channels
are being flipped?
char input[] = “image_000000.jpg”;
int new_width = 1024;
int new_height = 768;
char output[] = “resized.bmp”;
It doesn’t look like you’re considering the possible format differences.
You could try making the new surface use the same format with something
like:
SDL_Surface* output_image = SDL_CreateRGBSurface(0, new_width, new_height,
input_image->format->BitsPerPixel, input_image->format->Rmask,
input_image->format->Gmask, input_image->format->Bmask,
input_image->format->Amask);
Untested, so double-check me.
Jonny DOn Fri, Sep 3, 2010 at 8:12 PM, Ian Mallett wrote:
Hi,
So I’m working on an image resampler. Right now, I’m trying to get nearest
neighbor resampling to work. The result is almost successful, except the
red and the blue channels of the final image are swapped.
Right now, I have no idea why. Can someone please explain why the channels
are being flipped?
char input[] = “image_000000.jpg”;
int new_width = 1024;
int new_height = 768;
char output[] = “resized.bmp”;
The default red, green, and blue masks are 0x0000FF00, 0x00FF0000, and
0xFF000000, respectively. Which is weird. Why is the default this way, and
not masks that would correspond to RGB?
The RGB masks correspond to the endian order of your computer, IIRC.On Sat, Sep 4, 2010 at 11:50 AM, Ian Mallett wrote:
Hi,
Hmmm, that seems to fix it.
The default red, green, and blue masks are 0x0000FF00, 0x00FF0000, and
0xFF000000, respectively. Which is weird. Why is the default this way, and
not masks that would correspond to RGB?