Class ManagedColor
Build from ManagedColor.h
Krita 4.0.0Krita 4.3.0

The ManagedColor class is a class to handle colors that are color managed. A managed color is a color of which we know the model(RGB, LAB, CMYK, etc), the bitdepth and the specific properties of its colorspace, such as the whitepoint, chromaticities, trc, etc, as represented by the color profile.

Krita has two color management systems. LCMS and OCIO. LCMS is the one handling the ICC profile stuff, and the major one handling that ManagedColor deals with. OCIO support is only in the display of the colors. ManagedColor has some support for it in colorForCanvas()

All colors in Krita are color managed. QColors are understood as RGB-type colors in the sRGB space.

We recommend you make a color like this:

colorYellow = ManagedColor("RGBA", "U8", "")QVector<float> yellowComponents = colorYellow.components()yellowComponents[0] = 1.0yellowComponents[1] = 1.0yellowComponents[2] = 0yellowComponents[3] = 1.0colorYellow.setComponents(yellowComponents)QColor yellow = colorYellow.colorForCanvas(canvas)

Static methods

fromQColor(qcolor: QColor, canvas: Canvas = None)

Methods

ManagedColor(colorModel: str, colorDepth: str, colorProfile: str, parent: QObject = None) colorDepth()str colorForCanvas(canvas: Canvas)QColor colorModel()str colorProfile()str components()list[float] componentsOrdered()list[float] fromXML(xml: str) setColorProfile(colorProfile: str)bool setColorSpace(colorModel: str, colorDepth: str, colorProfile: str)bool setComponents(values: list[float]) toQString()str toXML()str

Member documentation

ManagedColor(colorModel: str, colorDepth: str, colorProfile: str, parent: QObject = None)
Krita 4.0.0

create a managed color with the given color space properties.

Parameters

colorModel(no description provided)
colorDepth(no description provided)
colorProfile(no description provided)
parent(no description provided)

Return

(no description provided)

colorDepth()str
Krita 4.0.0

colorDepth A string describing the color depth of the image:

  • U8: unsigned 8 bits integer, the most common type
  • U16: unsigned 16 bits integer
  • F16: half, 16 bits floating point. Only available if Krita was built with OpenEXR
  • F32: 32 bits floating point

Return

the color depth.

colorForCanvas(canvas: Canvas)QColor
Krita 4.0.0

Parameters

canvas

the canvas whose color management you'd like to use. In Krita, different views have separate canvasses, and these can have different OCIO configurations active.

Return

the QColor as it would be displaying on the canvas. This result can be used to draw widgets with the correct configuration applied.

colorModel()str
Krita 4.0.0

retrieve the current color model of this document:

  • A: Alpha mask
  • RGBA: RGB with alpha channel (The actual order of channels is most often BGR!)
  • XYZA: XYZ with alpha channel
  • LABA: LAB with alpha channel
  • CMYKA: CMYK with alpha channel
  • GRAYA: Gray with alpha channel
  • YCbCrA: YCbCr with alpha channel

Return

the internal color model string.

colorProfile()str
Krita 4.0.0

Return

the name of the current color profile

components()list[float]
Krita 4.0.0

Return

a QVector containing the channel/components of this color normalized. This includes the alphachannel.

componentsOrdered()list[float]
Krita 4.0.0

componentsOrdered()

Return

same as Components, except the values are ordered to the display.

fromQColor(qcolor: QColor, canvas: Canvas = None)
Krita 4.3.0

is the (approximate) reverse of colorForCanvas()

Parameters

qcolor

the QColor to convert to a KoColor.

canvas

the canvas whose color management you'd like to use.

Return

the approximated ManagedColor, to use for canvas resources.

fromXML(xml: str)
Krita 4.0.0Krita 5.1.0

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

Parameters

xml

an XML color

Return

the unserialized color, or an empty color object if the function failed

to unserialize the color

setColorProfile(colorProfile: str)bool
Krita 4.0.0

set the color profile of the image to the given profile. The profile has to be registered with krita and be compatible with the current color model and depth; the image data is not converted.

Parameters

colorProfile

(no description provided)

Return

false if the colorProfile name does not correspond to to a registered profile or if assigning the profile failed.

setColorSpace(colorModel: str, colorDepth: str, colorProfile: str)bool
Krita 4.0.0

convert the nodes and the image to the given colorspace. The conversion is done with Perceptual as intent, High Quality and No LCMS Optimizations as flags and no blackpoint compensation.

Parameters

colorModel

A string describing the color model of the image:

  • A: Alpha mask
  • RGBA: RGB with alpha channel (The actual order of channels is most often BGR!)
  • XYZA: XYZ with alpha channel
  • LABA: LAB with alpha channel
  • CMYKA: CMYK with alpha channel
  • GRAYA: Gray with alpha channel
  • YCbCrA: YCbCr with alpha channel

colorDepth

A string describing the color depth of the image:

  • U8: unsigned 8 bits integer, the most common type
  • U16: unsigned 16 bits integer
  • F16: half, 16 bits floating point. Only available if Krita was built with OpenEXR
  • F32: 32 bits floating point

colorProfile

a valid color profile for this color model and color depth combination.

Return

false the combination of these arguments does not correspond to a colorspace.

setComponents(values: list[float])
Krita 4.0.0

Set the channel/components with normalized values. For integer colorspace, this obviously means the limit is between 0.0-1.0, but for floating point colorspaces, 2.4 or 103.5 are still meaningful (if bright) values.

Parameters

values

the QVector containing the new channel/component values. These should be normalized.

toQString()str
Krita 4.0.0Krita 4.2.0

create a user-visible string of the channel names and the channel values

Return

a string that can be used to display the values of this color to the user.

toXML()str
Krita 4.0.0Krita 5.1.0

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

Return

(no description provided)