home *** CD-ROM | disk | FTP | other *** search
- /*
- digscmap.c
-
- % Function for shifting rgb levels in a cmap.
-
- 5/03/89 by Ted.
-
- OWL 1.1
- Copyright (c) 1988, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- */
-
- #include "oakhead.h"
- #include "disppriv.h"
- #include "digutil.h"
- /* -------------------------------------------------------------------------- */
-
- void DIGPRIV dig_shiftcmap(cmap, nright)
- ocolmap_type cmap;
- int nright;
- /*
- Shift all rgb levels in cmap by the given number of bits.
- */
- {
- byte *rgbarray, *p, *endp, bias;
- static byte btab[8] = {0, 1, 3, 7, 15, 31, 63, 127};
-
- rgbarray = (byte *)ocolmap_entry(cmap, cmap->firstpix);
- endp = rgbarray + cmap->nentries * 3;
-
- if (nright > 0) {
- if (nright > 7) nright = 7;
- for (p = rgbarray; p < endp; p++) *p = *p >> nright;
- }
- else {
- nright = -nright;
- if (nright > 7) nright = 7;
- bias = btab[nright];
- for (p = rgbarray; p < endp; p++) *p = (*p << nright) + bias;
- }
- }
- /* -------------------------------------------------------------------------- */
-
-