1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
.TH LIBCOLOUR_RGB 7 libcolour
.SH NAME
LIBCOLOUR_RGB - Generic RGB
.SH DESCRIPTION
Generic RGB colours are presented with either of
.nf
typedef struct libcolour_rgb_f libcolour_rgb_f_t;
typedef struct libcolour_rgb_lf libcolour_rgb_lf_t;
typedef struct libcolour_rgb_llf libcolour_rgb_llf_t;
.fi
These
.BR struct s
use
.BR float ,
.BR double ,
and
.BR long\ double ,
respecitively, for the values stored in them,
and are otherwise identical.
.B struct libcolour_rgb_f
is defined as
.nf
struct libcolour_rgb_f {
enum libcolour_model \fImodel\fP;
float \fIR\fP;
float \fIG\fP;
float \fIB\fP;
int \fIwith_transfer\fP;
enum libcolour_encoding_type \fIencoding_type\fP;
union {
struct {
float \fIgamma\fP;
} \fIsimple\fP;
struct {
float \fIgamma\fP;
float \fIoffset\fP;
float \fIslope\fP;
float \fItransition\fP;
float \fItransitioninv\fP;
} \fIregular\fP;
struct {
float (*\fIto_encoded_red\fP)(float);
float (*\fIto_decoded_red\fP)(float);
float (*\fIto_encoded_green\fP)(float);
float (*\fIto_decoded_green\fP)(float);
float (*\fIto_encoded_blue\fP)(float);
float (*\fIto_decoded_blue\fP)(float);
} \fIcustom\fP;
} \fItransfer\fP;
struct libcolour_ciexyy \fIred\fP;
struct libcolour_ciexyy \fIgreen\fP;
struct libcolour_ciexyy \fIblue\fP;
struct libcolour_ciexyy \fIwhite\fP;
float \fIwhite_r\fP;
float \fIwhite_g\fP;
float \fIwhite_b\fP;
float \fIM\fP[3][3];
float \fIMinv\fP[3][3];
enum libcolour_rgb_colour_space \fIcolour_space\fP;
};
.fi
.I .model
shall be set to
.BR LIBCOLOUR_RGB .
In
.BR union\ libcolour_colour_f ,
.BR union\ libcolour_colour_lf ,
and
.BR union\ libcolour_colour_llf ,
.I .rgb
is used for generic RGB colours.
.P
.IR .R ,
.IR .G ,
and
.I .B
hold the red, green, and blue values, respectively,
and shall have a value between 0 and 1, inclusively,
for the colour to be in gamut.
.I .with_transfer
shall be set to a non-zero value if the specified transfer
function (\(dqgamma function\(dq) is applied, and zero
otherwise, meaning colours are linearly encoded.
.P
.I .encoding_type
shall be set to one of the following values:
.TP
.B LIBCOLOUR_ENCODING_TYPE_LINEAR
The colour space does not have a transfer function.
.TP
.B LIBCOLOUR_ENCODING_TYPE_SIMPLE
The colour space uses a simple gamma transfer function
that only uses the
.I .transfer.simple.gamma
parameter.
.TP
.B LIBCOLOUR_ENCODING_TYPE_REGULAR
The colour space uses a linear-gamma hybrid transfer
function that uses the
.IR .transfer.simple.gamma ,
.IR .transfer.simple.offset ,
.IR .transfer.simple.slope ,
and
.I .transfer.simple.transition
parameters as well as
.IR .transfer.simple.transitioninv ,
the inverse value of the
.I .transfer.simple.transition parameter of the transfer
function, that is, where the transition takes place in
the encoded, rather than linear, values. This value is
set automatically.
.TP
.B LIBCOLOUR_ENCODING_TYPE_CUSTOM
The colour space uses a custom transfer function. When
this value is used,
.IR .transfer.custom.to_encoded_red ,
.IR .transfer.custom.to_encoded_green ,
and
.IR .transfer.custom.to_encoded_blue
shall be set to the function used to apply the red,
green, and blue channels' transfer functions to a value,
respectively, and
.IR .transfer.custom.to_decoded_red ,
.IR .transfer.custom.to_decoded_green ,
and
.IR .transfer.custom.to_decoded_blue
shall be set to the inverse of those functions.
.P
The colour space is defined by
.I .red
(the red primary),
.I .green
(the green primary),
.I .blue
(the blue primary),
.I .white
(the white point), and the RGB value of for the white
point, which is specified by
.I .white_r
(the red value for the white point),
.I .white_g
(the green value for the white point),
and
.IR .white_b
(the blue value for the white point).
.IR .white.Y ,
.IR .white_r ,
.IR .white_g ,
and
.IR .white_b
should usually be 1.
.I .M
is derived from these values, it is the matrix that is
to convert a colour from the specified RGB colour space
to CIE 1931 YXZ.
.I .Minv
is derived from
.I .M
is used to convert in the opposite direction.
.IR .colour_space ,
which is set automatically, is the colour space.
.P
.BR libcolour_get_rgb_colour_space (3)
is used to set the transfer function and colour space
parameters.
.P
The RGB colour model is an additive colour model, that is,
without a transfer function applied, linearily isomorphic
to CIE 1931 XYZ.
.P
The call
.BI libcolour_proper(& c )
on a
.B struct libcolour_rgb_t
.I c
(done automatically for predefined colour spaces) sets
.IR c.red.model ,
.IR c.green.model ,
and
.I c.blue.model
to
.BR LIBCOLOUR_CIEXYY ,
and calculate and sets the Y values for
.IR c.red ,
.IR c.green ,
and
.IR c.blue .
Zero is always normally returned, but of there is something
wrong with with the values of the primaries, −1 is returned
and
.I errno
is set to
.BR EDOM .
.SH SEE ALSO
.BR libcolour (7)
.SH AUTHORS
Mattias Andrée
.RI < m@maandree.se >
|