DX7 Color Keying

Started by
11 comments, last by guitarman 23 years, 2 months ago
Try this:

    typedef unsigned short ushort;#pragma pack(push)#pragma pack(1)struct Color555 {    ushort red : 5;    ushort green : 5;    ushort blue : 5;};struct Color565 {    ushort red : 5;    ushort green : 6;    ushort blue : 5;};#pragma pack(pop)void convert(Color555 &from, Color565 &to){    to.red = from.red;    to.green = from.green;    to.blue = from.blue;}  


BTW: I assumed your pixelformat was RGB. If its BGR you need to reverse red and blue.

You can also use bitshifts. Perhaps someone else will explain them to you, my fingers hurt.




ALL YOUR BASE ARE BELONG TO US




Edited by - Countach on February 19, 2001 9:37:15 AM
-------homepage - email
Advertisement
whooshhh....right over my head. I''ve been C++ coding for a few years, but I''m still not too familiar with #pragmas...thanks. any other takers?

#define Jesus 1
[source]#define Jesus 1[/source]
The code I gave you converts to 565.
if (Is565())	{	color = ((GetBValue(color)>>3)|				((GetGValue(color)>>2)<<5)|				((GetRValue(color)>>3)<<11));	} 


It uses the previously defined function (see above code) to test if the graphics card is 565 format (most are), and if it is, converts the color appropriately.


"We are the music makers, and we are the dreamers of the dreams."
- Willy Wonka

This topic is closed to new replies.

Advertisement