PALETTEC.H 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // Copyright 2020 Electronic Arts Inc.
  3. //
  4. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
  5. // software: you can redistribute it and/or modify it under the terms of
  6. // the GNU General Public License as published by the Free Software Foundation,
  7. // either version 3 of the License, or (at your option) any later version.
  8. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /* $Header: /CounterStrike/PALETTE.H 2 9/23/97 11:00p Steve_t $ */
  15. /***********************************************************************************************
  16. *** 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 ***
  17. ***********************************************************************************************
  18. * *
  19. * Project Name : Command & Conquer *
  20. * *
  21. * File Name : PALETTE.H *
  22. * *
  23. * Programmer : Joe L. Bostic *
  24. * *
  25. * Start Date : 12/02/95 *
  26. * *
  27. * Last Update : December 2, 1995 [JLB] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Functions: *
  31. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  32. #ifndef PALETTE_Hx
  33. #define PALETTE_Hx
  34. #include "rgb.h"
  35. /*
  36. ** The palette class is used to manipulate a palette as a whole. All 256 colors are
  37. ** represented by the palette class object.
  38. */
  39. class PaletteClass
  40. {
  41. public:
  42. enum {
  43. COLOR_COUNT=256 // Number of color indices on the palette.
  44. };
  45. PaletteClass(void) {};
  46. PaletteClass(RGBClass const & rgb);
  47. RGBClass & operator[] (unsigned index) {return(Palette[index % COLOR_COUNT]);};
  48. const RGBClass & operator[] (unsigned index) const {return(Palette[index % COLOR_COUNT]);};
  49. int operator == (PaletteClass const & palette) const;
  50. int operator != (PaletteClass const & palette) const {return(!(operator ==(palette)));};
  51. PaletteClass & operator = (PaletteClass const & palette);
  52. // Removed these and replaced with function for clarity. ST - 5/9/2019
  53. //operator const unsigned char * (void) const {return((const unsigned char *)&Palette[0]);};
  54. //operator unsigned char * (void) {return((unsigned char *)&Palette[0]);};
  55. const void *Get_Data(void) const { return &Palette[0]; }
  56. void *Get_Data(void) { return &Palette[0]; }
  57. void Adjust(int ratio);
  58. void Adjust(int ratio, PaletteClass const & palette);
  59. void Partial_Adjust(int ratio, char *lut);
  60. void Partial_Adjust(int ratio, PaletteClass const & palette, char *lut);
  61. void Set(int time = 0, void (*callback)(void) = 0) const;
  62. int Closest_Color(RGBClass const & rgb) const;
  63. static PaletteClass const & CurrentPalette;
  64. protected:
  65. RGBClass Palette[COLOR_COUNT];
  66. };
  67. #endif