14 HEXRAYS_LODWORD(
v1) = HEXRAYS_HIDWORD(
v1) +
v1;
15 HEXRAYS_HIDWORD(
v1) *= 2;
23 bool HSV2RGB(
float *redo,
float *greeno,
float *blueo,
float hin,
float sin,
float vin) {
37 if (hin == 360.0) hin = 0.0;
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;
85 void RGB2HSV(
float *outh,
float *outs,
float redin,
float greenin,
float bluein,
float *outv) {
87 if (redin > 1 || greenin > 1 || bluein > 1)
__debugbreak();
94 if (redin <= (
double)greenin)
99 if (max < bluein) max = bluein;
102 if (redin <= (
double)greenin)
107 if (min > bluein) min = bluein;
122 outhcalc = (greenin - bluein) / delta;
125 outhcalc = (bluein - redin) / delta + 2.0;
127 outhcalc = (redin - greenin) / delta + 4.0;
130 *outh = outhcalc * 60.0;
276 for (
uint i = 0; i < 256; ++i)
308 for (
uint i = 0; i < 256; ++i)
331 for (
uint i = 0; i < 32; ++i) {
336 for (
uint j = 0; j < 256; ++j) {
337 v21 = a6[j] * (1.0f - i / 32.0f);
338 if (v21 < 0.0) v21 = 0.0;
341 HSV2RGB(&a1, &a2a, &a3, v64[j], v63[j], v21);
342 v23 =
v2->uNumTargetGBits;
347 }
else if (v23 == 5) {
351 }
else if (v23 == 0) {
362 (
unsigned __int32)a3 |
363 ((
unsigned __int32)a2a <<
v2->uNumTargetBBits) |
364 ((
unsigned __int32)a1
365 << (
v2->uNumTargetBBits +
v2->uNumTargetGBits));
379 for (
uint i = 0; i < 32; ++i) {
383 for (
uint j = 0; j < 256; ++j) {
384 v26 = a6[j] * (1.0 - i / 31.0f);
385 if (v26 < 0.0) v26 = 0.0;
388 HSV2RGB(&a1, &a2a, &a3, 1.0, 1.0, v26);
389 v28 =
v2->uNumTargetGBits;
394 }
else if (v28 == 5) {
398 }
else if (v23 == 0) {
415 (
unsigned __int64)(
signed __int64)a3 |
416 ((
unsigned __int16)(
signed __int64)a2a <<
v2->uNumTargetBBits) |
417 (
unsigned __int16)((
unsigned __int16)(
signed __int64)a1
418 << (
v2->uNumTargetBBits + v28));
428 for (
uint i = 0; i < 256; ++i) {
431 v32 = (a6[i] - 0.8f) * 0.8387096774193549 + 0.8;
432 if (v32 < 0.0) v32 = 0.0;
436 HSV2RGB(&a1, &a2a, &a3, v64[i], v63[i] * 0.7034339229968783, v32);
437 v35 =
v2->uNumTargetGBits;
442 }
else if (v35 == 5) {
446 }
else if (v23 == 0) {
453 v36 = (
signed __int64)((a1 + a2a + a3) * 0.3333333333333333 * 8.0);
454 v37 = (
signed int)v36 >> (8 -
v2->uNumTargetRBits);
456 v39 =
v2->uNumTargetBBits;
457 v40 = (
signed int)v36 >> v38;
458 v41 =
v2->uNumTargetRBits;
459 v79 = (
signed int)v36 >> (8 - v39);
460 if (v37 > (1 << v41) - 1) v37 = (1 << v41) - 1;
461 v42 =
v2->uNumTargetGBits;
462 if (v40 > (1 << v42) - 1) v40 = (1 << v42) - 1;
463 if (v79 > (1 << v39) - 1) v79 = (1 << v39) - 1;
465 v44 = v37 << (v39 +
v2->uNumTargetGBits);
469 v79 | ((
unsigned short)v40 << v39) | (
unsigned __int16)v44;
478 float mist_a, mist_b, mist_c;
492 RGB2HSV(&v68, &v67, mist_a, mist_b, mist_c, &unused);
498 for (
uint i = 0; i < 32; ++i) {
501 for (
uint j = 0; j < 256; ++j) {
503 if (v49 < 0.0) v49 = 0.0;
506 HSV2RGB(&a1, &a2a, &a3, v64[j], v49, a6[j]);
508 if (
v2->uNumTargetGBits == 6) {
512 }
else if (
v2->uNumTargetGBits == 5) {
516 }
else if (v23 == 0) {
525 v55 = (double)i / 31.0
f;
526 v52 = (
signed __int64)((
double)(1 <<
v2->uNumTargetRBits) *
529 v53 = (
signed __int64)((
double)(1 <<
v2->uNumTargetGBits) *
532 v54 = (
signed __int64)((
double)(1 <<
v2->uNumTargetBBits) *
536 v52 = (
signed __int64)a1;
537 v53 = (
signed __int64)a2a;
538 v54 = (
signed __int64)a3;
541 v56 =
v2->uNumTargetRBits;
543 if (v52 > (1 << v56) - 1) v52 = (1 << v56) - 1;
544 v57 =
v2->uNumTargetGBits;
545 if (v53 > (1 << v57) - 1) v53 = (1 << v57) - 1;
546 HEXRAYS_HIDWORD(v54) =
v2->uNumTargetBBits;
547 v59 =
v2->uNumTargetBBits;
548 if ((
signed int)v54 > (1 << v59) - 1) v81 = (1 << v59) - 1;
549 v60 =
v2->uNumTargetGBits;
570 : uNumTargetRBits(0),
574 for (
uint i = 0; i < 256; ++i) {
598 v3 = (int)&
v1->pBaseColors[0][0][1];
600 *(
char *)(
v3 + 1) =
v2;
602 *(
char *)(
v3 - 1) =
v2++;
611 memset(v5, 0,
sizeof(
int) * v6);
629 v3 = (int)&
v1->pBaseColors[0][0][1];
631 *(
char *)(
v3 + 1) =
v2;
633 *(
char *)(
v3 - 1) =
v2++;
642 memset(v5, 0,
sizeof(
int) * v6);
657 char colourstore[768];
673 while (*
v2 != uPaletteID) {
677 sprintf(Source,
"pal%03i", uPaletteID);
685 v17 = 1 - (int)&colourstore;
697 if (v5 >= 0.0 && v5 >= 1.0) {
700 if (v5 < 0.0) v5 = 0.0;
703 v6 = v18 * 0.64999998;
704 if (v6 >= 0.0 && v6 >= 1.0) {
707 if (v6 < 0.0) v6 = 0.0;
713 colourstore[
index] = (
signed __int64)(red * 255.0);
714 colourstore[
index + 1] = (
signed __int64)(
green * 255.0);
715 colourstore[
index + 2] = (
signed __int64)(
blue * 255.0);
717 }
while (
index < 768);
746 for (
uint i = 0; i < 50; ++i)
754 if (v7 >= 50)
return 0;
767 for (
uint i = 0; i < 768; ++i)
dst[i] = entries[i];
787 for (
uint i = 1; i < 50; ++i)
801 v3 = 32 * a1 + a2 + 3275;
803 v3 = 32 * a1 + a2 + 1675;
813 v3 = 32 * a1 + a2 + 3275;
815 v3 = 32 * a1 + a2 + 75;
828 return (
unsigned __int16 *)
result;
843 int ReplaceHSV(
unsigned int uColor,
float h_replace,
float s_replace,
float v_replace) {
844 float r = ((uColor & 0x00FF0000) >> 16) / 255.0f,
845 g = ((uColor & 0x0000FF00) >> 8) / 255.0f,
846 b = (uColor & 0x000000FF) / 255.0
f;
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;