Issues with Color, strokeColor, strokeWidth, strokeAntiAlias

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
luffy

Issues with Color, strokeColor, strokeWidth, strokeAntiAlias

Post by luffy »

Hi, I'm using Magick++ and I have followed the tutorial.
I'm using Debian 64bits if that matters.

I'm able do draw simple lines like in the example:
// Example:
my_image.strokeColor("red");
my_image.strokeAntiAlias(false);

However when I try to do something more, things don't work.

[1] I'm unable to set the color of a line using RGB values, I always get a black line. If I use the method in the example it works, however using strings isn't enough for me.

Code: Select all

Color *line_color = new Color(255, 0, 0, 0);
Color *line_color = new Color("red");
I always get black lines with the first method.


[2] strokeWidth
How do I set a width of 1 pixel?


[3] strokeAntiAlias and everything else

CASE 1: color "red", width 0.1, AA false
Image

CASE 2: color "red", width 0.1, AA true
Image

CASE 3: color "red", width 0.1, AA true, fillcolor "red"
Image

How do I draw a simple solid filled line? It gets all weird either with and without AA.
There are more colors in those lines than just red. Yes, that should be expected with AA, but not black pixels :(



Thank you very much for any help you may give.
luffy

Re: Issues with Color, strokeColor, strokeWidth, strokeAntiAlias

Post by luffy »

Anybody?

If this isn't solvable, can you recomend me any other image processing library (capable of solving this issue)?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Issues with Color, strokeColor, strokeWidth, strokeAntiAlias

Post by magick »

Grab the ImageMagick source distribution and move to the Magick++/demo folder. If you are running under Windows, go to the c:\Program Files\ImageMagick-6.4.6-Q16\Magick++_demos folder.

Take a look at the shapes and piddle projects. It shows examples of drawing with different font colors and strokewidths.
luffy

Re: Issues with Color, strokeColor, strokeWidth, strokeAntiAlias

Post by luffy »

Thanks for the comment, but that clearly doesn't solve my issues.
Those code samples don't target what I am mentioning.

My problem isn't drawing lines, my problem is drawing lines with certain properties:
- any color (not possible because passing RGB codes doesn't make any difference)
- make 1 solid color only! I try to make a red line and I get black pixels in that line ó_Ô
- define the width in terms of pixels (not very serious since 0.1 seems to be equivalente to 1 pixel)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Issues with Color, strokeColor, strokeWidth, strokeAntiAlias

Post by anthony »

There are two colors associated with any line draw in IM. 'stroke color' is one color, but even though a line has no thickness, 'fill color' also is used!

For demonstrations of this try stroking a diagonal line with a zero stroke width! you will get a mix of two colors.

You can see this in IM Examples, Drawing Lines, Line Width and Stroke

The solution is to EITHER use the same fill and stroke colors, OR setting one of the colors to none to turn it off. Note the fill line thickness is '0', only the stroke line can have a larger thickness, and that thickness is a floating point value!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply