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 »

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 »

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 »

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 »

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 »

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 »

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 »

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 »

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 »

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 »

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 »

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 »

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 »

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 »

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 »

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