xcode Interface Builder 中的颜色错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14578759/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Wrong color in Interface Builder
提问by user2020909
The problem:I set a color in Interface Builder, setting the channels RGB, then I do a screenshot of the working window, open it in Photoshop and check color by color picker, which I have set in Interface Builder. The result - the RGB values ??are different from the ones I set.
问题:我在 Interface Builder 中设置了一种颜色,将通道设置为 RGB,然后我对工作窗口进行了截图,在 Photoshop 中打开它并通过我在 Interface Builder 中设置的颜色选择器检查颜色。结果 - RGB 值与我设置的不同。
Video: http://www.youtube.com/watch?v=ASLfnYHPbqM
视频:http: //www.youtube.com/watch?v=ASLfnYHPbqM
Most abnormal begins with the 45th second, when I tried to use the color picker of the Interface Builder. It shows the RGB values ??are different from those that I have in him the same and installed), but the values ??of сolor picker IB coincide with the values ??of color picker Photoshop.
最不正常的开始于第 45 秒,当我尝试使用 Interface Builder 的颜色选择器时。它显示的 RGB 值与我在他身上安装的相同并安装的值不同),但颜色选择器 IB 的值与颜色选择器 Photoshop 的值一致。
回答by Mecki
Apple thinks it is much more important that colors look the same everywherethan that colors have the same RGB values everywhere. See, the same RGB values will not look the same on different screens, because every screen has different display characteristics.
Apple 认为颜色在任何地方看起来都相同比颜色在任何地方都具有相同的 RGB 值要重要得多。看,相同的 RGB 值在不同的屏幕上看起来不会相同,因为每个屏幕都有不同的显示特性。
So when you take a screenshot, Apple does not just store a RGB value for every pixel in the image, they also store the display characteristics of your monitor inside the image file. What is that good for? If someone else opens your screenshot, the system can look at the monitor characteristics of the person who created it, compare those to the monitor characteristics of the monitor of the person that wants to watch it, and can then calculate how it must adopt the RGB valuesin the image so that the image looks the same on the current monitor. If it was just displaying the RGB values without doing any of this, the image colors may look wrong (in some cases only slightly, in some cases some more, and if the user has a very bad monitor, in some cases even radically wrong).
因此,当您截取屏幕截图时,Apple 不仅会为图像中的每个像素存储 RGB 值,还会将显示器的显示特性存储在图像文件中。那有什么用?如果别人打开你的截图,系统可以查看创建它的人的显示器特性,将这些特性与想要观看它的人的显示器的显示器特性进行比较,然后可以计算它必须如何采用RGB图像中的值,以便图像在当前监视器上看起来相同。如果它只是显示 RGB 值而不执行任何操作,则图像颜色可能看起来不对(在某些情况下只是轻微的,在某些情况下更多,如果用户的显示器非常糟糕,在某些情况下甚至是完全错误的) .
So the system send different RGB values to the graphics adapter, because RGB colors by themselves do not really describe a color. RGB values together with a monitor profile do describe a color and not the RGB values are important, the color is important. If I make something red, I want it to be the same shade of red on every monitor. I don't want it to be a darker red on one monitor, a lighter red on another monitor, and a red that is almost pink on a third monitor.
因此系统向图形适配器发送不同的 RGB 值,因为 RGB 颜色本身并不能真正描述颜色。RGB 值与显示器配置文件一起描述了一种颜色,RGB 值并不重要,颜色很重要。如果我将某些东西变成红色,我希望它在每台显示器上都具有相同的红色阴影。我不希望它在一台显示器上呈深红色,在另一台显示器上呈浅红色,而在第三台显示器上呈几乎粉红色的红色。
The problem with Photoshop is that it has its own build-in color correction mechanism. Photoshop usually works in sRGB (standard RGB color space) or Adobe RGB (an extended color space Adobe invented). When you load an image that is not within the desired color space, Photoshop will transform the color space of the image and every color space transform causes the RGB values to change. Please note that the images displayed within Photoshop are still color corrected according to your current monitor color characteristics, it's just the RGB values you manipulate within Photoshop that are in another color space and when stored back to file, Photoshop will either transform the values back or it will keep them and embed a new color profile into the image file.
Photoshop 的问题在于它有自己的内置色彩校正机制。Photoshop 通常在 sRGB(标准 RGB 色彩空间)或 Adobe RGB(Adobe 发明的扩展色彩空间)中工作。当您加载不在所需色彩空间内的图像时,Photoshop 将转换图像的色彩空间,并且每次色彩空间转换都会导致 RGB 值发生变化。请注意,在 Photoshop 中显示的图像仍会根据您当前的显示器颜色特征进行颜色校正,只是您在 Photoshop 中操作的 RGB 值处于另一个颜色空间,当存储回文件时,Photoshop 会将这些值转换回或它将保留它们并将新的颜色配置文件嵌入到图像文件中。
The times where RGB alone has been used to describe colors are over for many years already. Today RGB is rather meaningless on its own, only when combined with a color profile it becomes really meaningful in describing an actual color.
仅用 RGB 来描述颜色的时代已经过去很多年了。今天,RGB 本身是相当无意义的,只有当与颜色配置文件结合时,它才会在描述实际颜色时变得真正有意义。
If you want a screenshot without a real color profile embedded, do the following:
如果您想要没有嵌入真实颜色配置文件的屏幕截图,请执行以下操作:
- Open "System Preferences"
- Go to "Displays"
- Go to "Color"
- Select "Generic RGB Profile"
- Make your screenshot
- Change your profile back
- 打开“系统偏好设置”
- 转到“显示”
- 转到“颜色”
- 选择“通用 RGB 配置文件”
- 制作你的截图
- 改回您的个人资料
It may be necessary to quit Xcode first before you change the profile (and restart it after you changed it back), since I'm not sure if changing the profile has immediate effect. It certainly has immediate effect how things are displayed on your monitor, but if you want to choose a color in Xcode by selecting specific RGB values, I'm not sure if a profile change will have immediate effect here as well (you can give it a try without restarting, if that does not work, you must repeat it with restarting).
可能有必要在更改配置文件之前先退出 Xcode(并在更改回来后重新启动它),因为我不确定更改配置文件是否会立即生效。它当然会立即影响显示器上的显示方式,但是如果您想通过选择特定的 RGB 值在 Xcode 中选择一种颜色,我不确定配置文件更改是否也会立即生效(您可以给它不重启试试,如果不行,必须重启再试试)。
This may still cause incorrect colors in Photoshop though, since Photoshop may still convert the colors to sRGB or Adobe RGB. So instead of selecting "Generic RGB Profile", you may want to select the "sRGB" profile (depending on your OS X version, may also be named "sRGB IEC61966-2.1"). This way the image is already in sRGB color space. You only have to convince Photoshop to keep it that way (and not converting it to Adobe RGB) and then you will really see the same RGB values in Xcode and Photoshop.
不过,这可能仍会导致 Photoshop 中的颜色不正确,因为 Photoshop 仍可能将颜色转换为 sRGB 或 Adobe RGB。因此,您可能希望选择“sRGB”配置文件而不是“通用 RGB 配置文件”(取决于您的 OS X 版本,也可能命名为“sRGB IEC61966-2.1”)。这样图像就已经在 sRGB 颜色空间中了。您只需要说服 Photoshop 保持这种方式(而不是将其转换为 Adobe RGB),然后您就会真正在 Xcode 和 Photoshop 中看到相同的 RGB 值。
Note how changing the color profile makes your display look quite differently? You think the color change is dramatically? Trust me, that is nothing compared to how different monitors may sometimes change the colors. Maybe you can now understand why color correction is so important. So the question is, why are the RGB values so important to you in the first place? Does it really matters, that RGB values are the same, as long as the displayed color is the same?
请注意更改颜色配置文件如何使您的显示器看起来完全不同?你认为颜色变化是戏剧性的?相信我,与不同的显示器有时会改变颜色相比,这算不了什么。也许您现在可以理解为什么色彩校正如此重要了。所以问题是,为什么 RGB 值首先对您如此重要?只要显示的颜色相同,RGB 值是否相同,这真的很重要吗?