Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,894 questions

51,825 answers

573 users

How to convert CMYK to RGB in C++

1 Answer

0 votes
#include <iostream>
#include <cmath>
 
// CMYK = Cyan, Magenta, Yellow, Key(black)
// RGB = Red, Green, Blue
  
struct CMYK {
    double C;
    double M;
    double Y;
    double K;
};
  
struct RGB {
    double R;
    double G;
    double B;
};
  
struct RGB CMYKToRGB(struct CMYK cmyk) {
    struct RGB rgb;
  
    rgb.R = round(255 * (1 - cmyk.C / 100) * (1 - cmyk.K / 100));
    rgb.G = round(255 * (1 - cmyk.M / 100) * (1 - cmyk.K / 100));
    rgb.B = round(255 * (1 - cmyk.Y / 100) * (1 - cmyk.K / 100));
  
    return rgb;
}
  
int main(void)
{
    struct CMYK data = {4.0, 16.0, 100.0, 0.0};
    struct RGB rgb = CMYKToRGB(data);
  
    std::cout << "R = " << rgb.R << " G = " << rgb.G << " B = " << rgb.B;
}
  
  
  
  
/*
run:
  
R = 245 G = 214 B = 0
  
*/

 



answered Jan 30, 2023 by avibootz
edited Jan 31, 2023 by avibootz

Related questions

1 answer 138 views
138 views asked Jan 31, 2023 by avibootz
1 answer 96 views
96 views asked Jan 31, 2023 by avibootz
1 answer 86 views
86 views asked Jan 30, 2023 by avibootz
1 answer 122 views
122 views asked Feb 2, 2023 by avibootz
1 answer 124 views
124 views asked Feb 1, 2023 by avibootz
1 answer 121 views
121 views asked Feb 1, 2023 by avibootz
1 answer 126 views
126 views asked Jan 31, 2023 by avibootz
...