Topic : How do I use 16-bpp surfaces?
Author : Nick Caldwell
Page : 1

How do I use 16-bpp surfaces?

Posted by Nick Caldwell on January 15, 1998 at 10:18:54:

In Reply to: How do I use 16-bpp surfaces? posted by Fredrik Andersson on January 14, 1998 at 13:53:09:

You are reading the pointer incorrectly. You should cast the surface pointer to a WORD instead of an unsigned char. Something like:

WORD *surface = (WORD *)SurfaceDesc.SurfacePtr

Also, you can't use the RGB macro outside of GDI. Here is an RGB macro that I use for 16bpp:

#define RGB2(r,g,b) ((WORD)  ((BYTE) (r) << __SHIFT | (BYTE) (G) << 5 | (BYTE) (B)))

__SHIFT is 10 or 11 depending on your video card. Read the DDraw help topic on pixel bitmasks for more info. The major difference between 16bpp and 24bpp is that in 16 your RGB values can be a max of RGB(31,31,31), in 24bpp they can be RGB(255,255,255). Obviously, this is because 24bpp uses more memory. Again, read the DDraw pixel bitmask topic, it explains this fully.

Page : 1