Advertisement

16bit mode

Started by August 01, 2000 06:55 AM
5 comments, last by krompo 24 years, 4 months ago
I would like to know, how exactly is 16bit mode structured when I want to write directly to the Surface in directdraw (using Lock/Unlock). I know it is 565, but rgb or bgr? I would try it but at the moment, I don''t have computer with VC++ at my disposal. thank you. krompo
krompo
quote: Original post by krompo

I would like to know, how exactly is 16bit mode structured
when I want to write directly to the Surface in directdraw
(using Lock/Unlock). I know it is 565, but rgb or bgr?
I would try it but at the moment, I don''t have computer
with VC++ at my disposal.

thank you.

krompo




Hi,

it is not as easy as you describe. Since it is a while ago that i did that i can only remeber that you must query DX how the combination of rgb of your graphic adapter is. The you can use these values to shift your pixel values to the correct places.
But there is no fix format like 565 or 665 or whatever. That depends on Grafx card.

cu

Peter

PS:

I have a printed document abaout that. If i can remember the URl i''ll post it here.
HPH
Advertisement
As far as I know there is 5-5-5 and 5-6-5 in the order r-g-b and b-g-r. That makes a total of 4 different colormodes.
You can query these with the GetPixelFormat method. Check the masks for the values to see in which colormode you''re in.

Sludge Software
www.sludgesoft.com
Developing a secret of mana style role-playing-game
Sludge Softwarewww.sludgesoft.comDeveloping a secret of mana style role-playing-game
As far as I know, most cards uses RGB order.
It''s easier and compatible with GDI.

(from Windows SDK, GDI)

Windows 95/98:
... the system supports only the following 16bpp color masks: A 5-5-5 16-bit image, where the blue mask is 0x001F, the green mask is 0x03E0, and the red mask is 0x7C00; and a 5-6-5 16-bit image, where the blue mask is 0x001F, the green mask is 0x07E0, and the red mask is 0xF800.

...the system supports only the following 32-bpp color mask: The blue mask is 0x000000FF, the green mask is 0x0000FF00, and the red mask is 0x00FF0000.
It may be a good idea to download sci-tech display doctor.
With this tool you can set these things (555/565, rgb/bgr) yourself. Which can be really good for debugging purposes.

Sludge Software
www.sludgesoft.com
Developing a secret of mana style role-playing-game
Sludge Softwarewww.sludgesoft.comDeveloping a secret of mana style role-playing-game
Just a note; the function you want is IDIRECTDRAWSURFACE::GetPixelFormat(). Just pass a pointer to a DDPIXELFORMAT structure, and look at the dwRGBBitCount member after the call. In a 16-bit screen mode it''ll either be 15 for 5.5.5 or 16 for 5.6.5.


-Ironblayde
Aeon Software
"Your superior intellect is no match for our puny weapons!"
Advertisement
Hey. I have the code to do exactly what you need to do:

                // get the pixel format	DDPIXELFORMAT pixelFormat;	pixelFormat.dwSize = sizeof(DDPIXELFORMAT);	primaryBuffer->GetPixelFormat(&pixelFormat);	// get the bit shifts for each color in a pixel	// get red mask        // redMask, greenMask and blueMask are unsigned longs.        // rShift, gShift, and bShift are bytes	redMask = pixelFormat.dwRBitMask;	while(!(redMask & 0x01))	{		redMask >>= 1;		rShift++;	}	// get green mask	greenMask = pixelFormat.dwGBitMask;	while(!(greenMask & 0x01))	{		greenMask >>= 1;		gShift++;	}	// get blue mask	blueMask = pixelFormat.dwBBitMask;	while(!(blueMask & 0x01))	{		blueMask >>= 1;		bShift++;	}	// now that we have the shifts, reassign the original bitmasks	redMask = pixelFormat.dwRBitMask;	greenMask = pixelFormat.dwGBitMask;	blueMask = pixelFormat.dwBBitMask;	// test for 555 or 565 mode	switch(rShift)	{	case 10:		{			gScale = 8;			DebugOut("-InitDirectDraw: gScale set for 555 mode\n");		} break;	case 11:		{			gScale = 4;			DebugOut("-InitDirectDraw: gScale set for 565 mode\n");		} break;	default:		{			char buffer[70];			wsprintf(buffer,"-InitDirectDraw: Error setting gScale: rShift = %d",rShift);			DebugOut(buffer);		} break;	} // end switch(rShift)      // here's my inline func for building an RGB value// the ">>3"s are dividing by 8, so that values from 0..255// can be passed in instead of just from 0..32 or 0..64inline unsigned short RGBValue(unsigned int r, unsigned int g, unsigned int b){	return (((r >> 3) << rShift) | ((g / gScale) << gShift) | ((b >> 3) << bShift));}// and, in case you need it, extracting the RGB valuesinline void ExtractRGB(unsigned short builtColor, unsigned char* r,								unsigned char* g, unsigned char* b){	*r = (builtColor & redMask) >> rShift;	*g = (builtColor & greenMask) >> gShift;	*b = (builtColor & blueMask) >> bShift;}        


Edited by - IdEstVita on August 2, 2000 3:19:01 AM

This topic is closed to new replies.

Advertisement