PHP - 如何将RGB颜色转换为CIE 1931颜色规范

时间:2013-11-29 10:19:10

标签: javascript php color-scheme philips-hue

我正在创建自己的基于PHP的应用程序,我想将RGB颜色更改为CIE 1931的xy格式。

如何将RGB颜色规格转换为CIE颜色空间?

2 个答案:

答案 0 :(得分:6)

首先用变换矩阵计算X,Y和Z,然后对结果进行归一化

X = 0.4124*R + 0.3576*G + 0.1805*B
Y = 0.2126*R + 0.7152*G + 0.0722*B
Z = 0.0193*R + 0.1192*G + 0.9505*B

规格化:

x = X / (X + Y + Z)
y = Y / (X + Y + Z)

答案 1 :(得分:0)

这是我的Javascript版本。它应该对你有所帮助;)

Try this simple code in your activity:

 @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        // Checks the orientation of the screen
        if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
            iv.setRotation(90f);
            Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();
        } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
            iv.setRotation(0);
            Toast.makeText(this, "portrait", Toast.LENGTH_SHORT).show();
        }
    }

and following line in your manifest in activity tag
            android:configChanges="orientation|keyboardHidden|screenSize"