public void Test_Combine()
    {
      using (MagickImage rose = new MagickImage(Files.Builtin.Rose))
      {
        using (MagickImageCollection collection = new MagickImageCollection())
        {
          ExceptionAssert.Throws<InvalidOperationException>(delegate ()
          {
            collection.Combine();
          });

          collection.AddRange(rose.Separate(Channels.RGB));

          Assert.AreEqual(3, collection.Count);

          MagickImage image = collection.Merge();
          Assert.AreNotEqual(rose.TotalColors, image.TotalColors);
          image.Dispose();

          image = collection.Combine();
          Assert.AreEqual(rose.TotalColors, image.TotalColors);
        }
      }
    }
    public void Test_Combine()
    {
      using (MagickImage rose = new MagickImage(Files.Builtin.Rose))
      {
        using (MagickImageCollection collection = new MagickImageCollection(rose.Separate(Channels.RGB)))
        {
          Assert.AreEqual(3, collection.Count);

          MagickImage image = collection.Merge();
          Assert.AreNotEqual(rose.TotalColors, image.TotalColors);
          image.Dispose();

          image = collection.Combine();
          Assert.AreEqual(rose.TotalColors, image.TotalColors);
        }
      }
    }
예제 #3
0
    public void Test_Separate_Composite()
    {
      using (MagickImage logo = new MagickImage(Files.Builtin.Logo))
      {
        using (MagickImage blue = logo.Separate(Channels.Blue).First())
        {
          Test_Separate_Composite(blue, ColorSpace.Gray, 146);

          using (MagickImage green = logo.Separate(Channels.Green).First())
          {
            Test_Separate_Composite(green, ColorSpace.Gray, 62);

            blue.Composite(green, CompositeOperator.Multiply);

            Test_Separate_Composite(blue, ColorSpace.sRGB, 35);
          }
        }
      }
    }
예제 #4
0
    public void Test_Channels()
    {
      PixelChannel[] rgb = new PixelChannel[]
      {
        PixelChannel.Red, PixelChannel.Green, PixelChannel.Blue
      };

      PixelChannel[] rgba = new PixelChannel[]
      {
        PixelChannel.Red, PixelChannel.Green, PixelChannel.Blue, PixelChannel.Alpha
      };

      PixelChannel[] gray = new PixelChannel[]
      {
        PixelChannel.Gray
      };

      PixelChannel[] grayAlpha = new PixelChannel[]
      {
        PixelChannel.Gray, PixelChannel.Alpha
      };

      PixelChannel[] cmyk = new PixelChannel[]
      {
        PixelChannel.Cyan, PixelChannel.Magenta, PixelChannel.Yellow, PixelChannel.Black
      };

      PixelChannel[] cmyka = new PixelChannel[]
      {
        PixelChannel.Cyan, PixelChannel.Magenta, PixelChannel.Yellow, PixelChannel.Black, PixelChannel.Alpha
      };

      using (MagickImage image = new MagickImage(Files.RoseSparkleGIF))
      {
        CollectionAssert.AreEqual(rgba, image.Channels.ToArray());

        image.Alpha(AlphaOption.Off);

        CollectionAssert.AreEqual(rgb, image.Channels.ToArray());
      }

      using (MagickImage image = new MagickImage(Files.SnakewarePNG))
      {
        CollectionAssert.AreEqual(grayAlpha, image.Channels.ToArray());

        using (MagickImage redChannel = image.Separate(Channels.Red).First())
        {
          CollectionAssert.AreEqual(gray, redChannel.Channels.ToArray());

          redChannel.Alpha(AlphaOption.On);

          CollectionAssert.AreEqual(grayAlpha, redChannel.Channels.ToArray());
        }
      }

      using (MagickImage image = new MagickImage(Files.SnakewarePNG))
      {
        image.ColorSpace = ColorSpace.CMYK;

        CollectionAssert.AreEqual(cmyka, image.Channels.ToArray());

        image.Alpha(AlphaOption.Off);

        CollectionAssert.AreEqual(cmyk, image.Channels.ToArray());
      }
    }
예제 #5
0
    public void Test_Separate()
    {
      using (MagickImage rose = new MagickImage(Files.Builtin.Rose))
      {
        int i = 0;
        foreach (MagickImage image in rose.Separate())
        {
          i++;
          image.Dispose();
        }

        Assert.AreEqual(3, i);

        i = 0;
        foreach (MagickImage image in rose.Separate(Channels.Red | Channels.Green))
        {
          i++;
          image.Dispose();
        }

        Assert.AreEqual(2, i);
      }
    }