- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我已经为这个问题苦苦挣扎了很多天,找不到任何解释!
背景:
我正在使用 VC9+MFC 在 Windows 上创建一个颜色管理照片编辑应用程序,并使用WCS(Windows 颜色系统)API 从照片嵌入的颜色转换像素配置文件到监视器的配置文件。
我的显示器已使用“Windows 显示校准”进行校准,并创建了一个名为“CalibratedDisplayProfile-x.icc”的配置文件。
问题:
当我将像素从“ProPhoto RGB”转换为显示器的配置文件时,黑暗区域的颜色发生变化,色调变为绿色。如果目标配置文件是 sRGB,则中间调/高光不会发生这种情况。这是屏幕截图。
测试:
为了简化问题,我写了一些翻译单一颜色的测试代码,但测试结果确实让我很困惑。源颜色“c0”是RGB(0,0,65535),但输出颜色“c1”是RGB(0,0,0)!!函数“CheckColor”失败并出现错误“无效参数”...
怎么会这样?我做错了什么吗?
您可以在此处下载两个配置文件:Color Profiles
非常感谢!
CString strProfilePath = _T("C:\\Windows\\System32\\spool\\drivers\\color\\");
CString strSrcProfile = strProfilePath + _T("ProPhoto.icm");
CString strDstProfile = strProfilePath + _T("CalibratedDisplayProfile-2.icc");
PROFILE pf = {0};
pf.dwType = PROFILE_FILENAME;
pf.pProfileData = (PVOID)strSrcProfile.GetBuffer();
pf.cbDataSize = (strSrcProfile.GetLength() + 1) * sizeof(TCHAR);
HPROFILE hSrcProfile = ::OpenColorProfile( &pf, PROFILE_READ, FILE_SHARE_READ, OPEN_EXISTING );
pf.pProfileData = (PVOID)strDstProfile.GetBuffer();
pf.cbDataSize = (strDstProfile.GetLength() + 1) * sizeof(TCHAR);
HPROFILE hDstProfile = ::OpenColorProfile( &pf, PROFILE_READ, FILE_SHARE_READ, OPEN_EXISTING );
HPROFILE hProfiles[2];
hProfiles[0] = hSrcProfile;
hProfiles[1] = hDstProfile;
DWORD dwIndents[2] = { INTENT_RELATIVE_COLORIMETRIC, INTENT_RELATIVE_COLORIMETRIC };
HTRANSFORM hTransform = ::CreateMultiProfileTransform( hProfiles, 2, dwIndents, 2, BEST_MODE, INDEX_DONT_CARE );
COLOR c0, c1;
c0.rgb.red = 0;
c0.rgb.green = 0;
c0.rgb.blue = 0xffff;
::TranslateColors( hTransform, &c0, 1, COLOR_RGB, &c1, COLOR_RGB );
BYTE btResult = 0;
::CheckColors( hTransform, &c0, 1, COLOR_RGB, &btResult );
::DeleteColorTransform( hTransform );
::CloseColorProfile( hSrcProfile );
::CloseColorProfile( hDstProfile );
最佳答案
我在 Windows 7 SP1 x64 上遇到了与您完全相同的问题。似乎TranslateColors
功能要么被设计破坏,要么不应该以这种方式使用。我认为这是微软的错,因为他们可以在 MSDN 上编写更多 WCS 示例。
但我设法使用 TranslateBitmapBits
解决了问题代替功能。这是一个示例:
bool translateColors(BYTE* srcRgbColors, BYTE* dstRgbColors, DWORD nBytes)
{
BOOL bResult = FALSE;
HPROFILE hSrcProfile = nullptr;
HPROFILE hDstProfile = nullptr;
HTRANSFORM hColorTransform = nullptr;
/* open source sRGB profile */
wchar_t* srcProfilePath = L"sRGB Color Space Profile.icm";
tagPROFILE targetProfile;
targetProfile.dwType = PROFILE_FILENAME;
targetProfile.pProfileData = srcProfilePath;
targetProfile.cbDataSize = sizeof(wchar_t) * (wcslen(srcProfilePath) + 1);
hSrcProfile = OpenColorProfile(&targetProfile, PROFILE_READ, FILE_SHARE_READ, OPEN_EXISTING);
if (nullptr == hSrcProfile) goto EXIT;
/* open destination monitor profile */
wchar_t* dstProfilePath = L"ActiveMonitorProfile.icm";
tagPROFILE destinationProfile;
destinationProfile.dwType = PROFILE_FILENAME;
destinationProfile.pProfileData = dstProfilePath;
destinationProfile.cbDataSize = sizeof(wchar_t) * (wcslen(dstProfilePath) + 1);
hDstProfile = OpenColorProfile(&destinationProfile, PROFILE_READ, FILE_SHARE_READ, OPEN_EXISTING);
if (nullptr == hDstProfile) goto EXIT;
/* create color transform */
DWORD dwIntent = (DWORD)-1;
HPROFILE hProfileList[2] = { hSrcProfile, hDstProfile };
hColorTransform = CreateMultiProfileTransform(
hProfileList,
2,
&dwIntent,
1,
NORMAL_MODE,
INDEX_DONT_CARE
);
if (nullptr == hColorTransform) goto EXIT;
/* transform colors */
DWORD dwWidth = nBytes / 3; // 3 channels per pixel, 8 bits per channel, RGB format
bResult = TranslateBitmapBits(
hColorTransform,
srcRgbColors,
BM_RGBTRIPLETS,
dwWidth, // bitmap width
1, // bitmap height
0,
dstRgbColors,
BM_RGBTRIPLETS,
0,
nullptr,
0
);
EXIT:
/* free resources */
if (nullptr != hColorTransform) {
DeleteColorTransform(hColorTransform);
}
if (nullptr != hSrcProfile) {
CloseColorProfile(hSrcProfile);
}
if (nullptr != hDstProfile) {
CloseColorProfile(hDstProfile);
}
return bResult == FALSE ? false : true;
}
/* example usage */
BYTE srcBitmapData[3];
srcBitmapData[0] = 0x1c;
srcBitmapData[1] = 0x1a;
srcBitmapData[2] = 0x1a;
BYTE dstOutputBitmapData[3];
bool bResult = traslateColors(srcBitmapData, dstOutputBitmapData, 3);
希望这对您有所帮助。
关于c++ - 从 ProPhoto RGB 到显示器配置文件的颜色转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22626380/
我的问题很简单,我相信我只是遗漏了一些小东西,但我不知道它是什么。 我知道如何使用 GraphicsEnvironment、GraphicsConfiguration 和 GraphicsDevice
我目前正在使用一台机器,它的两侧有 2 个显示器。它有一个类似操纵杆的 4 个按钮,用于控制中央机械手的运动。它们都显示相同的屏幕,即显示 1 在第二个屏幕上重复显示。它们都是触摸屏。我希望它们根据用
虽然容器应该具有连接到显示器所需的权限,但我每次都收到此错误: docker exec -it my_container /# rqt QStandardPaths: XDG_RUNTIME_DIR
有没有办法通过 OS X 中的终端获取有关连接的显示器和显示器及其分辨率的信息? 我有一些安装在多台显示器上运行,有时如果没有连接显示器,GFLW 窗口似乎无法打开 - 我想检查显示器是否正确连接,并
本质上,我要完成的是让一个矩形显示器侧向(垂直方向),Android 显示屏处于纵向位置。由于显示器的限制,在显示器本身上旋转显示是不可行的。首先我设置禁用自动旋转,然后将其设置为纵向模式。 adb
我一直在思考一个我想开发的项目的可行性,我不知道是否可行。我想要的是一台标准的 Linux 计算机,当另一台机器通过 USB 插入它时,让它像 USB 显示器一样工作; IE。如果我用标准 USB 线
在 Windows 中,我们有关于我们的 Monitros 的信息——一些唯一的名称和 ID。例如 宏碁 xxx 三星xxx 我对如何在 C# 中获取信息有疑问,因为我知道我们可以从 WMI 获取序列
如何检测笔记本电脑/上网本中插入的显示器并在检测到后启用克隆显示 View ? 非常感谢 最佳答案 您可以使用 EnumDisplaySettingsEx() 这是类似的问题:How do I ena
我有一个使用 AWT 的 Java 程序,我想在 headless 系统上运行它。该程序的显示除了显示统计信息外什么都不做。当程序完成时,它退出。显示屏上没有用户交互。该程序创建了一个我在构建系统中使
我发现了很多关于 Retina Display 的问题,但没有一个答案在服务器端。 我想根据屏幕提供不同的图像,例如(在 PHP 中): if( $is_retina) $thumbnail
我在一个容器中显示多个 DIV,我希望它们在右侧没有更多空间时换行。它在 IOS 上运行良好,但我无法使其在 Android 上运行... -webkit-flex-wrap: wrap; -moz-
我在本地计算机上运行 matlab,并从 Java 调用以下函数(在 tomcat Web 服务器中运行): function df = getFig(file) f = openfig(fi
我想开发一个使用两个屏幕来显示信息的 Android 应用程序。例如:一个屏幕显示应用程序,另一个屏幕显示有关当前应用程序状态的一些信息。 我的问题:android 是否支持两个显示器/屏幕?您将如何
我想编写一个 Python 程序,自动查找和识别连接到我的计算机 (Windows) 的多个显示设备。此外,我还想以编程方式在其中一个设备中启动显示 session (例如幻灯片放映)。知道如何做到这
所以我的 Vista 机器设置为在 10 分钟后关闭显示器。 (注意:机器没有挂起或休眠) 我有一个 .Net 应用程序正在运行,它需要在指定时间“唤醒”系统。作为人类,您只需移动鼠标或按下一个键。我
如何校准 Mac 显示器以匹配 iPhone 的颜色? iPhone 的 Gamma 值是多少? 谢谢。 最佳答案 根据this article ,gamma 为 1.8,这就是 Mac OSX Le
有没有办法用 cocoa 禁用屏幕保护程序和显示器 sleep ? 最佳答案 OSX 10.8 中已弃用 UpdateSystemActivity(OverallAct) 的使用。 现在推荐的方法是通
我正在尝试将 wkhtmltopdf 与 Django、nginx、uwsgi 一起使用 它在使用 manage.py runserver 运行的开发环境中完美运行 但是当与 nginx ans uw
我正在使用 xmonad(具有最小配置,main = xmonad gnomeConfig{ modMask = mod4Mask,terminal = "gnome-terminal"}),我的计算
直接写入帧缓冲区不再有效。无论如何要写入 NDK 中的显示器?我可能会使用 ANativeWindow 但这需要一个现有的表面。有没有更好的办法?或者是在本地创建表面然后使用 ANativeWindo
我是一名优秀的程序员,十分优秀!