/**
* gets The CMYK string value of the Uicolor object .
*/
-(nsstring *) Getcmykstringvaluebycolor: (uicolor *) origincolor{
//Method provided by the Colours class extension
nsdictionary *cmykdict = [selfgetcmykvaluebycolor: Origincolor];
return [nsstringstringwithformat:@ "(%0.2f,%0. 2f,%0.2f,%0.2f) ",
[cmykdict[@ "C"]floatvalue],
[cmykdict[@ "M"]floatvalue],
[cmykdict[@ "Y"]floatvalue],
[cmykdict[@ "K"]floatvalue]];
}
/**
* gets The CMYK value of the Uicolor object .
*
* @return
*/
-(nsdictionary *) Getcmykvaluebycolor: (uicolor *) origincolor
{
//Convert RGB to CMY
nsdictionary *rgb = [selfgetrgbdictionarybycolor: Origincolor];
CGFloat C =1 -[rgb[@ "R"]floatvalue];
CGFloat M =1 -[rgb[@ "G"]floatvalue];
CGFloat Y =1 -[rgb[@ "B"]floatvalue];
//Find K
CGFloat K =min(1,min(C,min(Y, M)));
if (K = =1) {
C =0;
M =0;
Y =0;
}
Else {
void (^newcmyk) (cgfloat *);
Newcmyk = ^ (cgfloat *x) {
*x = (*x-k)/(1 -K);
};
Newcmyk (&C);
Newcmyk (&M);
Newcmyk (&y);
}
return @{@ "C":@ (c),
@ "M":@ (m),
@ "y":@ (y),
@ "K":@ (k)};
}
/**
* gets The RGB value of the Uicolor object .
*
* @return Dictionary objects that contain RGB values.
*/
-(nsdictionary *) Getrgbdictionarybycolor: (uicolor *) origincolor
{
cgfloat r=0, g=0, b=0, a=0;
if ([selfrespondstoselector:@selector(getRed:green:blue:alpha:)]) {
[Origincolorgetred: &rgreen: &gBlue: &bAlpha:&a];
}
Else {
Const cgfloat *components =cgcolorgetcomponents(origincolor. Cgcolor);
r = components[0];
g = components[1];
b = components[2];
A = components[3];
}
return @{@ "R":@ (R),
@ "G":@ (g),
@ "B":@ (b),
@ "A":@ (a)};
}
iOS gets CMYK values for Uicolor objects