Changeset View
Changeset View
Standalone View
Standalone View
libs/pigment/KoColor.h
Show All 38 Lines | |||||
39 | /** | 39 | /** | ||
40 | * A KoColor describes a color in a certain colorspace. The color is stored in a buffer | 40 | * A KoColor describes a color in a certain colorspace. The color is stored in a buffer | ||
41 | * that can be manipulated by the function of the color space. | 41 | * that can be manipulated by the function of the color space. | ||
42 | */ | 42 | */ | ||
43 | class KRITAPIGMENT_EXPORT KoColor : public boost::equality_comparable<KoColor> | 43 | class KRITAPIGMENT_EXPORT KoColor : public boost::equality_comparable<KoColor> | ||
44 | { | 44 | { | ||
45 | 45 | | |||
46 | public: | 46 | public: | ||
47 | static void init(); | | |||
48 | | ||||
49 | /// Create an empty KoColor. It will be valid, but also black and transparent | 47 | /// Create an empty KoColor. It will be valid, but also black and transparent | ||
50 | KoColor() { | 48 | KoColor(); | ||
51 | const KoColor * const prefab = s_prefab; | | |||
52 | | ||||
53 | // assert that KoColor::init was called and everything is set up properly. | | |||
54 | KIS_ASSERT_X(prefab != nullptr, "KoColor::KoColor()", "KoColor not initialized yet."); | | |||
55 | | ||||
56 | *this = *prefab; | | |||
57 | } | | |||
58 | 49 | | |||
59 | /// Create a null KoColor. It will be valid, but all channels will be set to 0 | 50 | /// Create a null KoColor. It will be valid, but all channels will be set to 0 | ||
60 | explicit KoColor(const KoColorSpace * colorSpace); | 51 | explicit KoColor(const KoColorSpace * colorSpace); | ||
61 | /// Create a KoColor from a QColor. The QColor is immediately converted to native. The QColor | 52 | /// Create a KoColor from a QColor. The QColor is immediately converted to native. The QColor | ||
62 | /// is assumed to have the current monitor profile. | 53 | /// is assumed to have the current monitor profile. | ||
63 | KoColor(const QColor & color, const KoColorSpace * colorSpace); | 54 | KoColor(const QColor & color, const KoColorSpace * colorSpace); | ||
64 | 55 | | |||
65 | /// Create a KoColor using a native color strategy. The data is copied. | 56 | /// Create a KoColor using a native color strategy. The data is copied. | ||
▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Line(s) | |||||
180 | /** | 171 | /** | ||
181 | * Unserialize a color following Create's swatch color specification available | 172 | * Unserialize a color following Create's swatch color specification available | ||
182 | * at http://create.freedesktop.org/wiki/index.php/Swatches_-_colour_file_format | 173 | * at http://create.freedesktop.org/wiki/index.php/Swatches_-_colour_file_format | ||
183 | * | 174 | * | ||
184 | * @param elt the element to unserialize (<CMYK />, <sRGB />, <RGB />) | 175 | * @param elt the element to unserialize (<CMYK />, <sRGB />, <RGB />) | ||
185 | * @param bitDepthId the bit depth is unspecified by the spec, this allow to select | 176 | * @param bitDepthId the bit depth is unspecified by the spec, this allow to select | ||
186 | * a preferred bit depth for creating the KoColor object (if that | 177 | * a preferred bit depth for creating the KoColor object (if that | ||
187 | * bit depth isn't available, this function will randomly select | 178 | * bit depth isn't available, this function will randomly select | ||
188 | * an other bit depth) | 179 | * an other bit depth) | ||
rempt: Please don't rename d to m_d -- we're actually trying to standardize on plain 'd' instead of… | |||||
189 | * @return the unserialize color, or an empty color object if the function failed | 180 | * @return the unserialize color, or an empty color object if the function failed | ||
190 | * to unserialize the color | 181 | * to unserialize the color | ||
191 | */ | 182 | */ | ||
192 | static KoColor fromXML(const QDomElement& elt, const QString & bitDepthId); | 183 | static KoColor fromXML(const QDomElement& elt, const QString & bitDepthId); | ||
193 | 184 | | |||
194 | /** | 185 | /** | ||
195 | * Unserialize a color following Create's swatch color specification available | 186 | * Unserialize a color following Create's swatch color specification available | ||
196 | * at http://create.freedesktop.org/wiki/index.php/Swatches_-_colour_file_format | 187 | * at http://create.freedesktop.org/wiki/index.php/Swatches_-_colour_file_format | ||
Show All 28 Lines | 215 | if (m_colorSpace) { | |||
225 | Q_ASSERT(*m_colorSpace == *KoColorSpaceRegistry::instance()->permanentColorspace(m_colorSpace)); | 216 | Q_ASSERT(*m_colorSpace == *KoColorSpaceRegistry::instance()->permanentColorspace(m_colorSpace)); | ||
226 | } | 217 | } | ||
227 | #endif | 218 | #endif | ||
228 | } | 219 | } | ||
229 | 220 | | |||
230 | const KoColorSpace *m_colorSpace; | 221 | const KoColorSpace *m_colorSpace; | ||
231 | quint8 m_data[MAX_PIXEL_SIZE]; | 222 | quint8 m_data[MAX_PIXEL_SIZE]; | ||
232 | quint8 m_size; | 223 | quint8 m_size; | ||
233 | | ||||
234 | static const KoColor *s_prefab; | | |||
235 | }; | 224 | }; | ||
236 | 225 | | |||
237 | Q_DECLARE_METATYPE(KoColor) | 226 | Q_DECLARE_METATYPE(KoColor) | ||
238 | 227 | | |||
239 | #endif | 228 | #endif |
Please don't rename d to m_d -- we're actually trying to standardize on plain 'd' instead of 'm_d' which we used to use in Krita only.