Page 1 of 1

Issues with Color, strokeColor, strokeWidth, strokeAntiAlias

Posted: 2008-12-01T12:11:14-07:00
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.

Re: Issues with Color, strokeColor, strokeWidth, strokeAntiAlias

Posted: 2008-12-03T16:00:06-07:00
by luffy
Anybody?

If this isn't solvable, can you recomend me any other image processing library (capable of solving this issue)?

Re: Issues with Color, strokeColor, strokeWidth, strokeAntiAlias

Posted: 2008-12-03T16:36:49-07:00
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.

Re: Issues with Color, strokeColor, strokeWidth, strokeAntiAlias

Posted: 2008-12-07T12:12:28-07:00
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)

Re: Issues with Color, strokeColor, strokeWidth, strokeAntiAlias

Posted: 2008-12-07T21:38:48-07:00
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!