76fbfc6f7a1c11e933c85e4d051ac3ac3ee3ba85
1 #ifndef COLOR_TOOL_GPU_H
2 #define COLOR_TOOL_GPU_H
4 #include "both_define.h"
5 #include "builtin_types.h" // pour float3
15 /*--------------------------------------*\
17 \*-------------------------------------*/
19 /*--------------------------------------*\
21 \*-------------------------------------*/
26 * Convertir une couleur HSB en RGB !
31 static void HSB_TO_RVB(const float3
& hsb01
, uchar4
* ptrRVBA
)
33 ColorTools::HSB_TO_RVB(hsb01
.x
, hsb01
.y
, hsb01
.z
, &ptrRVBA
->x
, &ptrRVBA
->y
, &ptrRVBA
->z
);
37 * Convertir une couleur HSB en RGB !
42 static void HSB_TO_RVB(float h01
, uchar4
* ptrRVBA
)
44 ColorTools::HSB_TO_RVB(h01
, 1.0f
, 1.0f
, &ptrRVBA
->x
, &ptrRVBA
->y
, &ptrRVBA
->z
);
48 * Convertir une couleur HSB en RGB !
53 static void HSB_TO_RVB(float h01
, float s01
, float b01
, uchar4
* ptrRVBA
)
55 ColorTools::HSB_TO_RVB(h01
, s01
, b01
, &ptrRVBA
->x
, &ptrRVBA
->y
, &ptrRVBA
->z
);
59 * Convertir une couleur HSB en RGB !
64 static void HSB_TO_RVB(float H
, float S
, float V
, unsigned char *ptrR
, unsigned char *ptrG
, unsigned char *ptrB
)
66 //float H = profondeur / 255.0;
69 if (S
== 0) //HSV from 0 to 1
83 unsigned char var_i
= (unsigned char) var_h
; //Or ... var_i = floor( var_h )
85 float var_1
= V
* (1 - S
);
86 float var_2
= V
* (1 - S
* (var_h
- var_i
));
87 float var_3
= V
* (1 - S
* (1 - (var_h
- var_i
)));
89 float var_r
, var_g
, var_b
;
127 //RGB results from 0 to 255
128 *ptrR
= (unsigned char) (var_r
* 255);
129 *ptrG
= (unsigned char) (var_g
* 255);
130 *ptrB
= (unsigned char) (var_b
* 255);
134 /*--------------------------------------*\
136 \*-------------------------------------*/
142 /*----------------------------------------------------------------------*\
144 \*---------------------------------------------------------------------*/