How does on-screen color inversion work in OS X?

后端 未结 4 2159
感动是毒
感动是毒 2021-02-06 13:24

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

\"enter

4条回答
  •  甜味超标
    2021-02-06 13:48

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

    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.

    Here's code to invert the display:

    //ApplicationServices includes CoreGraphics
    #import 
    
    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;
    }
    

提交回复
热议问题