屏幕颜色反转在OS X中如何工作? [英] How does on-screen color inversion work in OS X?

查看:315
本文介绍了屏幕颜色反转在OS X中如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是OS X内置的颜色反转功能可以将您的屏幕变成:

This is what OS X's built in color inversion feature can turn your screen into:

它可以反转所有颜色,调整灰度,调整对比度。现在我想建立自己的实现,因此需要专业人士的建议。

It can invert all colors, turn them grayscale, adjust contrast. Now I want to build my own implementation and therefore need a professionals' advice.

无法捕获倒置屏幕让我认为反演是一种调整层,驻留在所有窗口之上,并且简单地不暴露于交互事件。是这样吗?是通过OpenGL库完成的吗?

Inability to capture inverted screen made me thinking that inversion is a sort of an adjustment layer, that resides above all windows and simply is not exposed to the interaction events. Is that so? Is it done via OpenGL libs?

我不研究实际的编码帮助,而是一个解决问题的设计/方法。在我的目标应用程序中,我需要定义输出颜色变化和应用颜色转换规则(输入=>输出)。

I don't look into actual coding help, but rather a design/approach on solving the problem. In my goal app I will need to define output color diapasons and apply color transformation rules (input => output).

提前感谢。

推荐答案

Mac OS做颜色反转的方式是(可能)使用 Quartz Display Services 修改图形卡的gamma表。

The way Mac OS does the color inversion is (probably) by using Quartz Display Services to modify the graphics card's gamma table.

显卡具有两个这样的表,以在组合成最终帧缓冲器之后修改颜色输出。其中一个可以通过应用程序修改,以更改屏幕显示任何RGB值的方式。

Graphics cards have two of these tables to modify color output after composition into the final frame buffer. One of them can be modified by applications to alter the way the screen shows any RGB value.

这里的代码反转显示:

//ApplicationServices includes CoreGraphics
#import <ApplicationServices/ApplicationServices.h>

int main(int argc, const char * argv[])
{
    CGGammaValue table[] = {1, 0};
    CGSetDisplayTransferByTable(CGMainDisplayID(), sizeof(table) / sizeof(table[0]), table, table, table);
    sleep(3);
    return 0;
}

这篇关于屏幕颜色反转在OS X中如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆