ColorSpace.ColorVector.IsCanonical C# (CSharp) Method

IsCanonical() public method

public IsCanonical ( ) : bool
return bool
        public bool IsCanonical()
        {
            return Component1 >= 0.0 && Component1 <= 1.0 &&
                   Component2 >= 0.0 && Component2 <= 1.0 &&
                   Component3 >= 0.0 && Component3 <= 1.0;
        }

Usage Example

示例#1
0
文件: Program.cs 项目: EFanZh/EFanZh
        private static void GenerateXyyColors(Bitmap bitmap, double bigY)
        {
            double width = bitmap.Width - 1;
            double height = bitmap.Width - 1;

            for (int y = 0; y < bitmap.Height; y++)
            {
                for (int x = 0; x <= y; x++)
                {
                    double cx = (x + 0.5) / width;
                    double cy = 1.0 - (y + 0.5) / height;

                    ColorVector colorVector = new ColorVector()
                    {
                        Component1 = cx,
                        Component2 = cy,
                        Component3 = bigY
                    };

                    colorVector.ConvertXyyToLinearSRgb();

                    if (colorVector.IsCanonical())
                    {
                        colorVector.ConvertLinearSRgbToSRgb();

                        bitmap.SetPixel(x, y, colorVector.ToColor());
                    }
                }
            }
        }