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


C# BitmapImage.GetPixelColor方法代码示例

本文整理汇总了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");
        }
开发者ID:rmarinho,项目名称:PixelPicker,代码行数:17,代码来源:GetPixelExtensionTest.cs

示例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");
        }
开发者ID:rmarinho,项目名称:PixelPicker,代码行数:22,代码来源:GetPixelExtensionTest.cs


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