Draw Rectangle unfilled C#

Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
Post Reply
devyekov
Posts: 19
Joined: 2014-12-01T08:16:19-07:00
Authentication code: 6789

Draw Rectangle unfilled C#

Post by devyekov » 2014-12-03T17:41:59-07:00

Sorry, here again

How to draw a rectangle unfilled on a image? Using wrapper

Regards

User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Draw Rectangle unfilled C#

Post by dlemstra » 2014-12-05T02:29:32-07:00

I cannot help you with a complete example I can only use my phone at the moment. You should use the drawable classes and the Draw method of MagickImage. I hope this can help you for now. I will be behind a pc next week and then I can help you with a better example if you still need it.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

devyekov
Posts: 19
Joined: 2014-12-01T08:16:19-07:00
Authentication code: 6789

Re: Draw Rectangle unfilled C#

Post by devyekov » 2014-12-05T11:48:50-07:00

I appreciate the attention, I expect to find before solution. Because otherwise I'll be here wondering upps jeje

I found the guide (http://imagemagick.org/Usage/draw/#primitives) but I still do not understand how to use it in the Wrapper.

Regards
Thanks

devyekov
Posts: 19
Joined: 2014-12-01T08:16:19-07:00
Authentication code: 6789

Re: Draw Rectangle unfilled C#

Post by devyekov » 2015-03-11T16:10:25-07:00

Hello

Can you help me with this issue that I could not solve?.
Use C# with Magick.NET-x86.dll

Regards
Thank You

User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Draw Rectangle unfilled C#

Post by dlemstra » 2015-03-12T04:53:35-07:00

I completely forgot about this topic.

When you draw a circle it has two color. The stroke color (the line) and the fill color (part inside line). You can make it 'empty' if you set the fill color to transparent. Below is an example:

Code: Select all

using (MagickImage image = new MagickImage(new MagickColor("yellow"), 500, 500))
{
  DrawableStrokeColor strokeColor = new DrawableStrokeColor(new MagickColor("purple"));
  DrawableStrokeWidth stokeWidth = new DrawableStrokeWidth(5);
  DrawableFillColor fillColor = new DrawableFillColor(MagickColor.Transparent);
  DrawableCircle circle = new DrawableCircle(250, 250, 100, 100);

  image.Draw(strokeColor, stokeWidth, fillColor, circle);
  image.Write(@"C:\circl.png");
}
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

devyekov
Posts: 19
Joined: 2014-12-01T08:16:19-07:00
Authentication code: 6789

Re: Draw Rectangle unfilled C#

Post by devyekov » 2015-03-12T15:45:36-07:00

Thank you very much for your prompt response. I works great.

I have just a curiosity, not a mistake, but when the lines of a rectangle is generated, the lines are not uniform, on some occasions the line is not seen. (part of the line)

Regards
thx

User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Draw Rectangle unfilled C#

Post by dlemstra » 2015-03-12T22:45:01-07:00

Can you post an example? I don't understand the question/issue. Are you using the latest version of Magick.NET?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

devyekov
Posts: 19
Joined: 2014-12-01T08:16:19-07:00
Authentication code: 6789

Re: Draw Rectangle unfilled C#

Post by devyekov » 2015-03-13T10:21:38-07:00

Hi

To generate the image using the same method you gave me. Use Magick.NET-7.0.0.0007-Q16-x86-net20
How do I send a picture?

Regards
Thk

User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Draw Rectangle unfilled C#

Post by dlemstra » 2015-03-14T06:28:31-07:00

You can post your image on something like dropbox and post a link here.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

devyekov
Posts: 19
Joined: 2014-12-01T08:16:19-07:00
Authentication code: 6789

Re: Draw Rectangle unfilled C#

Post by devyekov » 2015-03-19T23:22:39-07:00

In the image on upper right corner, line becomes thinner. It is not a mistake, but why is not uniform?

What I observed is that this occurs with high resolution images.

https://www.dropbox.com/s/io6x7esk11aib ... o.jpg?dl=0

Thk
Regards

User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Draw Rectangle unfilled C#

Post by dlemstra » 2015-03-20T04:44:30-07:00

Are you adding the rectangle before or after you resize the image?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

devyekov
Posts: 19
Joined: 2014-12-01T08:16:19-07:00
Authentication code: 6789

Re: Draw Rectangle unfilled C#

Post by devyekov » 2015-03-20T09:48:01-07:00

Hi,

I make no resize before or after. Only apply the rectangle. I can't now load the original image, later I upload the image.

Code: Select all

MagickImage image = new MagickImage(strPathImage);
DrawableStrokeColor strokeColor = new DrawableStrokeColor(new MagickColor("white"));
DrawableStrokeWidth stokeWidth = new DrawableStrokeWidth(7);
DrawableFillColor fillColor = new DrawableFillColor(MagickColor.Transparent);
DrawableRectangle rec = new DrawableRectangle(new Rectangle(300, 300, image.Width - 600, image.Height - 600));
image.Draw(strokeColor, stokeWidth, fillColor, rec);
image.Write(strOutImagen);
Regards

devyekov
Posts: 19
Joined: 2014-12-01T08:16:19-07:00
Authentication code: 6789

Re: Draw Rectangle unfilled C#

Post by devyekov » 2015-03-23T22:01:39-07:00


User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Draw Rectangle unfilled C#

Post by dlemstra » 2015-04-06T06:53:46-07:00

We were able to reproduce the issue and the next release of Magick.NET will include a fix for this. Thank you for all the great information that helped us find the bug.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

devyekov
Posts: 19
Joined: 2014-12-01T08:16:19-07:00
Authentication code: 6789

Re: Draw Rectangle unfilled C#

Post by devyekov » 2015-04-06T11:19:18-07:00

Excellent, it was a pleasure. Thank to you guys.

Post Reply