CMYK转RGB

news/2024/10/23 9:33:22/

扫描仪的颜色空间一般为CMYK,从扫描仪上得到的图片如果是自己移植图片解码器, 一般需要将CMYK转换至RGB888。相关解释,参考国外资料:
To understand the CMYK color model, it is best to start with an understanding of RGB color.

The RGB color model is made up of red, green and blue. It is used on your computer monitor and is what you will view your projects in while still on the screen. RGB is retained for projects that are designed to stay on screen (websites, pdfs, and other web graphics, for instance).

These colors, however, can only be viewed with natural or produced light, such as in the computer monitor, and not on a printed page. This is where CMYK comes in.

When two RGB colors are mixed equally they produce the colors of the CMYK model, which are known as subtractive primaries.

Green and blue create cyan (C).
Red and blue create magenta (M).
Red and green create yellow (Y).
Black is added to the model because it cannot be created with the 3 subtractive primaries (when combined they create a dark brown). The K, or “key,” stands for black.

转换公式如下:
R = C* (255 - cyan)/255;
G = C* (255 - magenta)/255;
B = C* (255 - yellow)/255;

C实现代码:

uint8_t* CMYKToRGB24(uint32_t* cmyk, int width, int height)
{uint32_t off;uint32_t color;int i,j;uint32_t row_bytes;uint8_t* rgb;uint8_t* ptr;uint8_t c,m,y,k;int tmp;row_bytes = (width * 3 + 3) & ~3;rgb = (uint8_t*)malloc(row_bytes * height);if(!rgb)return NULL;off = 0;for (i = 0; i < height; i++){   ptr = rgb + off;for(j = 0; j < width; j++){color = *cmyk++;c = color & 0x000000FF;m = (color >> 8) & 0x000000FF;y = (color >> 16) & 0x000000FF;k = (color >> 24) & 0x000000FF;*ptr++ = k * c/255;*ptr++ = k * m/255;*ptr++ = k * y/255;}off += row_bytes;}return rgb;
}

http://www.ppmy.cn/news/826668.html

相关文章

java cmyk转rgb_图片 CMYK转RGB 代码

//大部分情况都转换没问题&#xff0c;有极个别的转换不成功。现在想&#xff0c;是不是调用convert.exe 更方便 呵呵 private static boolean isCMYK(String filename) { boolean result false; BufferedImage img null; try { img ImageIO.read(new File(filename)); } ca…

CMYK convert RGB

libjpeg 处理CMYK 格式数据以及iCC配置文件 ICC文件&#xff0c;又叫ICC Color Profile&#xff0c;是指设备管理色彩特性的文件&#xff0c;各种具有色彩管理功能的软件&#xff08;如photoshop&#xff09;可以依据ICC文件的配置对不同设备的颜色特点进行准确地显示&#xf…

java cmyk和rgb的转换_CMYK与RGB相互转换(java)

package util; import java.awt.*; import javax.swing.*; import java.awt.color.*; public class ColorTranslate { ICC_Profile ICC_pf; ICC_ColorSpace ICC_ClSpace; //以下变量存储CMYK颜色值&#xff0c;取值为0到100 int C 9; int M 9; int Y 9; int K 9; //初始化I…

java cmyk和rgb的转换_如何在ColdFusion(Java)中在CMYK和RGB之间转换图像?

小编典典 我使用Java ImageIO库(https://jai-imageio.dev.java.net)。它们不是完美的&#xff0c;但可以很简单&#xff0c;就可以完成工作。至于从CMYK转换为RGB&#xff0c;这是我能想到的最好的方法。 下载并安装适用于您平台的ImageIO JAR和本机库。本地库是必不可少的。没…

CMYK 和 RGB 着色

CMYK 和 RGB 着色 The CMYK color model (process color, four color) is a subtractive color model, used in color printing, and is also used to describe the printing process itself. CMYK refers to the four inks used in some color printing: cyan, magenta, yello…

java cmyk和rgb的转换_CMYK和RGB怎么转换

作为设计师新手&#xff0c;常常会遇到电脑里的图和实际打印出来的图颜色对不上的问题&#xff0c;只能不断调整再打印&#xff0c;费钱又费时。其实这都是因为颜色模式不同的原因&#xff0c;我们可以通过CorelDRAW 2019(Win版)调整&#xff0c;减少损失。 RGB(如图一)是通过对…

CMYK与RGB参数转换公式及转换方法

1. RGB色彩模式 自然界中绝大部分的可见光谱可以用红、绿和蓝三色光按不同比例和强度的混合来表示。RGB分别代表着3种颜色&#xff1a;R代表红色&#xff0c;G代表绿色、B代表蓝色。RGB模型也称为加色模型&#xff0c;如图5所示。RGB模型通常用于光照、视频和屏幕图像编辑。 …

最常用的计算机色彩表示方法——RGB模式与CMYK模式

现实绘画中需要的各种颜色&#xff0c;是通过红、黄、蓝三种原色进行调配得到的。而计算机里的颜色表示也是通过类似的“调配”的方法来完成。 其中最常见的两种表示方法即为RGB模式与CMYK模式。 一. RGB模式 RGB色彩就是常说的三原色&#xff0c;R代表Red&#xff08;红色&a…