RGB or Hex, to CMYK?

Hi,
In my app I have a hexadecimal code (850028) assigned to a variable called “HexValue”
I also have the RGB code for the same color (133,0,40)assigned to a variable called “RGBValue”

Does anyone know how to convert either of those values into CMYK?
I would imagine that Hex to CMYK would be easier, but I have no idea if it’s even possible?

The expected output format would need to be like this:
%,%,%,%

Thank you all in advance.

You should have looked here http://documentation.xojo.com/index.php/color in the first place : any color has these value just as well as RGB.

Thanks Michel, but I have already seen that page, however, I need to know how to convert from one to the other :frowning:

you mean like this?

dim clr as color
clr=rgb(127,32,58)
h=clr.hue
s=clr.saturation
v.clr.value
//
clr=HSV(0.4,.3..2)
r=clr.red
g.clr.blue
b=clr.green

same thing for CMY(.3,.2.1)

Thanks Dave - I will take a look at that and try to convert RGB to CMYK.

Thanks.

In Xojo, a color is a color, is a color.

I suppose you want to express the color in CMYK for some other software, right ? Which format is it expecting ?

Keep in mind that there are many algorithms for converting to cmyk and that it usually involves color profiles to get the black channel right.

When converting RGB to CMYK you should have ICC profiles in mind. What profile is used/embedded will affect the resulting CMYK value. I don’t know how this works in Xojo but I guess it’s not as easy as it sounds.

http://www.rapidtables.com/convert/color/rgb-to-cmyk.htm

The result I need is in this format:

%,%,%,%

Thanks everyone - I will look into this more.

if you want to really convert to CMYK, please use proper color management.

MBS LCMS Plugin for example allows to convert from RGB to CMYK.
You provide ICC Profiles for source and target color spaces.