当前位置: 首页>>代码示例>>C#>>正文


C# RGB.Set方法代码示例

本文整理汇总了C#中RGB.Set方法的典型用法代码示例。如果您正苦于以下问题:C# RGB.Set方法的具体用法?C# RGB.Set怎么用?C# RGB.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RGB的用法示例。


在下文中一共展示了RGB.Set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Window_Loaded

        private void Window_Loaded(object sender, RoutedEventArgs eventArgs)
        {
            #if DISP_ASTAR_LSTAR
            // a*L*平面。L軸は0~100なので
            float originOffsetX = 400;
            float originOffsetY = 800;

            labelAxisA.Content = "a*→";
            labelAxisA.Margin = new Thickness(700, 200, 0, 0);
            labelAxisB.Content = "↑L*";
            labelAxisB.Margin = new Thickness(400, 100, 0, 0);
            labelOrigin.Margin = new Thickness(400, 766, 0, 0);
            #else
            // a*b*平面
            float originOffsetX = 400;
            float originOffsetY = 400;
            labelAxisA.Content = "a*";
            labelAxisA.Margin = new Thickness(763, 400, 0, 0);
            labelAxisB.Content = "b*";
            labelAxisB.Margin = new Thickness(400, 6, 0, 0);
            labelOrigin.Margin = new Thickness(400, 400, 0, 0);
            #endif

            rectangleV.Height = canvas1.Height;
            rectangleV.Margin = new Thickness(originOffsetX, 0, 0, 0);

            rectangleH.Width = canvas1.Width;
            rectangleH.Margin = new Thickness(0, originOffsetY, 0, 0);

            var rgbHash = new HashSet<int>();

            var colors = new List<ColorPatch>[SEGMENT_NUM];
            for (int i = 0; i < SEGMENT_NUM; ++i) {
                colors[i] = new List<ColorPatch>();
            }
            for (int i = 0; i < colorTable.Length / 3; ++i) {
                byte r = colorTable[i * 3];
                byte g = colorTable[i * 3 + 1];
                byte b = colorTable[i * 3 + 2];
                var c = Color.FromRgb(r, g, b);

                RGB rgb = new RGB();
                rgb.Set(r, g, b);
                LabStar lab = XYZtoLabStar(RGBtoXYZ(rgb));

                var cp = new ColorPatch();
                cp.id = i;
                cp.rgb = rgb;
                cp.lab = lab;

                colors[i / COLOR_NUM_PER_SEGMENT].Add(cp);

                Ellipse e = new Ellipse();
                e.Fill = new SolidColorBrush(c);
                e.Height = 16;
                e.Width = 16;

            #if DISP_ASTAR_LSTAR
                // a*L*平面
                var pos = new Thickness((lab.a) * 10 + originOffsetX, (-lab.L) * 10 + originOffsetY, 0, 0);
            #else
                // a*b*平面
                var pos = new Thickness((lab.a) * 10 + originOffsetX, (-lab.b) * 10 + originOffsetY, 0, 0);
            #endif

                e.Margin = pos;
                canvas1.Children.Add(e);
                Canvas.SetZIndex(e, -1);

                bool collision = false;
                int hashValue = r * 65536 + g * 256 + b;
                if (rgbHash.Contains(hashValue)) {
                    collision = true;
                }
                rgbHash.Add(hashValue);

                Label l = new Label();
                l.Content = string.Format("{0}", i + 1);
                l.FontSize = 8;
                l.Foreground = new SolidColorBrush(Colors.White);

                l.Margin = pos;
                if (collision) {
                    l.Margin = new Thickness(pos.Left, pos.Top + l.FontSize, pos.Right, pos.Bottom);
                }

                canvas1.Children.Add(l);
            }

            for (int segment = 0; segment < SEGMENT_NUM; ++segment) {
                for (int i = 0; i < COLOR_NUM_PER_SEGMENT; ++i) {
                    var cpFrom = colors[segment].ElementAt(i);
                    var cpSort = new Dictionary<float, ColorPatch>();
                    for (int j = 0; j < COLOR_NUM_PER_SEGMENT; ++j) {
                        if (i == j) {
                            continue;
                        }
                        var cpTo = colors[segment].ElementAt(j);
                        cpSort.Add(cpFrom.lab.DistanceSquared(cpTo.lab), cpTo);
                    }
//.........这里部分代码省略.........
开发者ID:kekyo,项目名称:PlayPcmWin,代码行数:101,代码来源:MainWindow.xaml.cs


注:本文中的RGB.Set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。