public static float [ ] cmykFromRgb ( int rgbColor ) { int red = ( 0xff0000 & rgbColor ) >> 16 ; int green = ( 0xff00 & rgbColor ) >> 8 ; int blue = ( 0xff & rgbColor ) ; float black = Math . min ( 1.0f - red / 255.0f , Math . min ( 1.0f - green / 255.0f , 1.0f - blue / 255.0f ) ) ; float cyan = 1.0f ; float magenta = 1.0f ; float yellow = 1.0f ; if ( black != 1.0f ) { // black 1.0 causes zero divide cyan = ( 1.0f - ( red / 255.0f ) - black ) / ( 1.0f - black ) ; magenta = ( 1.0f - ( green / 255.0f ) - black ) / ( 1.0f - black ) ; yellow = ( 1.0f - ( blue / 255.0f ) - black ) / ( 1.0f - black ) ; } return new float [ ] { cyan , magenta , yellow , black } ; }
Convert RGB color to CMYK color .