World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
Файл PaletteManager.h

См. исходные тексты.

Классы

struct  PaletteManager
 

Функции

bool HSV2RGB (float *a1, float *a2, float *a3, float a4, float a5, float a6)
 
void RGB2HSV (float *a1, float *a2, float a3, float a4, float a5, float *a6)
 
signed int ReplaceHSV (unsigned int uColor, float a2, float gamma, float a4)
 

Переменные

PaletteManagerpPaletteManager
 

Функции

◆ HSV2RGB()

bool HSV2RGB ( float *  a1,
float *  a2,
float *  a3,
float  a4,
float  a5,
float  a6 
)

См. определение в файле PaletteManager.cpp строка 23

23  {
24  // r,g,b outputs 0-1
25 
26  if (hin > 360 || sin > 1 || vin > 1) __debugbreak();
27 
28  if (sin == 0.0) {
29  if (vin > 1) vin = 1;
30  if (vin < 0) vin = 0;
31  *blueo = vin;
32  *greeno = vin;
33  *redo = vin;
34  return 1;
35  }
36 
37  if (hin == 360.0) hin = 0.0;
38 
39  double hh = hin / 60; // to sixth segments
40  unsigned int segment = (unsigned int)hh;
41  double fractionrem = hh - segment;
42  double p = (1.0 - sin) * vin;
43  double q = (1.0 - fractionrem * sin) * vin;
44  double t = (1.0 - (1.0 - fractionrem) * sin) * vin;
45 
46  switch (segment) {
47  case 0:
48  *redo = vin;
49  *greeno = t;
50  *blueo = p;
51  break;
52  case 1:
53  *redo = q;
54  *greeno = vin;
55  *blueo = p;
56  break;
57  case 2:
58  *redo = p;
59  *greeno = vin;
60  *blueo = t;
61  break;
62 
63  case 3:
64  *redo = p;
65  *greeno = q;
66  *blueo = vin;
67  break;
68  case 4:
69  *redo = t;
70  *greeno = p;
71  *blueo = vin;
72  break;
73  case 5:
74  default:
75  *redo = vin;
76  *greeno = p;
77  *blueo = q;
78  break;
79  }
80 
81  return 1;
82 }

Перекрестные ссылки __debugbreak().

Используется в PaletteManager::CalcPalettes_LUT(), PaletteManager::LoadPalette() и ReplaceHSV().

+ Граф вызовов:
+ Граф вызова функции:

◆ RGB2HSV()

void RGB2HSV ( float *  a1,
float *  a2,
float  a3,
float  a4,
float  a5,
float *  a6 
)

См. определение в файле PaletteManager.cpp строка 85

85  {
86  // RGB inputs 0-1
87  if (redin > 1 || greenin > 1 || bluein > 1) __debugbreak();
88 
89  double max;
90  double min;
91  double outhcalc;
92  float delta;
93 
94  if (redin <= (double)greenin)
95  max = greenin;
96  else
97  max = redin;
98 
99  if (max < bluein) max = bluein;
100  // max is value of dominant hue
101 
102  if (redin <= (double)greenin)
103  min = redin;
104  else
105  min = greenin;
106 
107  if (min > bluein) min = bluein;
108  // min is value of least hue
109 
110  *outv = max;
111  delta = max - min;
112 
113  if (max == 0.0) { // r=g=b=0
114  *outs = 0.0;
115  *outh = 0.0;
116  return;
117  } else {
118  *outs = delta / max;
119  }
120 
121  if (redin == max) {
122  outhcalc = (greenin - bluein) / delta; // yellow and mag
123  } else {
124  if (greenin == max)
125  outhcalc = (bluein - redin) / delta + 2.0; // cyan and yellow
126  else
127  outhcalc = (redin - greenin) / delta + 4.0; // mag and cyan
128  }
129 
130  *outh = outhcalc * 60.0; // to degree
131  if (*outh < 0) {
132  *outh += 360.0;
133  }
134 }

Перекрестные ссылки __debugbreak().

Используется в PaletteManager::CalcPalettes_LUT(), PaletteManager::LoadPalette() и ReplaceHSV().

+ Граф вызовов:
+ Граф вызова функции:

◆ ReplaceHSV()

signed int ReplaceHSV ( unsigned int  uColor,
float  a2,
float  gamma,
float  a4 
)

См. определение в файле PaletteManager.cpp строка 843

843  {
844  float r = ((uColor & 0x00FF0000) >> 16) / 255.0f,
845  g = ((uColor & 0x0000FF00) >> 8) / 255.0f,
846  b = (uColor & 0x000000FF) / 255.0f;
847 
848  float h, s, v;
849  RGB2HSV(&h, &s, r, g, b, &v);
850 
851  if (h_replace != -1.0) h = h_replace;
852  if (s_replace != -1.0) s = s_replace;
853  if (v_replace != -1.0) v = v_replace;
854  HSV2RGB(&r, &g, &b, h, s, v);
855 
856  return (((uint)round_to_int(r * 255.0f) & 0xFF) << 16) |
857  (((uint)round_to_int(g * 255.0f) & 0xFF) << 8) |
858  (((uint)round_to_int(b * 255.0f) & 0xFF));
859 }

Перекрестные ссылки HSV2RGB(), RGB2HSV() и round_to_int().

Используется в Engine::AlterGamma_BLV() и Engine::AlterGamma_ODM().

+ Граф вызовов:
+ Граф вызова функции:

Переменные

◆ pPaletteManager

s
GLdouble s
Definition: SDL_opengl.h:2063
v
const GLdouble * v
Definition: SDL_opengl.h:2064
round_to_int
int round_to_int(float x)
Definition: OurMath.h:18
q
GLdouble GLdouble GLdouble GLdouble q
Definition: SDL_opengl.h:2087
h
GLfloat GLfloat GLfloat GLfloat h
Definition: SDL_opengl_glext.h:1949
RGB2HSV
void RGB2HSV(float *outh, float *outs, float redin, float greenin, float bluein, float *outv)
Definition: PaletteManager.cpp:85
HSV2RGB
bool HSV2RGB(float *redo, float *greeno, float *blueo, float hin, float sin, float vin)
Definition: PaletteManager.cpp:23
p
GLfloat GLfloat p
Definition: SDL_opengl_glext.h:11093
f
GLfloat f
Definition: SDL_opengl_glext.h:1873
t
GLdouble GLdouble t
Definition: SDL_opengl.h:2071
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1112
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
uint
unsigned int uint
Definition: MM7.h:4
__debugbreak
void __cdecl __debugbreak(void)
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1112