示例#1
0
            private static void AssertClipColors(bool inside, QuantumType value)
            {
                using (IMagickImage image = new MagickImage(Files.InvitationTIF))
                {
                    image.Alpha(AlphaOption.Transparent);
                    image.Clip("Pad A", inside);
                    image.Alpha(AlphaOption.Opaque);

                    using (IMagickImage mask = image.GetWriteMask())
                    {
                        Assert.IsNotNull(mask);
                        Assert.AreEqual(false, mask.HasAlpha);

                        using (IPixelCollection pixels = mask.GetPixels())
                        {
                            MagickColor pixelA = pixels.GetPixel(0, 0).ToColor();
                            MagickColor pixelB = pixels.GetPixel(mask.Width - 1, mask.Height - 1).ToColor();

                            Assert.AreEqual(pixelA, pixelB);
                            Assert.AreEqual(value, pixelA.R);
                            Assert.AreEqual(value, pixelA.G);
                            Assert.AreEqual(value, pixelA.B);

                            MagickColor pixelC = pixels.GetPixel(mask.Width / 2, mask.Height / 2).ToColor();
                            Assert.AreEqual(Quantum.Max - value, pixelC.R);
                            Assert.AreEqual(Quantum.Max - value, pixelC.G);
                            Assert.AreEqual(Quantum.Max - value, pixelC.B);
                        }
                    }
                }
            }