[译]XCmyk-CMYK到RGB计算器的源代码
By robot-v1.0
本文链接 https://www.kyfws.com/applications/xcmyk-cmyk-to-rgb-calculator-with-source-code-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 6 分钟阅读 - 2756 个词 阅读量 0[译]XCmyk-CMYK到RGB计算器的源代码
原文地址:https://www.codeproject.com/Articles/4488/XCmyk-CMYK-to-RGB-Calculator-with-source-code
原文作者:Hans Dietrich
译文由本站 robot-v1.0 翻译
前言
XCmyk implements an RGB to CMYK calculator
XCmyk实现RGB到CMYK计算器
介绍(Introduction)
颜色空间是一种表示颜色以及它们之间的关系的方式.在当前使用的色彩空间中,经常遇到RGB和CMYK空间:RGB,因为它用于彩色监视器;和CMYK,因为它用于打印.使用不同颜色空间的原因多种多样,任何Google搜索都会产生许多结果供进一步研究.(A color space is a way of representing colors and how they relate to one another. Among the color spaces currently in use, the RGB and CMYK spaces are encountered very frequently: RGB, because it is used in color monitors; and CMYK, because it is used for printing. There are different reasons for using different color spaces, and any google search will produce many results for further study.)
RGB(RGB)
在计算机行业中,RGB已成为桌面应用程序和基于Web的系统的事实上的标准. RGB是加色空间-也就是说,它的三种原色(红色,绿色和蓝色)可加在一起组合以产生所需的颜色.每种颜色由0到255之间的数字表示.这种表示形式便于计算机系统以十六进制表示法进行操作.这也意味着可以在RGB颜色空间中表示255 x 255 x 255或16,777,216种不同的颜色. RGB颜色空间可能显示为:(In the computer industry, RGB has become the de facto standard for both desktop applications and web-based systems. RGB is an additive color space - that is, its three primary colors (red, green, and blue) combine additively to produce any desired colors. Each of the component colors is represented by a number from 0 to 255. This representation lends itself to easy manipulation by computer systems in a hex notation. It also means that 255 x 255 x 255, or 16,777,216 different colors may be represented in the RGB color space. The RGB color space may be shown as:)
这表明当RGB值为(255,255,255)时,您将获得白色.(This shows that when you have an RGB value of (255,255,255), you will get white.)
CMYK(CMYK)
相反,CMYK是减色空间.它是RGB颜色空间的补充-青色,品红色和黄色分别是红色,绿色和蓝色的补充. CMYK之所以称为减色法,是因为从白光中减去了其原色以产生最终的颜色:青色吸收红色,品红色吸收绿色,黄色吸收蓝色.(CMYK by contrast is a subtractive color space. It is the complement of the RGB color space - cyan, magenta, and yellow are the complements of red, green, and blue, respectively. CMYK is called subtractive because its primary colors are subtracted from white light to produce the resulting color: cyan absorbs red, magenta absorbs green, and yellow absorbs blue.)
因此,您可以通过增加洋红色和黄色或减少青色来增加红色.在CMYK颜色空间中,每种颜色的值通常以百分比表示,范围从0到100.因此,在CMYK颜色空间中最多可以表示100 x 100 x 100或1,000,000种不同的颜色(黑色用于使颜色变浅或变深).(So you could increase the red either by increasing the magenta and yellow, or by decreasing the cyan. In the CMYK color space, the values for each of the colors are typically shown as percentages, from 0 to 100. So up to 100 x 100 x 100, or 1,000,000 different colors may be represented in the CMYK color space (black is used to lighten or darken the color).)
第四种颜色(黑色)被添加到CMYK颜色空间,因为在打印时它提供了比其他三种颜色更纯净的黑色形式.黑色墨水也比其他三种墨水便宜,因此打印机将调整颜色,直到实现最低成本的组合为止.黑色被添加为CMYK颜色空间的" K",以避免将" B"与蓝色或棕色混淆.(The fourth color (black) was added to the CMYK color space because in printing it gives a purer form of black than the other three colors. Black ink is also cheaper than the other three inks, so that printers will adjust the colors until the lowest-cost combination is achieved. Black was added to the CMYK color space as “K” to avoid confusing a “B” with blue or brown.)
RGB到CMYK(RGB to CMYK)
公司通常会希望将其网站布局和颜色与公司徽标以及印刷材料中的颜色使用相匹配.一(Often a company will want to match its web site layout and colors to its corporate logo, and to its use of colors in printed material. One) 标准方程(standard equation) 用于将RGB转换为CMYK的是:(that is used to convert RGB to CMYK is:)
Black = minimum(1-Red,1-Green,1-Blue)
Cyan = (1-Red-Black)/(1-Black)
Magenta = (1-Green-Black)/(1-Black)
Yellow = (1-Blue-Black)/(1-Black)
请注意,此等式假设RGB值已归一化-即它们在0到1.0之间.(Note that this equation assumes that the RGB values have been normalized - i.e., that they are between 0 and 1.0.)
借助此方程式,您可以近似于屏幕上看到的RGB颜色以及打印时的颜色.我说"近似"是因为从丝网到印刷材料时要考虑几个因素.首先是计算机监视器通常色彩校正较差.影像专业人士使用非常高端的监视器和各种校准工具来尽量减少这一因素.(With this equation, you are able to approximate the RGB color you see on your screen with what the color will look like when it is printed. I say “approximate” because there are several factors to consider when going from screen to printed material. The first is that computer monitors usually have poor color calibration. Imaging professionals use very high-end monitors and a variety of calibration tools to try to minimize this factor.)
另一个主要因素:颜色通常在打印时看起来会有所不同,这通常是由于所使用的纸张类型-磨砂,半光泽,高光泽等等.而且,彩色墨水也不透明,因此如果纸张不是白色,颜色将在纸张上着色.美纹纸也会影响颜色的外观.影像专业人士必须处理所有这些事情,并加以补偿.(Another major factor: colors will simply look different when printed, often due to the type of paper being used - matte, semi-gloss, high gloss, etc. Also, color inks are not opaque, so if the paper is not white, the color will be tinted by the paper. Textured paper will also affect the appearance of the color. Imaging professionals must deal with all these things, and compensate for them.)
您会看到成像专业人员经常使用的一种工具是"印刷色指南".这只是一本小册子-通常成扇形折叠-有很多颜色,其CMYK值打印在白纸上. <印刷色指南>通常由这些手册中的几本组成,适用于毛面纸,半光面纸等.(One tool you will see imaging professionals use quite often is something called a Process Color Guide. This is simply a small booklet - usually fan-fold - with a large number of colors and their CMYK values printed on white paper. A Process Color Guide usually consists of several of these booklets, for matte paper, semi-gloss paper, and so on.)
演示应用(Demo App)
的(The)**XCmykTest.exe(XCmykTest.exe)**演示演示了如何在(demo shows how to use the conversion routines in)XCmyk.cpp(XCmyk.cpp):(:)
请注意,当您沿一个方向旋转RGB或CMY旋钮之一时,另一颜色空间中的相应旋钮将沿相反方向旋转.(Note that as you turn one of the RGB or CMY knobs in one direction, the corresponding knob in the other color space will turn in the opposite direction.)
运行时要求(Run-time Requirements)
CKnobControlST
用途(uses)Gdiplus.dll(Gdiplus.dll),这是Windows XP附带的. GDI +可作为Windows NT 4.0SP6,Windows 2000,Windows 98和Windows Me的可再发行版本提供.要下载最新的可再发行文件,请转到(, which is included with Windows XP. GDI+ is available as a redistributable for Windows NT 4.0SP6, Windows 2000, Windows 98, and Windows Me. To download the latest redistributable, please go) 这里(here) .要了解有关GDI +的更多信息,请转到(. To learn more about GDI+, please go) 这里(here) .(.)
致谢(Acknowledgements)
- 感谢Davide Calabro的出色表现(Thanks to Davide Calabro’s excellent) CKnobControlST(CKnobControlST) .(.)
修订记录(Revision History)
版本1.0-2003年7月6日(Version 1.0 - 2003 July 6)
- 首次公开发行.(Initial public release.)
用法(Usage)
该软件已发布到公共领域.您可以自由使用任何喜欢的方式.如果您对其进行修改或扩展,请考虑在此处发布新代码,以供所有人共享.该软件按"原样"提供,没有任何明示或暗示的保证.对于此软件可能引起的任何损坏或业务损失,我不承担任何责任.(This software is released into the public domain. You are free to use it in any way you like. If you modify it or extend it, please to consider posting new code here for everyone to share. This software is provided “as is” with no expressed or implied warranty. I accept no liability for any damage or loss of business that this software may cause.)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
C++ VC6 WinXP Windows Win2K MFC Visual-Studio Dev 新闻 翻译