home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 11.ddi / OWLSRC.PAK / COLOR.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  1.4 KB  |  46 lines

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