aboutsummaryrefslogblamecommitdiffstats
path: root/LIBCOLOUR_RGB.7
blob: eb26b4aa2b5144fcb972c495ad15e3f1b33b7200 (plain) (tree)
1
2
3
4
5
6
7
8
9
10






                                                


                                                             














                                             





































                                                                       










































































































































                                                             
.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 < maandree@kth.se >