From a18e2f26983a4b903e2031433677c1029c106dba Mon Sep 17 00:00:00 2001 From: Andreu Vall Date: Sun, 16 Nov 2025 15:26:44 +0100 Subject: [PATCH] Add conversion from CMY to RGB and back --- src/conversions.jl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/conversions.jl b/src/conversions.jl index d49eea2..873356e 100644 --- a/src/conversions.jl +++ b/src/conversions.jl @@ -213,6 +213,11 @@ cnvt(::Type{CV}, c::Union{DIN99d, DIN99o, DIN99}) where {CV<:AbstractRGB} = cnvt error("No conversion of ", c, " to ", CV, " has been defined") end +function cnvt(::Type{CV}, c::CMY) where CV<:AbstractRGB + _one = one(c.c) + CV(_one - c.c, _one - c.m, _one - c.y) +end + # AbstractGray --> AbstractRGB conversions are implemented in ColorTypes.jl @@ -811,6 +816,10 @@ end cnvt(::Type{YCbCr{T}}, c::Color) where {T} = cnvt(YCbCr{T}, convert(RGB{T}, c)::RGB{T}) +function cnvt(::Type{CMY{T}}, c::AbstractRGB) where T + _one = one(c.r) + CMY(_one - c.r, _one - c.g, _one - c.b) +end # To Gray # -------