ObjFW
OFColorSpace.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2026 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License version 3.0 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13  * version 3.0 for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * version 3.0 along with this program. If not, see
17  * <https://www.gnu.org/licenses/>.
18  */
19 
20 #import "OFObject.h"
21 
22 OF_ASSUME_NONNULL_BEGIN
23 
26 @class OFColorSpace;
27 @class OFMatrix4x4;
28 
42 typedef void (*OFColorSpaceTransferFunction)(OFVector4D *vectors,
43  size_t count);
44 
51 {
52  OFColorSpaceTransferFunction _EOTF, _OETF;
53  OFMatrix4x4 *_RGBToXYZMatrix, *_XYZToRGBMatrix;
54  bool _linear;
55  OF_RESERVE_IVARS(OFColorSpace, 4)
56 }
57 
58 #ifdef OF_HAVE_CLASS_PROPERTIES
59 @property (class, readonly, retain, nonatomic) OFColorSpace *sRGBColorSpace;
60 @property (class, readonly, retain, nonatomic)
61  OFColorSpace *linearSRGBColorSpace;
62 @property (class, readonly, retain, nonatomic) OFColorSpace *BT709ColorSpace;
63 @property (class, readonly, retain, nonatomic)
64  OFColorSpace *displayP3ColorSpace;
65 @property (class, readonly, retain, nonatomic)
66  OFColorSpace *linearDisplayP3ColorSpace;
67 @property (class, readonly, retain, nonatomic) OFColorSpace *BT2020ColorSpace;
68 @property (class, readonly, retain, nonatomic)
69  OFColorSpace *linearBT2020ColorSpace;
70 @property (class, readonly, retain, nonatomic) OFColorSpace *adobeRGBColorSpace;
71 @property (class, readonly, retain, nonatomic)
72  OFColorSpace *linearAdobeRGBColorSpace;
73 #endif
74 
80 @property (readonly, nonatomic) OFColorSpaceTransferFunction EOTF;
81 
87 @property (readonly, nonatomic) OFColorSpaceTransferFunction OETF;
88 
92 @property (readonly, retain, nonatomic) OFMatrix4x4 *RGBToXYZMatrix;
93 
97 @property (readonly, retain, nonatomic) OFMatrix4x4 *XYZToRGBMatrix;
98 
102 @property (readonly, nonatomic, getter=isLinear) bool linear;
103 
114 + (instancetype)colorSpaceWithEOTF: (OFColorSpaceTransferFunction)EOTF
115  OETF: (OFColorSpaceTransferFunction)OETF
116  RGBToXYZMatrix: (OFMatrix4x4 *)RGBToXYZMatrix
117  XYZToRGBMatrix: (OFMatrix4x4 *)XYZToRGBMatrix
118  linear: (bool)linear;
119 
123 + (OFColorSpace *)sRGBColorSpace;
124 
128 + (OFColorSpace *)linearSRGBColorSpace;
129 
136 + (OFColorSpace *)BT709ColorSpace;
137 
141 + (OFColorSpace *)displayP3ColorSpace;
142 
146 + (OFColorSpace *)linearDisplayP3ColorSpace;
147 
151 + (OFColorSpace *)BT2020ColorSpace;
152 
157 + (OFColorSpace *)linearBT2020ColorSpace;
158 
162 + (OFColorSpace *)adobeRGBColorSpace;
163 
167 + (OFColorSpace *)linearAdobeRGBColorSpace;
168 
179 - (instancetype)initWithEOTF: (OFColorSpaceTransferFunction)EOTF
180  OETF: (OFColorSpaceTransferFunction)OETF
181  RGBToXYZMatrix: (OFMatrix4x4 *)RGBToXYZMatrix
182  XYZToRGBMatrix: (OFMatrix4x4 *)XYZToRGBMatrix
183  linear: (bool)linear;
184 @end
185 
186 OF_ASSUME_NONNULL_END
The root class for all other classes inside ObjFW.
Definition: OFObject.h:954
A 4x4 matrix of floats.
Definition: OFMatrix4x4.h:28
A class representing a color space.
Definition: OFColorSpace.h:50
void(* OFColorSpaceTransferFunction)(OFVector4D *vectors, size_t count)
A transfer function for a color space.
Definition: OFColorSpace.h:42
A vector in 4D space.
Definition: OFObject.h:551