ColorSpace

class ColorSpace

Methods

Deserialize

Equals

If both are null, we return true.

Make

Create an ColorSpace from a parsed (skcms) ICC profile.

MakeRGB

Create an ColorSpace from a transfer function and a row-major 3x3 transformation to XYZ.

MakeSRGB

Create the sRGB color space.

MakeSRGBLinear

Colorspace with the sRGB primaries, but a linear (1.0) gamma.

__init__

deref

gammaCloseToSRGB

Returns true if the color space gamma is near enough to be approximated as sRGB.

gammaIsLinear

Returns true if the color space gamma is linear.

gamutTransformTo

hash

invTransferFn

isNumericalTransferFn

Sets |fn| to the transfer function from this color space.

isSRGB

Returns true if the color space is sRGB.

makeColorSpin

Returns a color space with the same transfer function as this one, but with the primary colors rotated.

makeLinearGamma

Returns a color space with the same gamut as this one, but with a linear gamma.

makeSRGBGamma

Returns a color space with the same gamut as this one, with with the sRGB transfer function.

ref

refCntGreaterThan

serialize

Returns nullptr on failure.

toProfile

Convert this color space to an skcms ICC profile struct.

toXYZD50

Returns true and sets |toXYZD50| if the color gamut can be described as a matrix.

toXYZD50Hash

Returns a hash of the gamut transformation to XYZ D50.

transferFn

Overloaded function.

transferFnHash

unique

unref

writeToMemory

If |memory| is nullptr, returns the size required to serialize.

Methods

static ColorSpace.Deserialize(data: capsule, length: int) skia.ColorSpace
static ColorSpace.Equals(self: skia.ColorSpace, other: skia.ColorSpace) bool

If both are null, we return true.

If one is null and the other is not, we return false. If both are non-null, we do a deeper compare.

static ColorSpace.Make(profile: skia.cms.ICCProfile) skia.ColorSpace

Create an ColorSpace from a parsed (skcms) ICC profile.

static ColorSpace.MakeRGB(transferFn: skia.cms.TransferFunction, toXYZ: skia.cms.Matrix3x3) skia.ColorSpace

Create an ColorSpace from a transfer function and a row-major 3x3 transformation to XYZ.

static ColorSpace.MakeSRGB() skia.ColorSpace

Create the sRGB color space.

static ColorSpace.MakeSRGBLinear() skia.ColorSpace

Colorspace with the sRGB primaries, but a linear (1.0) gamma.

ColorSpace.__init__(*args, **kwargs)
ColorSpace.deref(self: skia.ColorSpace) None
ColorSpace.gammaCloseToSRGB(self: skia.ColorSpace) bool

Returns true if the color space gamma is near enough to be approximated as sRGB.

ColorSpace.gammaIsLinear(self: skia.ColorSpace) bool

Returns true if the color space gamma is linear.

ColorSpace.gamutTransformTo(self: skia.ColorSpace, dst: skia.ColorSpace, src_to_dst: skia.cms.Matrix3x3) None
ColorSpace.hash(self: skia.ColorSpace) int
ColorSpace.invTransferFn(self: skia.ColorSpace, fn: skia.cms.TransferFunction) None
ColorSpace.isNumericalTransferFn(self: skia.ColorSpace, fn: skia.cms.TransferFunction) bool

Sets |fn| to the transfer function from this color space.

Returns true if the transfer function can be represented as coefficients to the standard ICC 7-parameter equation. Returns false otherwise (eg, PQ, HLG).

ColorSpace.isSRGB(self: skia.ColorSpace) bool

Returns true if the color space is sRGB.

Returns false otherwise.

This allows a little bit of tolerance, given that we might see small numerical error in some cases: converting ICC fixed point to float, converting white point to D50, rounding decisions on transfer function and matrix.

This does not consider a 2.2f exponential transfer function to be sRGB. While these functions are similar (and it is sometimes useful to consider them together), this function checks for logical equality.

ColorSpace.makeColorSpin(self: skia.ColorSpace) skia.ColorSpace

Returns a color space with the same transfer function as this one, but with the primary colors rotated.

For any XYZ space, this produces a new color space that maps RGB to GBR (when applied to a source), and maps RGB to BRG (when applied to a destination). For other types of color spaces, returns nullptr.

This is used for testing, to construct color spaces that have severe and testable behavior.

ColorSpace.makeLinearGamma(self: skia.ColorSpace) skia.ColorSpace

Returns a color space with the same gamut as this one, but with a linear gamma.

For color spaces whose gamut can not be described in terms of XYZ D50, returns linear sRGB.

ColorSpace.makeSRGBGamma(self: skia.ColorSpace) skia.ColorSpace

Returns a color space with the same gamut as this one, with with the sRGB transfer function.

For color spaces whose gamut can not be described in terms of XYZ D50, returns sRGB.

ColorSpace.ref(self: skia.ColorSpace) None
ColorSpace.refCntGreaterThan(self: skia.ColorSpace, count: int) bool
ColorSpace.serialize(self: skia.ColorSpace) SkData

Returns nullptr on failure.

Fails when we fallback to serializing ICC data and the data is too large to serialize.

ColorSpace.toProfile(self: skia.ColorSpace) skia.cms.ICCProfile

Convert this color space to an skcms ICC profile struct.

ColorSpace.toXYZD50(self: skia.ColorSpace, matrix: skia.cms.Matrix3x3) bool

Returns true and sets |toXYZD50| if the color gamut can be described as a matrix.

Returns false otherwise.

ColorSpace.toXYZD50Hash(self: skia.ColorSpace) int

Returns a hash of the gamut transformation to XYZ D50.

Allows for fast equality checking of gamuts, at the (very small) risk of collision.

ColorSpace.transferFn(*args, **kwargs)

Overloaded function.

  1. transferFn(self: skia.ColorSpace, gabcdef: float) -> None

  2. transferFn(self: skia.ColorSpace, fn: skia.cms.TransferFunction) -> None

ColorSpace.transferFnHash(self: skia.ColorSpace) int
ColorSpace.unique(self: skia.ColorSpace) bool
ColorSpace.unref(self: skia.ColorSpace) None
ColorSpace.writeToMemory(self: skia.ColorSpace, memory: capsule) int

If |memory| is nullptr, returns the size required to serialize.

Otherwise, serializes into |memory| and returns the size.