Пример #1
0
    public static void UsingColors()
    {
      using (MagickImage image = new MagickImage(SampleFiles.SnakewarePng))
      {
        image.TransparentChroma(Color.Black, Color.Blue);
        image.BackgroundColor = new ColorMono(true);

        // Q16 (Blue):
        image.TransparentChroma(new MagickColor(0, 0, 0), new MagickColor(0, 0, 65535));
        image.TransparentChroma(new ColorRGB(0, 0, 0), new ColorRGB(0, 0, 65535));
        image.BackgroundColor = new MagickColor("#00f");
        image.BackgroundColor = new MagickColor("#0000ff");
        image.BackgroundColor = new MagickColor("#00000000ffff");

        // With transparency (Red):
        image.BackgroundColor = new MagickColor(0, 0, 65535, 32767);
        image.BackgroundColor = new MagickColor("#0000ff80");

        // Q8 (Green):
        image.TransparentChroma(new MagickColor(0, 0, 0), new MagickColor(0, 255, 0));
        image.TransparentChroma(new ColorRGB(0, 0, 0), new ColorRGB(0, 255, 0));
        image.BackgroundColor = new MagickColor("#0f0");
        image.BackgroundColor = new MagickColor("#00ff00");
      }
    }
Пример #2
0
 private void ExecuteTransparentChroma(XmlElement element, MagickImage image)
 {
   MagickColor colorLow_ = Variables.GetValue<MagickColor>(element, "colorLow");
   MagickColor colorHigh_ = Variables.GetValue<MagickColor>(element, "colorHigh");
   image.TransparentChroma(colorLow_, colorHigh_);
 }
Пример #3
0
    public void Test_TransparentChroma()
    {
      using (MagickImage image = new MagickImage(Files.TestPNG))
      {
        image.TransparentChroma(MagickColors.Black, MagickColors.WhiteSmoke);

        ColorAssert.AreEqual(new MagickColor("#3962396239620000"), image, 50, 50);
        ColorAssert.AreEqual(new MagickColor("#0000"), image, 32, 80);
        ColorAssert.AreEqual(new MagickColor("#f6def6def6deffff"), image, 132, 42);
        ColorAssert.AreEqual(new MagickColor("#0000808000000000"), image, 74, 79);
      }

      using (MagickImage image = new MagickImage(Files.TestPNG))
      {
        image.InverseTransparentChroma(MagickColors.Black, MagickColors.WhiteSmoke);

        ColorAssert.AreEqual(new MagickColor("#396239623962ffff"), image, 50, 50);
        ColorAssert.AreEqual(new MagickColor("#000f"), image, 32, 80);
        ColorAssert.AreEqual(new MagickColor("#f6def6def6de0000"), image, 132, 42);
        ColorAssert.AreEqual(new MagickColor("#000080800000ffff"), image, 74, 79);
      }
    }