home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_11_09 / 1109048a < prev    next >
Text File  |  1993-05-03  |  1KB  |  55 lines

  1. Listing 5  Manipulating the DIB Color Table
  2.  
  3.  
  4. void BuildMapping (struct BitMapRec FAR *dispRec)
  5. {
  6.  int e,i;
  7.  DWORD colorRef;
  8.  
  9.  for (i = 0; i < 256; i++)
  10.    {
  11.     if (options & PAL_MAPDIRECT)
  12.     {
  13.      e = i;
  14.  
  15.      if (options & PAL_LOWERCONTRAST)
  16.      {
  17.       if (i < 32) e = i * 3;
  18.         else if (i >= 224) e = (i * 3) - 512;
  19.                else e = ((i - 32) / 3) + 96;
  20.      }
  21.      else if (options & PAL_HIGHERCONTRAST)
  22.           {
  23.            if (i < 96) e = i / 3;
  24.              else if (i >= 160)
  25.                     e = ((i - 160) / 3) + 224;
  26.                   else e = ((i - 96) * 3) + 32;
  27.           }
  28.  
  29.      if (options & PAL_DARKER)
  30.      {
  31.       e = e / 2;
  32.      }
  33.      else if (options & PAL_LIGHTER)
  34.           {
  35.            e = (e / 2) + 128;
  36.           }
  37.  
  38.      e = e & 0x00FF;  /* "safety"... */
  39.     }
  40.     else {
  41.           colorRef = (DWORD)i +
  42.                      ((DWORD)i << 8L) +
  43.                      ((DWORD)i << 16L);
  44.           e = GetNearestPaletteIndex(newPalette,
  45.                                      colorRef);
  46.          }
  47.  
  48.     /*--------------------------------------------*/
  49.  
  50.     if (options & PAL_IMAGEINVERT)
  51.       dispRec->bmi.bmiColors[i] = e;
  52.     else dispRec->bmi.bmiColors[255-i] = e;
  53.    } /* end for i */
  54. } /* BuildMapping */
  55.