Exemplo n.º 1
0
        private void Distort(IMagickImage output, PointD[] corners, MagickGeometry inputDimensions, MagickGeometry trimmedDimensions, MagickColor backgroundColor)
        {
            MagickGeometry outputDimensions = GetDimensions(output, corners, inputDimensions, trimmedDimensions);

            double[] arguments = new double[16]
            {
                corners[0].X, corners[0].Y, 0, 0,
                corners[1].X, corners[1].Y, 0, outputDimensions.Height,
                corners[2].X, corners[2].Y, outputDimensions.Width, outputDimensions.Height,
                corners[3].X, corners[3].Y, outputDimensions.Width, 0
            };

            output.VirtualPixelMethod = VirtualPixelMethod.Background;
            output.BackgroundColor    = backgroundColor;
            if (!DisableViewportCrop)
            {
                output.SetArtifact("distort:viewport", GetViewport(arguments, corners).ToString());
            }
            var distortSettings = new DistortSettings()
            {
                Bestfit = true
            };

            output.Distort(DistortMethod.Perspective, distortSettings, arguments);
            output.BorderColor = backgroundColor;
            output.Border(2);
            output.ColorFuzz = ColorFuzz;
            output.Trim();
            output.RePage();
        }
Exemplo n.º 2
0
        private MagickGeometry TrimImage(IMagickImage image, MagickColor backgroundColor, int borderSize)
        {
            image.BorderColor = backgroundColor;
            image.Border(borderSize);
            image.ColorFuzz = ColorFuzz;
            image.Trim();
            image.RePage();

            return(new MagickGeometry(image.Width, image.Height));
        }
        private void PadImage(IMagickImage image)
        {
            if (Padding == 0)
            {
                return;
            }

            image.Compose     = CompositeOperator.Over;
            image.BorderColor = BackgroundColor;
            image.Border(Padding);
        }
Exemplo n.º 4
0
        public void CastShadow(IMagickImage caster, int offsetX, int offsetY, double size, Percentage alpha, MagickColor color, bool extendCasterWithBorder = true)
        {
            using (IMagickImage shadow = caster.Clone())
            {
                shadow.Shadow(offsetX, offsetY, size, alpha, color);

                if (extendCasterWithBorder)
                {
                    caster.BorderColor = MagickColors.Transparent;
                    caster.Border((int)size);
                }

                caster.Composite(shadow, 0, 0, CompositeOperator.DstOver);
            }
        }
Exemplo n.º 5
0
 private static void PadImage(IMagickImage image, int borderSize)
 {
     image.Border(borderSize);
 }