A digital world colors are specified in Red ,Green ,Blue(RGB) format with value of (R,G,b) varying on integers scale from 0 to 255 in point publishing the colors are mentioned in cyan, magenta - yellow black (CMYK) format ,with value of C,M,Y and k varying on real scale from 0.0 to 1.0 write the program to convert RGB colors to CMYK as per the following formula..White=max(Red/255,Green/255,Blue/255) ,cyan=(white-Red/255)/white , Magenta=(white -Green/255)/white , black = 1-white. note that if RGB value are 0 then the cmy values are all 0 and the k value is 1.
A digital world colors are specified in Red ,Green ,Blue(RGB) format with value of (R,G,B) varying on integers scale from 0 to 255 in point publishing the colors are mentioned in cyan, magenta - yellow black (CMYK) format ,with value of C,M,Y and k varying on real scale from 0.0 to 1.0 write the program to convert RGB colors to CMYK as per the following formula..
White=max(Red/255,Green/255,Blue/255),
cyan=(white-Red/255)/white
Magenta=(white -Green/255)/white
black = 1-white.
note that if RGB value are all 0 then the cmy values are all 0 and the k value is 1.
#include<stdio.h>
#include<conio.h>
int main()
{
float r,g,b,rf, gf,bf, max,w,c,y ,m,k;
printf(" Enter the value of red (0to 255):");
scanf("%f",&r);
printf("Enter the value of green(0 to 255):");
scanf("%f",&g);
printf("Enter the value of value of blue(0 to 255):");
scanf("%f",&b);
rf=r/255;
gf=g/255;
bf=b/255;
printf("Red:%f\n Green:%f\nBlue:%f\n",rf,gf ,bf) ;
// find the maximum all of them
max=rf;
if (max<gf)
max=gf;
if(max<bf)
max=bf;
//w stand for white
w=max;
printf("white :%f\n\n",w);
c=(w- rf)/w;
m=(w-gf)/w;
y=(w-bf)/w;
k=1-w;
printf("The value of cyan:%f\n",c);
printf("The value of magenta:%f\n",m);
printf("The value of yellow:%f\n",y);
printf("The value of black:%f\n",c);
}
related program--
Comments
Post a Comment