Philip's Hue - 白光调色板 - iOS实现

时间:2015-11-09 11:51:32

标签: ios objective-c color-picker philips-hue

https://github.com/InfinitApps/InfColorPicker/blob/master/InfColorPicker/InfHSBSupport.m

的帮助下,为Philip的Hue灯实现了彩色灯光调色板

enter image description here

UInt8 r_s = (UInt8) ((1.0f - r) * 255);
UInt8 g_s = (UInt8) ((1.0f - g) * 255);
UInt8 b_s = (UInt8) ((1.0f - b) * 255);

for (int s = 0; s < 256; ++s) {
    register UInt8* ptr = dataPtr;

    register unsigned int r_hs = 255 - blend(s, r_s);
    register unsigned int g_hs = 255 - blend(s, g_s);
    register unsigned int b_hs = 255 - blend(s, b_s);

    for (register int v = 255; v >= 0; --v) {
        ptr[0] = (UInt8) (v * b_hs >> 8);
        ptr[1] = (UInt8) (v * g_hs >> 8);
        ptr[2] = (UInt8) (v * r_hs >> 8);

        // Really, these should all be of the form used in blend(),
        // which does a divide by 255. However, integer divide is
        // implemented in software on ARM, so a divide by 256
        // (done as a bit shift) will be *nearly* the same value,
        // and is faster. The more-accurate versions would look like:
        //  ptr[0] = blend(v, b_hs);

        ptr += rowBytes;
    }

    dataPtr += 4;
}

有没有办法为Philip的色调光实现白色调色板,如下图所示?

enter image description here

0 个答案:

没有答案