1mlib_ImageColorHSL2RGB(3MLImBe)diaLib Library Functiomnlsib_ImageColorHSL2RGB(3MLIB)
2
3
4
6 mlib_ImageColorHSL2RGB - HSL to RGB color conversion
7
9 cc [ flag... ] file... -lmlib [ library... ]
10 #include <mlib.h>
11
12 mlib_status mlib_ImageColorHSL2RGB(mlib_image *dst, const mlib_image *src);
13
14
16 The mlib_ImageColorHSL2RGB() function performs a conversion from
17 hue/saturation/lightness to red/green/blue. The source and destination
18 images must be three-channel images.
19
20
21 It uses the following equations:
22
23 L' = L if L ≤ 1/2
24 L' = 1 - L if L > 1/2
25
26 V = L + S*L'
27 P = L - S*L'
28 Q = L + S*L'*(1 - 2*fraction(H*6))
29 T = L - S*L'*(1 - 2*fraction(H*6))
30
31 R, G, B = V, T, P if 0 ≤ H < 1/6
32 R, G, B = Q, V, P if 1/6 ≤ H < 2/6
33 R, G, B = P, V, T if 2/6 ≤ H < 3/6
34 R, G, B = P, Q, V if 3/6 ≤ H < 4/6
35 R, G, B = T, P, V if 4/6 ≤ H < 5/6
36 R, G, B = V, P, Q if 5/6 ≤ H < 1
37
38
39
40 where 0 ≤ H < 1 and 0 ≤ S, L, L', V, P, Q, T, R, G, B ≤ 1.
41
42
43 Assuming a pixel in the source image is (h, s, l) and its corresponding
44 pixel in the destination image is (r, g, b), then for MLIB_BYTE images,
45 the following applies:
46
47 H = h/256
48 S = s/255
49 L = l/255
50 r = R*255
51 g = G*255
52 b = B*255
53
54
55
56 for MLIB_SHORT images, the following applies:
57
58 H = (h + 32768)/65536
59 S = (s + 32768)/65535
60 L = (l + 32768)/65535
61 r = R*65535 - 32768
62 g = G*65535 - 32768
63 b = B*65535 - 32768
64
65
66
67 for MLIB_USHORT images, the following applies:
68
69 H = h/65536
70 S = s/65535
71 L = l/65535
72 r = R*65535
73 g = G*65535
74 b = B*65535
75
76
77
78 and for MLIB_INT images, the following applies:
79
80 H = (h + 2147483648)/4294967296
81 S = (s + 2147483648)/4294967295
82 L = (l + 2147483648)/4294967295
83 r = R*4294967295 - 2147483648
84 g = G*4294967295 - 2147483648
85 b = B*4294967295 - 2147483648
86
87
89 The function takes the following arguments:
90
91 dst Pointer to destination image.
92
93
94 src Pointer to source image.
95
96
98 The function returns MLIB_SUCCESS if successful. Otherwise it returns
99 MLIB_FAILURE.
100
102 See attributes(5) for descriptions of the following attributes:
103
104
105
106
107 ┌─────────────────────────────┬─────────────────────────────┐
108 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
109 ├─────────────────────────────┼─────────────────────────────┤
110 │Interface Stability │Committed │
111 ├─────────────────────────────┼─────────────────────────────┤
112 │MT-Level │MT-Safe │
113 └─────────────────────────────┴─────────────────────────────┘
114
116 mlib_ImageColorHSL2RGB_Fp(3MLIB), mlib_ImageColorRGB2HSL(3MLIB),
117 mlib_ImageColorRGB2HSL_Fp(3MLIB), attributes(5)
118
119
120
121SunOS 5.11 12 Sep 2007 mlib_ImageColorHSL2RGB(3MLIB)