如何1位的位图数据转换为8位(24 bpp的)?位图、转换为、数据、bpp

2023-09-11 22:41:45 作者:岁月负缠绵

假如我有4位图,比方说,CMYK,所有这一切都是1位/像素,并有不同的颜色,我想将它们转换为一个8位/色(24 bpp的)位图,我将如何做到这一点?

Supposing I have 4 bitmaps, say, CMYK, all of which are 1bit/pixel and are of different colors, and I wanted to convert them to an 8bit/color (24bpp) bitmap, how would I do this?

如果数据是这样的:

// the Cyan separation

CCCC CCCC CCCC CCCC CCCC CCCC CCCC CCCC
...

// the magenta separation, and so on..
MMMM MMMM MMMM MMMM MMMM MMMM MMMM MMMM
...

说,青色具有RGB值(0255255)中,在像素0(第一像素),我有1(开)的值,和品红具有RGB值(255,255,0),和在相同的像素,有值为1。什么会第一RGB像素是什么样子?会是什么样子呢?

Say, the Cyan had an RGB value of (0,255,255), and at Pixel 0 (first pixel), I had a value of 1 (on), and the Magenta had an RGB value of (255,255,0), and at the same pixel, had a value of 1.. What would the first RGB pixel look like? Would it look like this?

BBBB BBBB GGGG GGGG RRRR RRRR
// would this 3-byte sequence  actually be 255,255,255
// because the cyan has (0,255,255) and the 
// magenta has (255,255,0)?

谢谢,只是困惑,如何1bit的分离转换成8位图像..谢谢..

Thanks, just confused as to how to convert 1bit separations into an 8bit image.. Thanks..

推荐答案

CMYK是消减色彩系统,而RGB是一种添加剂的。

CMYK is a substractive color system, while RGB is an additive one.

如果您有(1.0,1.0,1.0)一个CMY(K)的价值,它是黑色的,而(255,255,255)的RGB值,它是白色的。

If you have a CMY(K) value of (1.0, 1.0, 1.0), it's black, while an RGB value of (255, 255, 255), it's white.

青色+品红色=蓝:(0,255,255)+(255,0,255)=(0,0,255)。但是,不完全的,因为我们正在谈论不同的颜色系统。

Cyan + Magenta = Blue: (0, 255, 255) + (255, 0, 255) != (0, 0, 255). But not exactly, because we're talking different color systems.

您需要先构建在CMYK像素,然后将其转换为RGB,它可以是近似的通过执行(R,G,B)=(1- C,1-M,1-Y)

You need to first construct the pixels in CMYK, and then convert them to RGB, which can be approximated by doing (R, G, B) = (1-C, 1-M, 1-Y).

在以1位值转换为8位值,你只需要改变每一个 0 0×00 和每 1 0xFF的:乘 bitValue 0xFF的

In order to convert a 1-bit value to an 8-bit value, you just need to transform every 0 into 0x00 and every 1 into 0xFF: Multiply bitValue by 0xFF.