How to convert from CMYK to RGB java

302 Views Asked by At

Im trying to make a java script to convert from cmyk to rgb, but im having problems with re results, I found the formula online but I dont know whats wrong with my script. The problem is that the outpur is wrong, e.g. Magenta should come out as red:255 green:0 blue:255 instead of my output which is :red:255 green:252 blue:255.

public class CMYKtoRGB {
public static void main(String[] args) {
     double cyan = Double.parseDouble(args[0]);
     double magenta = Double.parseDouble(args[1]);
     double yellow = Double.parseDouble(args[2]);
     double black = Double.parseDouble(args[3]);        

     int red = (int) Math.round(255 * ( 1 - cyan/100) * (1 - black/100 ));
     int green = (int) Math.round(255 * (1 - magenta/100) * (1 - black/100));
     int blue =(int)Math.round(255*(1-yellow)*(1-black/100));       

     System.out.println(red);
     System.out.println(green);
     System.out.println(blue);
}
}```
0

There are 0 best solutions below