示例#1
0
 private void ExecuteOpaque(XmlElement element, MagickImage image)
 {
   MagickColor target_ = Variables.GetValue<MagickColor>(element, "target");
   MagickColor fill_ = Variables.GetValue<MagickColor>(element, "fill");
   image.Opaque(target_, fill_);
 }
示例#2
0
    public void Test_Opaque()
    {
      using (MagickImage image = new MagickImage(Color.Red, 10, 10))
      {
        Test_Pixel_Equal(image, 0, 0, Color.Red);

        image.Opaque(Color.Red, Color.Yellow);
        Test_Pixel_Equal(image, 0, 0, Color.Yellow);

        image.InverseOpaque(Color.Yellow, Color.Red);
        Test_Pixel_Equal(image, 0, 0, Color.Yellow);

        image.InverseOpaque(Color.Red, Color.Red);
        Test_Pixel_Equal(image, 0, 0, Color.Red);
      }
    }
示例#3
0
    public void Test_IsOpaque()
    {
      using (MagickImage image = new MagickImage(Files.MagickNETIconPNG))
      {
        Assert.IsFalse(image.IsOpaque);
        image.ColorAlpha(Color.Purple);
        Assert.IsTrue(image.IsOpaque);
      }

      using (MagickImage image = new MagickImage(Files.Builtin.Logo))
      {
        Assert.IsTrue(image.IsOpaque);
        image.Opaque(Color.White, MagickColor.Transparent);
        Assert.IsFalse(image.IsOpaque);
      }
    }
示例#4
0
    public void Test_Compare()
    {
      MagickImage first = new MagickImage(Files.ImageMagickJPG);

      ExceptionAssert.Throws<ArgumentNullException>(delegate ()
      {
        first.Compare(null);
      });

      MagickImage second = first.Clone();

      MagickErrorInfo same = first.Compare(second);
      Assert.IsNotNull(same);
      Assert.AreEqual(0, same.MeanErrorPerPixel);

      double distortion = first.Compare(second, ErrorMetric.Absolute);
      Assert.AreEqual(0, distortion);

      first.Threshold(new Percentage(50));
      MagickErrorInfo different = first.Compare(second);
      Assert.IsNotNull(different);
      Assert.AreNotEqual(0, different.MeanErrorPerPixel);

      distortion = first.Compare(second, ErrorMetric.Absolute);
      Assert.AreNotEqual(0, distortion);

      MagickImage difference = new MagickImage();
      distortion = first.Compare(second, ErrorMetric.RootMeanSquared, difference);
      Assert.AreNotEqual(0, distortion);
      Assert.AreNotEqual(first, difference);
      Assert.AreNotEqual(second, difference);

      second.Dispose();

      first.Opaque(MagickColors.Black, MagickColors.Green);
      first.Opaque(MagickColors.White, MagickColors.Green);

      second = first.Clone();
      second.FloodFill(MagickColors.Gray, 0, 0);

      distortion = first.Compare(second, ErrorMetric.Absolute, Channels.Green);
      Assert.AreEqual(0, distortion);

      distortion = first.Compare(second, ErrorMetric.Absolute, Channels.Red);
      Assert.AreNotEqual(0, distortion);
    }
示例#5
0
    public void Test_Tile()
    {
      using (MagickImage image = new MagickImage(Files.Builtin.Logo))
      {
        using (MagickImage checkerboard = new MagickImage(Files.Patterns.Checkerboard))
        {
          image.Opaque(MagickColors.White, MagickColors.Transparent);
          image.Tile(checkerboard, CompositeOperator.DstOver);

          ColorAssert.AreEqual(new MagickColor("#66"), image, 578, 260);
        }
      }
    }
示例#6
0
    public void Test_Opaque()
    {
      using (MagickImage image = new MagickImage(MagickColors.Red, 10, 10))
      {
        ColorAssert.AreEqual(MagickColors.Red, image, 0, 0);

        image.Opaque(MagickColors.Red, MagickColors.Yellow);
        ColorAssert.AreEqual(MagickColors.Yellow, image, 0, 0);

        image.InverseOpaque(MagickColors.Yellow, MagickColors.Red);
        ColorAssert.AreEqual(MagickColors.Yellow, image, 0, 0);

        image.InverseOpaque(MagickColors.Red, MagickColors.Red);
        ColorAssert.AreEqual(MagickColors.Red, image, 0, 0);
      }
    }