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


C# WriteableBitmap.FillEllipseCentered方法代码示例

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


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

示例1: PreviewImage_OnLoaded

 private void PreviewImage_OnLoaded(object sender, RoutedEventArgs e)
 {
     _bitmap = BitmapFactory.New(500, 500);
     for (var y = 0; y < 500; ++y)
     {
         for (var x1 = 0; x1 < 250; ++x1)
         {
             _bitmap.SetPixel(x1,y,WriteableBitmapExtensions.ConvertColor(Colors.DodgerBlue));
             _bitmap.SetPixel(x1+250, y, WriteableBitmapExtensions.ConvertColor(Colors.SeaGreen));
         }
     }
     _bitmap.FillEllipseCentered(225, 225, 50, 50, WriteableBitmapExtensions.ConvertColor(0.5, Colors.Red), true);
     //_bitmap.FillRectangle(200, 200, 250, 250, WriteableBitmapExtensions.ConvertColor(0.5, Colors.Red), true);
     PreviewImage.Source = _bitmap;
 }
开发者ID:teichgraf,项目名称:WriteableBitmapEx,代码行数:15,代码来源:MainWindow.xaml.cs

示例2: AdvGamePage

        public AdvGamePage()
        {
            InitializeComponent();

            var fileStream1 = Application.GetResourceStream(new Uri("TestImages/TestingUpper.png", UriKind.Relative));
            var s1 = new BitmapImage();
            using (var stream = fileStream1.Stream)
            {
                s1.SetSource(stream);
            }

            var upper = new WriteableBitmap(s1);

            var fileStream2 = Application.GetResourceStream(new Uri("TestImages/TestingLower.png", UriKind.Relative));
            var s2 = new BitmapImage();
            using (var stream = fileStream2.Stream)
            {
                s2.SetSource(stream);
            }

            var lower = new WriteableBitmap(s2);

            var upperEx = upper.GetBitmapContext();
            var lowerEx = lower.GetBitmapContext();

            UpperImage.Source = upper;
            LowerImage.Source = lower;

            upper.ForEach((x, y, color) =>
                {
                    var lowerColor = lower.GetPixel(x, y);
                    return new Color
                        {
                            R = (byte) (color.R - lowerColor.R),
                            G = (byte) (color.G - lowerColor.G),
                            B = (byte) (color.B - lowerColor.B),
                            A = color.A
                        };
                });
            upper.Invalidate();

            var changesPixels = new List<Point>();

            upper.ForEach((x, y, color) =>
                {
                    if (upper.GetPixel(x, y).R != 0)
                    {
                        lower.FillEllipseCentered(x, y, 10, 10, Colors.Red);
                        changesPixels.Add(new Point(x, y));
                    }

                    return color;
                });
            lower.Invalidate();

            //var indicator = new bool[480, 320];
            var startingPoint = changesPixels[0];
            var newPointToBeInvestigate = new List<Point> { startingPoint };
            changesPixels.Remove(startingPoint);
            //indicator[(int)startingPoint.X, (int)startingPoint.Y] = true;

            System.Diagnostics.Debug.WriteLine(DateTime.Now);

            var i = 0;
            while (newPointToBeInvestigate.Count > 0 && i < newPointToBeInvestigate.Count)
            {
                var newPixels = changesPixels.Where(p => DistanceBetweenPoints(newPointToBeInvestigate[i], p)).ToList();

                foreach (var np in newPixels)
                {
                    changesPixels.Remove(np);
                    newPointToBeInvestigate.Add(np);
                }

                //foreach (var newP in newPixels.Where(newP => !indicator[(int)newP.X, (int)newP.Y]))
                //{
                //    indicator[(int)newP.X, (int)newP.Y] = true;
                //}

                i++;

            }
            System.Diagnostics.Debug.WriteLine(DateTime.Now);

            foreach (var changeP in newPointToBeInvestigate)
            {
                lower.SetPixel((int)changeP.X, (int)changeP.Y, Colors.Green);
            }

            lower.Invalidate();
        }
开发者ID:NBitionDevelopment,项目名称:WindowsPhonePhotoHunt,代码行数:91,代码来源:AdvGamePage.xaml.cs


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