本文整理汇总了C#中System.Windows.Media.Imaging.BitmapImage.GetPixelColor方法的典型用法代码示例。如果您正苦于以下问题:C# BitmapImage.GetPixelColor方法的具体用法?C# BitmapImage.GetPixelColor怎么用?C# BitmapImage.GetPixelColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Imaging.BitmapImage
的用法示例。
在下文中一共展示了BitmapImage.GetPixelColor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPixelColorGreenCorner
public void GetPixelColorGreenCorner()
{
int x = 1;
int y = 1;
int a = 255;
int r = 0;
int g = 255;
int b = 0;
BitmapImage bmp = new BitmapImage(new Uri("testimage.png", UriKind.RelativeOrAbsolute));
var color = bmp.GetPixelColor(x, y);
var pixColor = bmp.GetPixelColorUsingPixelColor(x, y);
Assert.IsTrue(color.R == r, "Red is not good");
Assert.IsTrue(color.G == g, "Green is not good");
Assert.IsTrue(color.B == b, "Blue is not good");
Assert.IsTrue(color.A == a, "Alpha is not good");
}
示例2: GetPixelWithColor
public void GetPixelWithColor()
{
int x = 65;
int y = 43;
int a = 255;
int r = 179;
int g = 47;
int b = 206;
BitmapImage bmp = new BitmapImage(new Uri("default.png", UriKind.RelativeOrAbsolute));
var color = bmp.GetPixelColor(x, y);
var pixColor = bmp.GetPixelColorUsingPixelColor(x, y);
Assert.IsTrue(color.R == r, "Red is not good");
Assert.IsTrue(color.G == g, "Green is not good");
Assert.IsTrue(color.B == b, "Blue is not good");
Assert.IsTrue(color.A == a, "Alpha is not good");
Assert.IsTrue(pixColor.Red == r, "Red PixelColor is not good");
Assert.IsTrue(pixColor.Green == g, "Green PixelColor is not good");
Assert.IsTrue(pixColor.Blue == b, "Blue PixelColor is not good");
Assert.IsTrue(pixColor.Alpha == a, "Alpha PixelColor is not good");
}