public void Test_Frame()
    {
      int frameSize = 100;

      using (MagickImage image = new MagickImage(Files.MagickNETIconPNG))
      {
        int expectedWidth = frameSize + image.Width + frameSize;
        int expectedHeight = frameSize + image.Height + frameSize;

        image.Frame(frameSize, frameSize);
        Assert.AreEqual(expectedWidth, image.Width);
        Assert.AreEqual(expectedHeight, image.Height);
      }

      using (MagickImage image = new MagickImage(Files.MagickNETIconPNG))
      {
        int expectedWidth = frameSize + image.Width + frameSize;
        int expectedHeight = frameSize + image.Height + frameSize;

        image.Frame(frameSize, frameSize, 6, 6);
        Assert.AreEqual(expectedWidth, image.Width);
        Assert.AreEqual(expectedHeight, image.Height);
      }

      ExceptionAssert.Throws<MagickOptionErrorException>(delegate ()
      {
        using (MagickImage image = new MagickImage(Files.MagickNETIconPNG))
        {
          image.Frame(6, 6, frameSize, frameSize);
        }
      });
    }
Beispiel #2
0
 private void ExecuteFrame(XmlElement element, MagickImage image)
 {
   Hashtable arguments = new Hashtable();
   foreach (XmlAttribute attribute in element.Attributes)
   {
     if (attribute.Name == "geometry")
       arguments["geometry"] = Variables.GetValue<MagickGeometry>(attribute);
     else if (attribute.Name == "height")
       arguments["height"] = Variables.GetValue<Int32>(attribute);
     else if (attribute.Name == "innerBevel")
       arguments["innerBevel"] = Variables.GetValue<Int32>(attribute);
     else if (attribute.Name == "outerBevel")
       arguments["outerBevel"] = Variables.GetValue<Int32>(attribute);
     else if (attribute.Name == "width")
       arguments["width"] = Variables.GetValue<Int32>(attribute);
   }
   if (arguments.Count == 0)
     image.Frame();
   else if (OnlyContains(arguments, "geometry"))
     image.Frame((MagickGeometry)arguments["geometry"]);
   else if (OnlyContains(arguments, "width", "height"))
     image.Frame((Int32)arguments["width"], (Int32)arguments["height"]);
   else if (OnlyContains(arguments, "width", "height", "innerBevel", "outerBevel"))
     image.Frame((Int32)arguments["width"], (Int32)arguments["height"], (Int32)arguments["innerBevel"], (Int32)arguments["outerBevel"]);
   else
     throw new ArgumentException("Invalid argument combination for 'frame', allowed combinations are: [] [geometry] [width, height] [width, height, innerBevel, outerBevel]");
 }
    public void Test_AlphaColor()
    {
      using (MagickImage image = new MagickImage(Files.Builtin.Logo))
      {
        image.AlphaColor = MagickColors.PaleGoldenrod;
        image.Frame();

        ColorAssert.AreEqual(MagickColors.PaleGoldenrod, image, 10, 10);
        ColorAssert.AreEqual(MagickColors.PaleGoldenrod, image, 680, 520);
      }
    }