home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / CSAPE32.ARJ / SOURCE / OWLSCR / DIGPOW2.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-11-01  |  1.1 KB  |  47 lines

  1. /*
  2.     digpow2.c
  3.  
  4.     % Function for getting power of 2 of a number of bits.
  5.  
  6.     5/05/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.      4/14/90 jmd    added olimits.h
  16.     10/31/90 ted    made dig_powof2 return unsigned long instead of long.
  17. */
  18.  
  19. #include "oakhead.h"
  20. #include "disppriv.h"
  21. #include "digutil.h"
  22. #include "olimits.h"
  23.  
  24. /* -------------------------------------------------------------------------- */
  25.  
  26. unsigned long DIGPRIV dig_powof2(byte power)
  27. /*
  28.     Return the power of 2 for selected powers expected to be found as the
  29.     number of color bits in display hardware.
  30. */
  31. {
  32.     switch (power) {
  33.     default:return(1L);
  34.     case 1:  return(2L);
  35.     case 2:  return(4L);
  36.     case 4:  return(16L);
  37.     case 8:  return(256L);
  38.     case 16: return(256L * 256L);
  39.     case 18: return(512L * 512L);
  40.     case 20: return(1024L * 1024L * 16L);
  41.     case 24: return(1024L * 1024L * 16L);
  42.     case 32: return(ULONG_MAX);
  43.     }
  44. }
  45. /* -------------------------------------------------------------------------- */
  46.  
  47.