home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 8
/
CDASC08.ISO
/
VRAC
/
CUJ0993.ZIP
/
1109048A
< prev
next >
Wrap
Text File
|
1993-05-03
|
1KB
|
55 lines
Listing 5 Manipulating the DIB Color Table
void BuildMapping (struct BitMapRec FAR *dispRec)
{
int e,i;
DWORD colorRef;
for (i = 0; i < 256; i++)
{
if (options & PAL_MAPDIRECT)
{
e = i;
if (options & PAL_LOWERCONTRAST)
{
if (i < 32) e = i * 3;
else if (i >= 224) e = (i * 3) - 512;
else e = ((i - 32) / 3) + 96;
}
else if (options & PAL_HIGHERCONTRAST)
{
if (i < 96) e = i / 3;
else if (i >= 160)
e = ((i - 160) / 3) + 224;
else e = ((i - 96) * 3) + 32;
}
if (options & PAL_DARKER)
{
e = e / 2;
}
else if (options & PAL_LIGHTER)
{
e = (e / 2) + 128;
}
e = e & 0x00FF; /* "safety"... */
}
else {
colorRef = (DWORD)i +
((DWORD)i << 8L) +
((DWORD)i << 16L);
e = GetNearestPaletteIndex(newPalette,
colorRef);
}
/*--------------------------------------------*/
if (options & PAL_IMAGEINVERT)
dispRec->bmi.bmiColors[i] = e;
else dispRec->bmi.bmiColors[255-i] = e;
} /* end for i */
} /* BuildMapping */