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


C# Image.Compare方法代码示例

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


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

示例1: Image_Open

        public void Image_Open()
        {
            Map m = new Map(10, 10);
            Image i1 = new Image(10, 10);
            m.Background = new Color("green");
            m.Render(i1);

            Image i2 = Image.Open(@".\data\10x10green.png");
            Assert.AreEqual(i1.Compare(i2), 0);
        }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:10,代码来源:ImageTests.cs

示例2: Image_FromBytes

        public void Image_FromBytes()
        {
            Map m = new Map(10, 10);
            Image i1 = new Image(10, 10);
            m.Background = new Color("green");
            m.Render(i1);

            byte[] buffer = File.ReadAllBytes(@".\data\10x10green.png");
            Image i2 = Image.FromBytes(buffer);
            Assert.AreEqual(i1.Compare(i2), 0);
        }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:11,代码来源:ImageTests.cs

示例3: Image_Compare_InvalidSize

 public void Image_Compare_InvalidSize()
 {
     Image i1 = new Image(256, 256);
     Image i2 = new Image(512, 512);
     i1.Compare(i2);
     
 }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:7,代码来源:ImageTests.cs

示例4: Image_Compare

        public void Image_Compare()
        {
            Map m1 = new Map(256, 256);
            Map m2 = new Map(256, 256);
            Image i1 = new Image(256, 256);
            Image i2 = new Image(256, 256);
            Assert.AreEqual(i1.Compare(i2), 0);

            i1.SetPixel(0, 0, new Color("white"));
            Assert.AreEqual(i1.Compare(i2), 1);

            m1.Background = new Color("black");
            m1.Render(i1);
            Assert.AreEqual(i1.Width() * i1.Height(), i1.Compare(i2));

            //test options
            m1.Background= new Color(100, 100, 100, 255);
            m1.Render(i1);
            i2 = new Image(256, 256);
            m2.Background = new Color(100,100,100,100);
            m2.Render(i2);
            Dictionary<string, object> options;
            options = new Dictionary<string, object> { { "Alpha", false } };
            Assert.AreEqual(i1.Compare(i2, options), 0);

            m1.Background = new Color(255, 255, 255);
            m1.Render(i1);
            m2.Background = new Color(255, 255, 255);
            m2.Render(i2);
            i2.SetPixel(0, 0, new Color(250, 250, 250));
            options = new Dictionary<string, object> { { "Threshold", 5 } };
            Assert.AreEqual(i1.Compare(i2, options), 0);
        }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:33,代码来源:ImageTests.cs

示例5: VectorTile_Overzoom_Render

        public void VectorTile_Overzoom_Render()
        {
            Mapnik.RegisterDatasource(Path.Combine(Mapnik.Paths["InputPlugins"], "shape.input"));
            Map m = new Map(256, 256);
            m.Load(@".\data\layer.xml");

            m.ZoomToBox(-20037508.34, -20037508.34, 20037508.34, 20037508.34);
            VectorTile v1 = new VectorTile(0, 0, 0, 256, 256);
            m.Render(v1);

            m.ZoomToBox(-20037508.34, 0, 0, 20037508.34);
            VectorTile v2 = new VectorTile(1, 0, 0, 256, 256);
            m.Render(v2);

            Map renderMap = new Map(256, 256);
            renderMap.Load(@".\data\style.xml");
            Image i1 = new Image(256, 256);
            Image i2 = new Image(256, 256);

            Dictionary<string, object> options = new Dictionary<string, object>();
            options["Z"] = 1;

            v1.Render(renderMap, i1, options);
            v2.Render(renderMap, i2);

            //Small diff showing up between images 
            Assert.IsTrue(i1.Compare(i2)-500 < 0);
   
        }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:29,代码来源:VectorTileTests.cs

示例6: VectorTile_Render_Image

        public void VectorTile_Render_Image()
        {
            Mapnik.RegisterDatasource(Path.Combine(Mapnik.Paths["InputPlugins"], "shape.input"));
            Map m = new Map(256, 256);
            m.Load(@".\data\layer.xml");
            m.Extent = new double[] { -20037508.34, 0, 0, 20037508.34 };
            VectorTile v = new VectorTile(1, 0, 0);
            m.Render(v);

            VectorTile v2 = new VectorTile(1, 0, 0);
            v2.SetData(v.GetData());

            Map m2 = new Map(256, 256);
            m2.Load(@".\data\style.xml");
            Image i = new Image(256, 256);
            v2.Render(m2, i);
            Assert.AreEqual(0,i.Compare(Image.Open(@".\data\world_1.0.0.png")));
        }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:18,代码来源:VectorTileTests.cs

示例7: VectorTile_AddImage

        public void VectorTile_AddImage()
        {
            VectorTile v = new VectorTile(1, 0, 0);
            byte[] bytes = File.ReadAllBytes(@".\data\world_1.0.0.png");
            v.AddImage(bytes, "raster");
            Assert.IsFalse(v.Empty());
            Assert.IsTrue(v.Painted());
            CollectionAssert.AreEquivalent(new List<string>() { "raster" }, v.Names().ToList());

            Map m = new Map(256, 256);
            m.Load(@".\data\raster_style.xml");
            Image i = new Image(256, 256);
            v.Render(m, i);
            Assert.AreEqual(0,i.Compare(Image.FromBytes(bytes)));
        }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:15,代码来源:VectorTileTests.cs


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