rgb.h 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Command & Conquer *
  23. * *
  24. * $Archive:: /G/wwlib/RGB.H $*
  25. * *
  26. * $Author:: Eric_c $*
  27. * *
  28. * $Modtime:: 4/02/99 12:00p $*
  29. * *
  30. * $Revision:: 2 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if _MSC_VER >= 1000
  36. #pragma once
  37. #endif // _MSC_VER >= 1000
  38. #ifndef RGB_H
  39. #define RGB_H
  40. class PaletteClass;
  41. class HSVClass;
  42. /*
  43. ** Each color entry is represented by this class. It holds the values for the color
  44. ** guns. The gun values are recorded in device dependant format, but the interface
  45. ** uses gun values from 0 to 255.
  46. */
  47. class RGBClass
  48. {
  49. public:
  50. RGBClass(void) : Red(0), Green(0), Blue(0) {}
  51. RGBClass(unsigned char red, unsigned char green, unsigned char blue) : Red(red), Green(green), Blue(blue) {}
  52. operator HSVClass (void) const;
  53. RGBClass & operator = (RGBClass const & rgb) {
  54. if (this == &rgb) return(*this);
  55. Red = rgb.Red;
  56. Green = rgb.Green;
  57. Blue = rgb.Blue;
  58. return(*this);
  59. }
  60. enum {
  61. MAX_VALUE=255
  62. };
  63. void Adjust(int ratio, RGBClass const & rgb);
  64. int Difference(RGBClass const & rgb) const;
  65. int Get_Red(void) const {return (Red);}
  66. int Get_Green(void) const {return(Green);}
  67. int Get_Blue(void) const {return(Blue);}
  68. void Set_Red(unsigned char value) {Red = value;}
  69. void Set_Green(unsigned char value) {Green = value;}
  70. void Set_Blue(unsigned char value) {Blue = value;}
  71. private:
  72. friend class PaletteClass;
  73. /*
  74. ** These hold the actual color gun values in machine independant scale. This
  75. ** means the values range from 0 to 255.
  76. */
  77. unsigned char Red;
  78. unsigned char Green;
  79. unsigned char Blue;
  80. };
  81. extern RGBClass const BlackColor;
  82. #endif