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


C# MagickImage.Extent方法代码示例

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


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

示例1: Test_BorderColor

    public void Test_BorderColor()
    {
      using (MagickImage image = new MagickImage(MagickColors.MediumTurquoise, 10, 10))
      {
        ColorAssert.AreEqual(new MagickColor("#df"), image.Settings.BorderColor);

        image.Settings.FillColor = MagickColors.Beige;
        image.Settings.BorderColor = MagickColors.MediumTurquoise;
        image.Extent(20, 20, Gravity.Center, MagickColors.Aqua);
        image.Draw(new DrawableAlpha(0, 0, PaintMethod.FillToBorder));

        ColorAssert.AreEqual(MagickColors.Beige, image, 0, 0);
        ColorAssert.AreEqual(MagickColors.MediumTurquoise, image, 10, 10);
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:15,代码来源:MagickSettingsTests.cs

示例2: ExecuteExtent

 private void ExecuteExtent(XmlElement element, MagickImage image)
 {
   Hashtable arguments = new Hashtable();
   foreach (XmlAttribute attribute in element.Attributes)
   {
     if (attribute.Name == "backgroundColor")
       arguments["backgroundColor"] = Variables.GetValue<MagickColor>(attribute);
     else if (attribute.Name == "geometry")
       arguments["geometry"] = Variables.GetValue<MagickGeometry>(attribute);
     else if (attribute.Name == "gravity")
       arguments["gravity"] = Variables.GetValue<Gravity>(attribute);
     else if (attribute.Name == "height")
       arguments["height"] = Variables.GetValue<Int32>(attribute);
     else if (attribute.Name == "width")
       arguments["width"] = Variables.GetValue<Int32>(attribute);
     else if (attribute.Name == "x")
       arguments["x"] = Variables.GetValue<Int32>(attribute);
     else if (attribute.Name == "y")
       arguments["y"] = Variables.GetValue<Int32>(attribute);
   }
   if (OnlyContains(arguments, "geometry"))
     image.Extent((MagickGeometry)arguments["geometry"]);
   else if (OnlyContains(arguments, "geometry", "backgroundColor"))
     image.Extent((MagickGeometry)arguments["geometry"], (MagickColor)arguments["backgroundColor"]);
   else if (OnlyContains(arguments, "geometry", "gravity"))
     image.Extent((MagickGeometry)arguments["geometry"], (Gravity)arguments["gravity"]);
   else if (OnlyContains(arguments, "geometry", "gravity", "backgroundColor"))
     image.Extent((MagickGeometry)arguments["geometry"], (Gravity)arguments["gravity"], (MagickColor)arguments["backgroundColor"]);
   else if (OnlyContains(arguments, "width", "height"))
     image.Extent((Int32)arguments["width"], (Int32)arguments["height"]);
   else if (OnlyContains(arguments, "width", "height", "backgroundColor"))
     image.Extent((Int32)arguments["width"], (Int32)arguments["height"], (MagickColor)arguments["backgroundColor"]);
   else if (OnlyContains(arguments, "width", "height", "gravity"))
     image.Extent((Int32)arguments["width"], (Int32)arguments["height"], (Gravity)arguments["gravity"]);
   else if (OnlyContains(arguments, "width", "height", "gravity", "backgroundColor"))
     image.Extent((Int32)arguments["width"], (Int32)arguments["height"], (Gravity)arguments["gravity"], (MagickColor)arguments["backgroundColor"]);
   else if (OnlyContains(arguments, "x", "y", "width", "height"))
     image.Extent((Int32)arguments["x"], (Int32)arguments["y"], (Int32)arguments["width"], (Int32)arguments["height"]);
   else
     throw new ArgumentException("Invalid argument combination for 'extent', allowed combinations are: [geometry] [geometry, backgroundColor] [geometry, gravity] [geometry, gravity, backgroundColor] [width, height] [width, height, backgroundColor] [width, height, gravity] [width, height, gravity, backgroundColor] [x, y, width, height]");
 }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:41,代码来源:MagickImage.cs

示例3: Test_Extent

    public void Test_Extent()
    {
      using (MagickImage image = new MagickImage())
      {
        image.Read(Files.RedPNG);
        image.Resize(new MagickGeometry(100, 100));
        Assert.AreEqual(100, image.Width);
        Assert.AreEqual(33, image.Height);

        image.BackgroundColor = MagickColor.Transparent;
        image.Extent(100, 100, Gravity.Center);
        Assert.AreEqual(100, image.Width);
        Assert.AreEqual(100, image.Height);

        Test_Pixel_Equal(image, 0, 0, MagickColor.Transparent);
      }
    }
开发者ID:marinehero,项目名称:Magick.NET,代码行数:17,代码来源:MagickImageTests.cs

示例4: Test_Composite_ChangeMask

    public void Test_Composite_ChangeMask()
    {
      using (MagickImage background = new MagickImage("xc:red", 100, 100))
      {
        background.BackgroundColor = Color.White;
        background.Extent(200, 100);

        IDrawable[] drawables = new IDrawable[]
        {
          new DrawablePointSize(50),
          new DrawableText(135, 70, "X")
        };

        using (MagickImage image = background.Clone())
        {
          image.Draw(drawables);
          image.Composite(background, Gravity.Center, CompositeOperator.ChangeMask);

          using (MagickImage result = new MagickImage(MagickColor.Transparent, 200, 100))
          {
            result.Draw(drawables);
            Assert.AreEqual(0.073, result.Compare(image, ErrorMetric.RootMeanSquared), 0.001);
          }
        }
      }
    }
开发者ID:marinehero,项目名称:Magick.NET,代码行数:26,代码来源:MagickImageTests.cs

示例5: Test_Trim

    public void Test_Trim()
    {
      using (MagickImage image = new MagickImage("xc:fuchsia", 50, 50))
      {
        ColorAssert.AreEqual(MagickColors.Fuchsia, image, 0, 0);
        ColorAssert.AreEqual(MagickColors.Fuchsia, image, 49, 49);

        image.Extent(100, 60, Gravity.Center, MagickColors.Gold);

        Assert.AreEqual(100, image.Width);
        Assert.AreEqual(60, image.Height);
        ColorAssert.AreEqual(MagickColors.Gold, image, 0, 0);
        ColorAssert.AreEqual(MagickColors.Fuchsia, image, 50, 30);

        image.Trim();

        Assert.AreEqual(50, image.Width);
        Assert.AreEqual(50, image.Height);
        ColorAssert.AreEqual(MagickColors.Fuchsia, image, 0, 0);
        ColorAssert.AreEqual(MagickColors.Fuchsia, image, 49, 49);
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:22,代码来源:MagickImageTests.cs

示例6: Test_Extent

    public void Test_Extent()
    {
      using (MagickImage image = new MagickImage())
      {
        image.Read(Files.RedPNG);
        image.Resize(new MagickGeometry(100, 100));
        Assert.AreEqual(100, image.Width);
        Assert.AreEqual(33, image.Height);

        image.BackgroundColor = MagickColors.Transparent;
        image.Extent(100, 100, Gravity.Center);
        Assert.AreEqual(100, image.Width);
        Assert.AreEqual(100, image.Height);

        ColorAssert.AreEqual(MagickColors.Transparent, image, 0, 0);
        ColorAssert.AreEqual(MagickColors.Red, image, 15, 50);
        ColorAssert.AreEqual(new MagickColor(0, 0, 0, 0), image, 35, 35);
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:19,代码来源:MagickImageTests.cs


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