home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c185 / 2.ddi / OWLSRC.EXE / CSCAPE / SOURCE / DIGSCMAP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-06  |  1.0 KB  |  47 lines

  1. /*
  2.     digscmap.c
  3.  
  4.     % Function for shifting rgb levels in a cmap.
  5.  
  6.     5/03/89  by Ted.
  7.  
  8.     OWL 1.1
  9.     Copyright (c) 1988, by Oakland Group, Inc.
  10.     ALL RIGHTS RESERVED.
  11.  
  12.     Revision History:
  13.     -----------------
  14. */
  15.  
  16. #include "oakhead.h"
  17. #include "disppriv.h"
  18. #include "digutil.h"
  19. /* -------------------------------------------------------------------------- */
  20.  
  21. void DIGPRIV dig_shiftcmap(cmap, nright)
  22.     ocolmap_type cmap;
  23.     int nright;
  24. /*
  25.     Shift all rgb levels in cmap by the given number of bits.
  26. */
  27. {
  28.     byte *rgbarray, *p, *endp, bias;
  29.     static byte btab[8] = {0, 1, 3, 7, 15, 31, 63, 127};
  30.  
  31.     rgbarray = (byte *)ocolmap_entry(cmap, cmap->firstpix);
  32.     endp = rgbarray + cmap->nentries * 3;
  33.  
  34.     if (nright > 0) {
  35.         if (nright > 7) nright = 7;
  36.         for (p = rgbarray; p < endp; p++) *p = *p >> nright;
  37.     }
  38.     else {
  39.         nright = -nright;
  40.         if (nright > 7) nright = 7;
  41.         bias = btab[nright];
  42.         for (p = rgbarray; p < endp; p++) *p = (*p << nright) + bias;
  43.     }
  44. }
  45. /* -------------------------------------------------------------------------- */
  46.  
  47.