Esempio 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();
        }
Esempio n. 2
0
        private void DistortImageWithMagnification(IMagickImage input, IMagickImage image)
        {
            var delX = (input.Width - _width) / 2;
            var delY = (input.Height - _height) / 2;

            SetDistortViewport(image, (int)delX, (int)delY);

            image.Distort(DistortMethod.ScaleRotateTranslate, Magnification.Value, 0);
        }
Esempio n. 3
0
        private void DistortImageWithCoords(IMagickImage image)
        {
            SetDistortViewport(image, 0, 0);

            var arguments = new double[16]
            {
                _coords[0].X, _coords[0].Y, 0, 0, _coords[1].X, _coords[1].Y, _width, 0,
                _coords[2].X, _coords[2].Y, _width, _height, _coords[3].X, _coords[3].Y, 0, _height
            };

            image.Distort(DistortMethod.Perspective, arguments);
        }
Esempio n. 4
0
        private void DistortImageWithDimensions(IMagickImage input, IMagickImage image)
        {
            var delX = (input.Width - _width) / 2;
            var delY = (input.Height - _height) / 2;

            SetDistortViewport(image, (int)delX, (int)delY);

            var cX   = input.Width / 2;
            var cY   = input.Height / 2;
            var magX = _width / input.Width;
            var magY = _height / input.Height;

            image.Distort(DistortMethod.ScaleRotateTranslate, cX, cY, magX, magY, 0);
        }