A video card either represents RGB by 565 bit or 555 bits.( Although there might be other).
So when u start, u need to extract information using GetSurfaceDesc to get the pixel format. Then u create a macro that shifts into bits correctly and use the macro instead of RGB(r,g,b).
There are articles on that problem either here or at www.perplexed.com/GPMega. I know, cause I got my solutions there.