本文整理汇总了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;
}
示例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();
}