Re: 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.

Discuss this article in the forums

Date this article was posted to 7/25/1999
(Note that this date does not necessarily correspond to the date the article was written)

See Also:

© 1999-2011 All rights reserved. Terms of Use Privacy Policy
Comments? Questions? Feedback? Click here!