Pixels?

under a 16bpp mode, do the pixels not follow RGB?

im using the following code (ripped from a tool of mine to output
16bpp (5/6/5) data for my DGA and GTK projects…and in SDL the reds
become blue, green becomes red, and blue becomes green…

    val = fgetc(inFile);
    val >>= 3;
    outVal = (unsigned short)val;
    outVal <<= 11;

    val = fgetc(inFile);
    val >>= 2;
    tempVal = (unsigned short)(val <<= 5);
    outVal |= val;

    val = fgetc(inFile);
    val >>= 3;
    outVal |= val;

odd

and the red becoming blue is a tad off, probably accounted for by the
6… :smiley:

am i missing something fundamental here? it’s pretty late so i just
might be, maybe ill go look through some demos, probably shoulda done
that before, oh well…ill post this anyways :smiley:

j

Jeff <@Jeff> writes:

under a 16bpp mode, do the pixels not follow RGB?

im using the following code (ripped from a tool of mine to output
16bpp (5/6/5) data for my DGA and GTK projects…and in SDL the reds
become blue, green becomes red, and blue becomes green…

    val = fgetc(inFile);
    val >>= 3;
    outVal = (unsigned short)val;
    outVal <<= 11;

    val = fgetc(inFile);
    val >>= 2;
    tempVal = (unsigned short)(val <<= 5);
    outVal |= val;

    val = fgetc(inFile);
    val >>= 3;
    outVal |= val;

odd

and the red becoming blue is a tad off, probably accounted for by the
6… :smiley:

am i missing something fundamental here? it’s pretty late so i just
might be, maybe ill go look through some demos, probably shoulda done
that before, oh well…ill post this anyways :smiley:

btw the data being converted from is R/G/B 24 bit

failed to mention that :slight_smile:

j

im using the following code (ripped from a tool of mine to output
16bpp (5/6/5) data for my DGA and GTK projects…and in SDL the reds
become blue, green becomes red, and blue becomes green…

Have you checked the screen pixel format?

i.e. for red…

SDL_PixelFormat *format = screen->format;

outVal |= (val>>format->Rloss)<<format->Rshift;

Never hard-code the loss and shift values…

You might use the SDL_MapRGB() function, which will give the proper value
even on 8-bit displays (it may be dithered however). If you want speed, and
know for sure that you will be writing to a packed pixel surface, then the
above formula is probably best.

See ya!
-Sam Lantinga (slouken at devolution.com)–
Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/