Exemplo n.º 1
0
 public void Test_BrightnessContrast()
 {
   using (MagickImage image = new MagickImage(Files.Builtin.Wizard))
   {
     ColorAssert.AreNotEqual(MagickColors.White, image, 340, 295);
     image.BrightnessContrast(new Percentage(50), new Percentage(50));
     image.Clamp();
     ColorAssert.AreEqual(MagickColors.White, image, 340, 295);
   }
 }
Exemplo n.º 2
0
 private void ExecuteClamp(XmlElement element, MagickImage image)
 {
   Hashtable arguments = new Hashtable();
   foreach (XmlAttribute attribute in element.Attributes)
   {
     arguments[attribute.Name] = Variables.GetValue<Channels>(attribute);
   }
   if (arguments.Count == 0)
     image.Clamp();
   else if (OnlyContains(arguments, "channels"))
     image.Clamp((Channels)arguments["channels"]);
   else
     throw new ArgumentException("Invalid argument combination for 'clamp', allowed combinations are: [] [channels]");
 }
Exemplo n.º 3
0
    public void Test_Tint()
    {
      using (MagickImage image = new MagickImage(Files.Builtin.Logo))
      {
        image.Settings.FillColor = MagickColors.Gold;
        image.Tint("1x2");
        image.Clamp();

        ColorAssert.AreEqual(new MagickColor("#dee500000000"), image, 400, 205);
        ColorAssert.AreEqual(MagickColors.Black, image, 400, 380);
      }
    }
Exemplo n.º 4
0
    public void Test_BlueShift()
    {
      using (MagickImage image = new MagickImage(Files.Builtin.Logo))
      {
        ColorAssert.AreNotEqual(MagickColors.White, image, 180, 80);

        image.BlueShift(2);

#if Q16HDRI
        ColorAssert.AreNotEqual(MagickColors.White, image, 180, 80);
        image.Clamp();
#endif

        ColorAssert.AreEqual(MagickColors.White, image, 180, 80);

#if Q8 || Q16
        ColorAssert.AreEqual(new MagickColor("#ac2cb333c848"), image, 350, 265);
#elif Q16HDRI
        ColorAssert.AreEqual(new MagickColor("#ac2cb333c848"), image, 350, 265);
#else
#error Not implemented!
#endif
      }
    }
Exemplo n.º 5
0
    public void Test_Sharpen()
    {
      using (MagickImage image = new MagickImage(Files.NoisePNG))
      {
        image.Sharpen(10, 20);
        image.Clamp();

        using (MagickImage original = new MagickImage(Files.NoisePNG))
        {
          Assert.AreEqual(0.06675, image.Compare(original, ErrorMetric.RootMeanSquared), 0.00001);
        }
      }
    }
Exemplo n.º 6
0
    public void Test_Polaroid()
    {
      using (MagickImage image = new MagickImage(Files.MagickNETIconPNG))
      {
        image.BorderColor = MagickColors.Red;
        image.BackgroundColor = MagickColors.Fuchsia;
        image.Settings.FontPointsize = 20;
        image.Polaroid("Magick.NET", 10, PixelInterpolateMethod.Bilinear);
        image.Clamp();

        ColorAssert.AreEqual(MagickColors.Black, image, 103, 162);
        ColorAssert.AreEqual(MagickColors.Red, image, 99, 97);
#if Q8
        ColorAssert.AreEqual(new MagickColor("#ff00ffbc"), image, 146, 194);
#elif Q16 || Q16HDRI
        ColorAssert.AreEqual(new MagickColor("#ffff0000ffffbbe5"), image, 146, 194);
#else
#error Not implemented!
#endif
      }
    }
Exemplo n.º 7
0
    public void Test_LocalContrast()
    {
      using (MagickImage image = new MagickImage(Files.NoisePNG))
      {
        image.LocalContrast(5.0, (Percentage)75);
        image.Clamp();

        ColorAssert.AreEqual(MagickColors.Black, image, 81, 28);
        ColorAssert.AreEqual(MagickColors.Black, image, 245, 181);
        ColorAssert.AreEqual(MagickColors.White, image, 200, 135);
        ColorAssert.AreEqual(MagickColors.White, image, 200, 135);
      }
    }
Exemplo n.º 8
0
    public void Test_Edge()
    {
      using (MagickImage image = new MagickImage(Files.Builtin.Logo))
      {
        ColorAssert.AreNotEqual(MagickColors.Black, image, 400, 295);
        ColorAssert.AreNotEqual(MagickColors.Blue, image, 455, 126);

        image.Edge(2);
        image.Clamp();

        ColorAssert.AreEqual(MagickColors.Black, image, 400, 295);
        ColorAssert.AreEqual(MagickColors.Blue, image, 455, 126);
      }
    }
Exemplo n.º 9
0
    public void Test_Distort()
    {
      using (MagickImage image = new MagickImage(Files.MagickNETIconPNG))
      {
        ExceptionAssert.Throws<ArgumentNullException>(delegate ()
        {
          image.Distort(DistortMethod.Perspective, null);
        });

        ExceptionAssert.Throws<ArgumentException>(delegate ()
        {
          image.Distort(DistortMethod.Perspective, new double[] { });
        });

        image.BackgroundColor = MagickColors.Cornsilk;
        image.VirtualPixelMethod = VirtualPixelMethod.Background;
        image.Distort(DistortMethod.Perspective, new double[] { 0, 0, 0, 0, 0, 90, 0, 90, 90, 0, 90, 25, 90, 90, 90, 65 });
        image.Clamp();

        ColorAssert.AreEqual(new MagickColor("#0000"), image, 1, 64);
        ColorAssert.AreEqual(MagickColors.Cornsilk, image, 104, 50);
        ColorAssert.AreEqual(new MagickColor("#aa67e157f9da"), image, 66, 62);
      }
    }