Magick.NET icon indicating copy to clipboard operation
Magick.NET copied to clipboard

Draw Lines on Rect skewed

Open sunbot opened this issue 8 years ago • 8 comments

The following should be a perfect, even line square, but after the upgrade to 7.5, it's quite skewed. "Paint" drip appears on bottom left as well.

image

This is the correct image: image

Using .Net Framework 4.6.1 Here is a snippet. Nothing changed from original.

using (MagickImage output = new MagickImage(MagickColors.Transparent, /*width*/,/*height*/))
{
    output.Tile(source, CompositeOperator.DstOver);
    output.Settings.StrokeColor = new MagickColor(Color.Red);
    output.Settings.StrokeWidth = 18;
    output.Settings.FillColor = MagickColors.

    DrawableRectangle rect = new DrawableRectangle(/*valid values*/);
    output.Draw(rect);
}

sunbot avatar Jul 06 '18 16:07 sunbot

Is it possible to also include the /*valid values*/ in your example so I have a complete sample to reproduce this?

dlemstra avatar Jul 06 '18 20:07 dlemstra

Of course @dlemstra

var rectParams = new {UpperLeftX = 1, UpperLeftY = 0, LowerRightX = 177, LowerRightY = 176};

sunbot avatar Jul 06 '18 21:07 sunbot

Could you create a complete example that demonstrates your issue?

dlemstra avatar Jul 06 '18 21:07 dlemstra

Code:

        using (MagickImage source = new MagickImage(binaryData))
        {
            source.Draw(new DrawableRectangle(0, 0, 550, 400));

            using (MagickImage output =
                new MagickImage(MagickColors.Transparent, 535, 1065))
            {
                output.Tile(source, CompositeOperator.DstOver);

                output.Settings.StrokeColor = new MagickColor(Color.Red);
                output.Settings.StrokeWidth = 18;
                output.Settings.FillColor = MagickColors.Transparent;

                var rectParams = new {UpperLeftX = 1, UpperLeftY = 0, LowerRightX = 177, LowerRightY = 176};

                DrawableRectangle rect = new DrawableRectangle(
                    rectParams.UpperLeftX,
                    rectParams.UpperLeftY,
                    rectParams.LowerRightX,
                    rectParams.LowerRightY);

                output.Draw(rect);
                output.Format = MagickFormat.Jpeg;
                output.Interpolate = PixelInterpolateMethod.Catrom;
                output.Quality = 90;

                output.Write(Path.Combine("D:\\Test\\tileoutput",
                    $"testgridlines-{DateTime.Now.Millisecond}_{output.Width}x{output.Height}.jpeg"));

            }
        }

With Updates yields: image

Previous version: image

Slight difference in appearance with no changes but library. Here are some other coordinates to try: coords="0,0,90,90"
coords="92,91,182,181"
coords="184,183,274,273"
coords="1,274,91,364"
coords="93,366,183,456"
coords="185,458,275,548"

sunbot avatar Jul 06 '18 21:07 sunbot

Thanks for trying to create a sample but next time please make sure I can just copy it in another file and run the code. This code contains variables that are not defined.

But I reproduced your issue with a sample that I created myself. It looks like this was a bug inside the ImageMagick library that now has been resolved. I will try to publish a new release to resolve this soon.

dlemstra avatar Jul 07 '18 08:07 dlemstra

Thanks for looking into it.

sunbot avatar Jul 07 '18 21:07 sunbot

Can you give it another try with the latest release @sunbot?

dlemstra avatar Jul 09 '18 22:07 dlemstra

Looks good! Thanks!

sunbot avatar Jul 12 '18 20:07 sunbot