|
Krita Source Code Documentation
|
#include <KoColor.h>
Inheritance diagram for KoColor:Public Member Functions | |
| void | add (const KoColor &value) |
| KoColor | added (const KoColor &value) const |
| void | addMetadata (QString key, QVariant value) |
| void | clearMetadata () |
| clearMetadata clear th metadata map inside the KoColor. | |
| const KoColorSpace * | colorSpace () const |
| return the current colorSpace | |
| KoColor | convertedTo (const KoColorSpace *cs) const |
| KoColor | convertedTo (const KoColorSpace *cs, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) const |
| void | convertTo (const KoColorSpace *cs) |
| void | convertTo (const KoColorSpace *cs, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) |
| quint8 * | data () |
| const quint8 * | data () const |
| void | dump () const |
| use qDebug calls to print internal info | |
| void | fromKoColor (const KoColor &src) |
| void | fromQColor (const QColor &c) |
| Convenient function for converting from a QColor. | |
| KoColor () | |
| Create an empty KoColor. It will be valid, but also black and transparent. | |
| KoColor (const KoColor &rhs) | |
| Copy constructor – deep copies the colors. | |
| KoColor (const KoColor &src, const KoColorSpace *colorSpace) | |
| Create a KoColor by converting src into another colorspace. | |
| KoColor (const KoColorSpace *colorSpace) | |
| Create a null KoColor. It will be valid, but all channels will be set to 0. | |
| KoColor (const QColor &color, const KoColorSpace *colorSpace) | |
| KoColor (const quint8 *data, const KoColorSpace *colorSpace) | |
| Create a KoColor using a native color strategy. The data is copied. | |
| QMap< QString, QVariant > | metadata () const |
| qreal | opacityF () const |
| quint8 | opacityU8 () const |
| KoColor & | operator= (const KoColor &rhs) |
| bool | operator== (const KoColor &other) const |
| const KoColorProfile * | profile () const |
| return the current profile | |
| void | setColor (const quint8 *data, const KoColorSpace *colorSpace=0) |
| void | setOpacity (qreal alpha) |
| void | setOpacity (quint8 alpha) |
| void | setProfile (const KoColorProfile *profile) |
| assign new profile without converting pixel data | |
| void | subtract (const KoColor &value) |
| KoColor | subtracted (const KoColor &value) const |
| QColor | toQColor () const |
| a convenience method for the above. | |
| void | toQColor (QColor *c) const |
| a convenience method for the above. | |
| QString | toSVG11 (QHash< QString, const KoColorProfile * > *profileList) const |
| toSVG11 | |
| QString | toXML () const |
| toXML creates a string with XML that represents the current color. The XML is extended with a "channeldepth" attribute so we can restore the color to the same channel depth. | |
| void | toXML (QDomDocument &doc, QDomElement &colorElt) const |
Static Public Member Functions | |
| static KoColor | createTransparent (const KoColorSpace *cs) |
| static KoColor | fromSVG11 (const QString value, QHash< QString, const KoColorProfile * > profileList, KoColor current=KoColor()) |
| fromSVG11 Parses a color attribute value and returns a KoColor. SVG defines the colorprofiles elsewhere in the file, so this function expects you to first figure out the profiles and which colorspaces these match to, and it will then use those colorspaces to generate the kocolor. If it cannot find the appropriate colorspace, it will return the color fallback. If that doesn't work, an empty KoColor. This function ignores url() values. Colors will be F32 unless they are lab and cmyk, in which case they'll be U16. | |
| static KoColor | fromXML (const QDomElement &elt, const QString &channelDepthId) |
| static KoColor | fromXML (const QDomElement &elt, const QString &channelDepthId, bool *ok) |
| static KoColor | fromXML (const QString &xml) |
| fromXML restores a KoColor from a string saved with toXML(). If the string does not contain the "channeldepth" attribute, 16 bit integer is assumed. | |
| static QString | toQString (const KoColor &color) |
| toQString create a user-visible string of the channel names and the channel values | |
Private Member Functions | |
| void | assertPermanentColorspace () |
Private Attributes | |
| const KoColorSpace * | m_colorSpace |
| quint8 | m_data [MAX_PIXEL_SIZE] |
| QMap< QString, QVariant > | m_metadata |
| quint8 | m_size |
A KoColor describes a color in a certain colorspace. The color is stored in a buffer that can be manipulated by the function of the color space.
| KoColor::KoColor | ( | ) |
Create an empty KoColor. It will be valid, but also black and transparent.
Definition at line 75 of file KoColor.cpp.
|
explicit |
Create a null KoColor. It will be valid, but all channels will be set to 0.
Definition at line 82 of file KoColor.cpp.
References colorSpace(), KoColorSpaceRegistry::instance(), m_colorSpace, m_data, m_size, MAX_PIXEL_SIZE, KoColorSpaceRegistry::permanentColorspace(), and KoColorSpace::pixelSize().
| KoColor::KoColor | ( | const QColor & | color, |
| const KoColorSpace * | colorSpace ) |
Create a KoColor from a QColor. The QColor is immediately converted to native. The QColor is assumed to have the current monitor profile.
Definition at line 91 of file KoColor.cpp.
References colorSpace(), KoColorSpace::fromQColor(), KoColorSpaceRegistry::instance(), m_colorSpace, m_data, m_size, MAX_PIXEL_SIZE, KoColorSpaceRegistry::permanentColorspace(), and KoColorSpace::pixelSize().
| KoColor::KoColor | ( | const quint8 * | data, |
| const KoColorSpace * | colorSpace ) |
Create a KoColor using a native color strategy. The data is copied.
Definition at line 104 of file KoColor.cpp.
References colorSpace(), data(), KoColorSpaceRegistry::instance(), m_colorSpace, m_data, m_size, MAX_PIXEL_SIZE, KoColorSpaceRegistry::permanentColorspace(), and KoColorSpace::pixelSize().
| KoColor::KoColor | ( | const KoColor & | src, |
| const KoColorSpace * | colorSpace ) |
Create a KoColor by converting src into another colorspace.
Definition at line 115 of file KoColor.cpp.
References colorSpace(), KoColorSpaceRegistry::instance(), KoColorConversionTransformation::internalConversionFlags(), KoColorConversionTransformation::internalRenderingIntent(), m_colorSpace, m_data, m_size, MAX_PIXEL_SIZE, KoColorSpaceRegistry::permanentColorspace(), and KoColorSpace::pixelSize().
|
inline |
Channelwise adds value to *this and stores the result in *this
Throws a safe assert if the colorspaces of the two colors are different
Definition at line 244 of file KoColor.cpp.
References KoColorSpace::channelCount(), KoColorSpace::fromNormalisedChannelsValue(), KIS_SAFE_ASSERT_RECOVER_RETURN, m_colorSpace, m_data, KoColorSpace::normalisedChannelsValue(), and value().
Channelwise adds value to a copy of *this and returns the result
Throws a safe assert if the colorspaces of the two colors are different
Definition at line 261 of file KoColor.cpp.
| void KoColor::addMetadata | ( | QString | key, |
| QVariant | value ) |
store the given key, value pair in a KoColor.
Definition at line 666 of file KoColor.cpp.
References m_metadata, and value().
|
inlineprivate |
Definition at line 312 of file KoColor.h.
References KoColorSpaceRegistry::instance().
| void KoColor::clearMetadata | ( | ) |
clearMetadata clear th metadata map inside the KoColor.
Definition at line 676 of file KoColor.cpp.
References m_metadata.
|
inline |
return the current colorSpace
| KoColor KoColor::convertedTo | ( | const KoColorSpace * | cs | ) | const |
Copies this color and converts it to the specified colorspace. If the specified colorspace is the same as the original colorspace, just returns a copy
Definition at line 170 of file KoColor.cpp.
References convertedTo(), KoColorConversionTransformation::internalConversionFlags(), and KoColorConversionTransformation::internalRenderingIntent().
| KoColor KoColor::convertedTo | ( | const KoColorSpace * | cs, |
| KoColorConversionTransformation::Intent | renderingIntent, | ||
| KoColorConversionTransformation::ConversionFlags | conversionFlags ) const |
Copies this color and converts it to the specified colorspace. If the specified colorspace is the same as the original colorspace, just returns a copy
Definition at line 163 of file KoColor.cpp.
References convertTo().
| void KoColor::convertTo | ( | const KoColorSpace * | cs | ) |
Definition at line 156 of file KoColor.cpp.
References convertTo(), KoColorConversionTransformation::internalConversionFlags(), and KoColorConversionTransformation::internalRenderingIntent().
| void KoColor::convertTo | ( | const KoColorSpace * | cs, |
| KoColorConversionTransformation::Intent | renderingIntent, | ||
| KoColorConversionTransformation::ConversionFlags | conversionFlags ) |
Convert this KoColor to the specified colorspace. If the specified colorspace is the same as the original colorspace, do nothing
Definition at line 136 of file KoColor.cpp.
References KoColorSpace::convertPixelsTo(), data(), KoColorSpaceRegistry::instance(), m_colorSpace, m_data, m_size, MAX_PIXEL_SIZE, KoColorSpaceRegistry::permanentColorspace(), and KoColorSpace::pixelSize().
|
static |
Not all color spaces support creation of a color from QColor, so we should create the default backdrop color explicitly.
Definition at line 681 of file KoColor.cpp.
References KoColorSpaceRegistry::instance(), m_colorSpace, m_data, m_size, KoColorSpaceRegistry::permanentColorspace(), KoColorSpace::pixelSize(), and KoColorSpace::transparentColor().
|
inline |
|
inline |
| void KoColor::dump | ( | ) | const |
use qDebug calls to print internal info
Definition at line 269 of file KoColor.cpp.
References KoColorSpace::channels, dbgPigment, KoColorSpace::id, m_colorSpace, m_data, KoChannelInfo::name(), KoChannelInfo::pos(), and KoChannelInfo::size().
Convert the color from src and replace the value of the current color with the converted data. Don't convert the color if src and this have the same colorspace.
Definition at line 294 of file KoColor.cpp.
References colorSpace(), KoColorConversionTransformation::internalConversionFlags(), KoColorConversionTransformation::internalRenderingIntent(), and m_data.
| void KoColor::fromQColor | ( | const QColor & | c | ) |
Convenient function for converting from a QColor.
Definition at line 213 of file KoColor.cpp.
References KoColorSpace::fromQColor(), m_colorSpace, and m_data.
|
static |
fromSVG11 Parses a color attribute value and returns a KoColor. SVG defines the colorprofiles elsewhere in the file, so this function expects you to first figure out the profiles and which colorspaces these match to, and it will then use those colorspaces to generate the kocolor. If it cannot find the appropriate colorspace, it will return the color fallback. If that doesn't work, an empty KoColor. This function ignores url() values. Colors will be F32 unless they are lab and cmyk, in which case they'll be U16.
https://www.w3.org/TR/SVG11/types.html#DataTypeColor for hex, rgb() and colornames https://www.w3.org/TR/SVG11/types.html#DataTypeICCColor for icc-color() https://www.w3.org/TR/SVG11/painting.html#SpecifyingPaint
| value | the content of the svg color value |
| profileList | list of KoColorProfiles that were found inside the svg file, with the reference names. |
| current | the current color. |
Definition at line 534 of file KoColor.cpp.
References KoColorSpace::alphaPos(), KoColorSpace::channelCount(), KoColorSpace::channels, CMYKAColorModelID, KoColorProfile::colorModelID(), colorSpace(), KoColorSpaceRegistry::colorSpace(), data(), dbgPigment, KoChannelInfo::displayPositionToChannelIndex(), KoColorSpace::fromNormalisedChannelsValue(), fromQColor(), fromXML(), KoID::id(), KoColorSpaceRegistry::instance(), KoColor(), LABAColorModelID, length(), KoColorProfile::name, profile(), setOpacity(), value(), and XYZAColorModelID.
|
static |
Unserialize a color following Create's swatch color specification available at https://web.archive.org/web/20110826002520/http://create.freedesktop.org/wiki/Swatches_-_color_file_format/Draft
| elt | the element to unserialize (<CMYK />, <sRGB />, <RGB />) |
| channelDepthId | the bit depth is unspecified by the spec, this allow to select a preferred bit depth for creating the KoColor object (if that bit depth isn't available, this function will randomly select another bit depth) |
Definition at line 350 of file KoColor.cpp.
References fromXML().
|
static |
Unserialize a color following Create's swatch color specification available at https://web.archive.org/web/20110826002520/http://create.freedesktop.org/wiki/Swatches_-_color_file_format/Draft
| elt | the element to unserialize (<CMYK />, <sRGB />, <RGB />) |
| channelDepthId | the bit depth is unspecified by the spec, this allow to select a preferred bit depth for creating the KoColor object (if that bit depth isn't available, this function will randomly select another bit depth) |
| ok | If a an error occurs, *ok is set to false; otherwise it's set to true |
Definition at line 356 of file KoColor.cpp.
References addMetadata(), KoColorSpaceRegistry::AllColorSpaces, CMYKAColorModelID, KoColorSpaceRegistry::colorDepthList(), KoColorSpace::colorFromXML(), KoColorSpaceRegistry::colorSpace(), data(), GrayAColorModelID, KoID::id(), KoColorSpaceRegistry::instance(), KoColor(), LABAColorModelID, KoColorProfile::name, KoColorSpaceRegistry::p709SRGBProfile(), profile(), KoColorSpaceRegistry::profileByName(), RGBAColorModelID, KisDomUtils::toDouble(), KisDomUtils::toInt(), KisDomUtils::toString(), v, value(), XYZAColorModelID, and YCbCrAColorModelID.
|
static |
fromXML restores a KoColor from a string saved with toXML(). If the string does not contain the "channeldepth" attribute, 16 bit integer is assumed.
| xml | a valid XML document |
Definition at line 446 of file KoColor.cpp.
References fromXML(), KoID::id(), and Integer16BitsColorDepthID.
| QMap< QString, QVariant > KoColor::metadata | ( | ) | const |
Get a map with all the metadata The metadata is used by parsing functions to store extra data, like for example spot color names, or the original parsing model.
Definition at line 671 of file KoColor.cpp.
References m_metadata.
| qreal KoColor::opacityF | ( | ) | const |
Definition at line 345 of file KoColor.cpp.
References m_colorSpace, m_data, and KoColorSpace::opacityF().
| quint8 KoColor::opacityU8 | ( | ) | const |
Convenient function that return the opacity of the color
Definition at line 341 of file KoColor.cpp.
References m_colorSpace, m_data, and KoColorSpace::opacityU8().
assignment operator to copy the data from the param color into this one.
| rhs | the color we are going to copy |
Definition at line 64 of file KoColor.h.
References m_colorSpace, m_data, m_metadata, and m_size.
| bool KoColor::operator== | ( | const KoColor & | other | ) | const |
Definition at line 126 of file KoColor.cpp.
References colorSpace(), m_data, and m_size.
| const KoColorProfile * KoColor::profile | ( | ) | const |
return the current profile
Definition at line 299 of file KoColor.cpp.
References m_colorSpace, and KoColorSpace::profile().
| void KoColor::setColor | ( | const quint8 * | data, |
| const KoColorSpace * | colorSpace = 0 ) |
Replace the existing color data, and colorspace with the specified data. The data is copied.
Definition at line 186 of file KoColor.cpp.
References colorSpace(), data(), KoColorSpaceRegistry::instance(), m_colorSpace, m_data, m_size, MAX_PIXEL_SIZE, KoColorSpaceRegistry::permanentColorspace(), and KoColorSpace::pixelSize().
| void KoColor::setOpacity | ( | qreal | alpha | ) |
Definition at line 337 of file KoColor.cpp.
References m_colorSpace, m_data, and KoColorSpace::setOpacity().
| void KoColor::setOpacity | ( | quint8 | alpha | ) |
Convenient function to set the opacity of the color.
Definition at line 333 of file KoColor.cpp.
References m_colorSpace, m_data, and KoColorSpace::setOpacity().
| void KoColor::setProfile | ( | const KoColorProfile * | profile | ) |
assign new profile without converting pixel data
Definition at line 177 of file KoColor.cpp.
References colorSpace(), KoColorSpaceRegistry::colorSpace(), KoColorSpaceRegistry::instance(), m_colorSpace, KoColorSpaceRegistry::permanentColorspace(), and profile().
Channelwise subtracts value from *this and stores the result in *this
Throws a safe assert if the colorspaces of the two colors are different
Definition at line 220 of file KoColor.cpp.
References KoColorSpace::channelCount(), KoColorSpace::fromNormalisedChannelsValue(), KIS_SAFE_ASSERT_RECOVER_RETURN, m_colorSpace, m_data, KoColorSpace::normalisedChannelsValue(), and value().
Channelwise subtracts value from a copy of *this and returns the result
Throws a safe assert if the colorspaces of the two colors are different
Definition at line 237 of file KoColor.cpp.
References subtract(), and value().
| QColor KoColor::toQColor | ( | ) | const |
a convenience method for the above.
Definition at line 206 of file KoColor.cpp.
References toQColor().
| void KoColor::toQColor | ( | QColor * | c | ) | const |
a convenience method for the above.
Definition at line 198 of file KoColor.cpp.
References m_colorSpace, m_data, and KoColorSpace::toQColor().
|
static |
toQString create a user-visible string of the channel names and the channel values
| color | the color to create the string from |
Definition at line 655 of file KoColor.cpp.
References KoColorSpace::channels, KoColorSpace::channelValueText(), colorSpace(), data(), KoChannelInfo::displayOrderSorted(), KoChannelInfo::displayPosition(), KoChannelInfo::displayPositionToChannelIndex(), and KoChannelInfo::name().
| QString KoColor::toSVG11 | ( | QHash< QString, const KoColorProfile * > * | profileList | ) | const |
toSVG11
| profileList | list of profiles, this will map the profile to a name, so it may be embedded. |
Definition at line 470 of file KoColor.cpp.
References colorSpace(), data(), KoChannelInfo::displayPositionToChannelIndex(), Integer8BitsColorDepthID, LABAColorModelID, KoColorProfile::name, KoColorSpace::normalisedChannelsValue(), PRIMARIES_ITU_R_BT_709_5, profile(), KoColorSpace::profile(), toQColor(), toXML(), TRC_LINEAR, and XYZAColorModelID.
| QString KoColor::toXML | ( | ) | const |
toXML creates a string with XML that represents the current color. The XML is extended with a "channeldepth" attribute so we can restore the color to the same channel depth.
Definition at line 436 of file KoColor.cpp.
References colorSpace(), and toXML().
| void KoColor::toXML | ( | QDomDocument & | doc, |
| QDomElement & | colorElt ) const |
Serialize this color following Create's swatch color specification available at https://web.archive.org/web/20110826002520/http://create.freedesktop.org/wiki/Swatches_-_color_file_format/Draft
This function doesn't create the <color /> element but rather the <CMYK />, <sRGB />, <RGB /> ... elements. It is assumed that colorElt is the <color /> element.
| colorElt | root element for the serialization, it is assumed that this element is <color /> |
| doc | is the document containing colorElt |
Definition at line 304 of file KoColor.cpp.
References KoColorSpace::colorToXML(), m_colorSpace, m_data, m_metadata, and v.
|
private |
|
private |