BYTE SwapROP3_SrcDst(BYTE bRop3) { /* swap 1,2 bit and 5,6 bit */ BYTE bit1 = (bRop3 & 0x04) ? 0x02 : 0; BYTE bit2 = (bRop3 & 0x02) ? 0x04 : 0; BYTE bit5 = (bRop3 & 0x40) ? 0x20 : 0; BYTE bit6 = (bRop3 & 0x20) ? 0x40 : 0; return (bRop3 & 0x99) | bit1 | bit2 | bit5 | bit6; }
How 'bout
BYTE SwapROP3_SrcDst(BYTE bRop3) { /* swap 1,2 bit and 5,6 bit */ BYTE bits44 = (bRop3 & 0x44) >> 1; BYTE bits22 = (bRop3 & 0x22) << 1; return (bRop3 & 0x99) | bits22 | bits44; }
On April 9, 2003 01:22 am, Dan Kegel wrote:
How 'bout
BYTE SwapROP3_SrcDst(BYTE bRop3) { /* swap 1,2 bit and 5,6 bit */ BYTE bits44 = (bRop3 & 0x44) >> 1; BYTE bits22 = (bRop3 & 0x22) << 1; return (bRop3 & 0x99) | bits22 | bits44; }
Nice! At which point we might as well inline it all:
inline BYTE SwapROP3_SrcDst(BYTE bRop3) { return (bRop3 & 0x99) | ((bRop3 & 0x22) << 1) | ((bRop3 & 0x44) >> 1); }
:)