home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / CSAPE32.ARJ / SOURCE / OWLSCR / DIGSCMAP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-03-29  |  1.0 KB  |  46 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-DIG 1.2
  9.     Copyright (c) 1988, by Oakland Group, Inc.
  10.     ALL RIGHTS RESERVED.
  11.  
  12.     Revision History:
  13.     -----------------
  14.      3/28/90 jmd    ansi-fied
  15. */
  16.  
  17. #include "oakhead.h"
  18. #include "disppriv.h"
  19. #include "digutil.h"
  20. /* -------------------------------------------------------------------------- */
  21.  
  22. void DIGPRIV dig_shiftcmap(ocolmap_type cmap, int nright)
  23. /*
  24.     Shift all rgb levels in cmap by the given number of bits.
  25. */
  26. {
  27.     byte *rgbarray, *p, *endp, bias;
  28.     static byte btab[8] = {0, 1, 3, 7, 15, 31, 63, 127};
  29.  
  30.     rgbarray = (byte *)ocolmap_entry(cmap, cmap->firstpix);
  31.     endp = rgbarray + cmap->nentries * 3;
  32.  
  33.     if (nright > 0) {
  34.         if (nright > 7) nright = 7;
  35.         for (p = rgbarray; p < endp; p++) *p = *p >> nright;
  36.     }
  37.     else {
  38.         nright = -nright;
  39.         if (nright > 7) nright = 7;
  40.         bias = btab[nright];
  41.         for (p = rgbarray; p < endp; p++) *p = (*p << nright) + bias;
  42.     }
  43. }
  44. /* -------------------------------------------------------------------------- */
  45.  
  46.