Exemplo n.º 1
0
        /**
         * Use this method only for double of float transfer types.
         * Extracts scaling data from the color space signature
         * and other tags, stored in the profile
         * @param pf - ICC profile
         */
        public void loadScalingData(java.awt.color.ICC_Profile pf)
        {
            // Supposing double or float transfer type
            isTTypeIntegral = false;

            nColorChannels = pf.getNumComponents();

            // Get min/max values directly from the profile
            // Very much like fillMinMaxValues in ICC_ColorSpace
            float[] maxValues = new float[nColorChannels];
            float[] minValues = new float[nColorChannels];

            switch (pf.getColorSpaceType())
            {
                case java.awt.color.ColorSpace.TYPE_XYZ:
                    minValues[0] = 0;
                    minValues[1] = 0;
                    minValues[2] = 0;
                    maxValues[0] = MAX_XYZ;
                    maxValues[1] = MAX_XYZ;
                    maxValues[2] = MAX_XYZ;
                    break;
                case java.awt.color.ColorSpace.TYPE_Lab:
                    minValues[0] = 0;
                    minValues[1] = -128;
                    minValues[2] = -128;
                    maxValues[0] = 100;
                    maxValues[1] = 127;
                    maxValues[2] = 127;
                    break;
                default:
                    for (int i = 0; i < nColorChannels; i++)
                    {
                        minValues[i] = 0;
                        maxValues[i] = 1;
                    }
                    break;
            }

            channelMinValues = minValues;
            channelMulipliers = new float[nColorChannels];
            invChannelMulipliers = new float[nColorChannels];

            for (int i = 0; i < nColorChannels; i++)
            {
                channelMulipliers[i] =
                    MAX_SHORT / (maxValues[i] - channelMinValues[i]);

                invChannelMulipliers[i] =
                    (maxValues[i] - channelMinValues[i]) / MAX_SHORT;
            }
        }