home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bc45 / owlsrc.pak / COLOR.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-24  |  1.4 KB  |  47 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // (C) Copyright 1992, 1994 by Borland International, All Rights Reserved
  4. //
  5. //   Implementation of color classes
  6. //----------------------------------------------------------------------------
  7. #include <owl/owlpch.h>
  8. #include <owl/color.h>
  9.  
  10. const TColor TColor::Black(0, 0, 0);         // 0
  11. const TColor TColor::LtGray(192, 192, 192);  // 7
  12. const TColor TColor::Gray(128, 128, 128);    // 8
  13. const TColor TColor::LtRed(255, 0, 0);       // 9
  14. const TColor TColor::LtGreen(0, 255, 0);     // 10
  15. const TColor TColor::LtYellow(255, 255, 0);  // 11
  16. const TColor TColor::LtBlue(0, 0, 255);      // 12
  17. const TColor TColor::LtMagenta(255, 0, 255); // 13
  18. const TColor TColor::LtCyan(0, 255, 255);    // 14
  19. const TColor TColor::White(255, 255, 255);   // 15
  20.  
  21. //
  22. // These routines converts bit count into a color count and vice versa
  23. // They also verify that the bit count is one that is supported by windows,
  24. // ie 1, 4, 8, and 24.  If the bit count is not supported, it returns -1
  25. //
  26. long _OWLFUNC
  27. NColors(uint16 bitCount)
  28. {
  29.   if (bitCount == 1 || bitCount == 4 || bitCount == 8)
  30.     return 1 << bitCount;
  31.   else if (bitCount == 24)
  32.     return 0;
  33.   return -1;
  34. }
  35.  
  36. uint16 _OWLFUNC
  37. NBits(long colors)
  38. {
  39.   if (colors <= 2)
  40.     return 1;
  41.   else if (colors <= 16)
  42.     return 4;
  43.   else if (colors <= 256)
  44.     return 8;
  45.   return 24;
  46. }
  47.