strokeDashArray BUG?
Posted: 2007-06-12T10:57:19-07:00
Libary: Magick++ (C++ API) V6.2.6
System/Kernel:
SuSE_9.1_ia64
Linux dvlra1a 2.6.5-7.252.1-rtgfx #1 SMP Mon Mar 20 18:27:59 PST 2006 ia64 ia64 ia64 GNU/Linux
-------------------------------------------------
I have an app I've written that is drawing grid lines (major/minor) using different dash patterns. Every so often (I cannot figure out any repeatable pattern), I get strange results when drawing these grid lines, with lines being drawn from the top left corner of the image across the image diagonally. I've finally come up with a code snippet that reliable reproduces this bug on my system... any help in fixing this would be much appreciated... Thanks! I can send output images illustrating this bug if desired - just let me know. -Todd
--------------------------------------------------
System/Kernel:
SuSE_9.1_ia64
Linux dvlra1a 2.6.5-7.252.1-rtgfx #1 SMP Mon Mar 20 18:27:59 PST 2006 ia64 ia64 ia64 GNU/Linux
-------------------------------------------------
I have an app I've written that is drawing grid lines (major/minor) using different dash patterns. Every so often (I cannot figure out any repeatable pattern), I get strange results when drawing these grid lines, with lines being drawn from the top left corner of the image across the image diagonally. I've finally come up with a code snippet that reliable reproduces this bug on my system... any help in fixing this would be much appreciated... Thanks! I can send output images illustrating this bug if desired - just let me know. -Todd
--------------------------------------------------
Code: Select all
#include <Magick++.h>
using namespace Magick;
typedef struct {
char color[64];
int width;
float opacity;
double dash[10];
} LineDescription;
static Image * _pImg = NULL;
static void SetLineStyle(LineDescription & line)
{
Color clear(0,0,0,TransparentOpacity);
_pImg->fillColor(clear);
Color line_color(line.color);
line_color.alpha(1.0 - line.opacity);
_pImg->strokeColor(line_color);
_pImg->strokeWidth(line.width);
line.dash[0] <= 0.0 ?
_pImg->strokeDashArray(NULL) :
_pImg->strokeDashArray(line.dash);
}
int main(void)
{
_pImg = new Image(Geometry(640,640),"black");
system("rm test.jpg");
int major_gap = 50;
int minor_gap = 10;
LineDescription major;
strncpy(major.color,"white",64);
major.width = 1;
major.opacity = 0.6;
major.dash[0] = 0.5;
major.dash[1] = 2.5;
major.dash[2] = 0.0;
LineDescription minor;
strncpy(minor.color,"gray",64);
minor.width = 1;
minor.opacity = 0.4;
minor.dash[0] = 0.5;
minor.dash[1] = 1.5;
minor.dash[2] = 0.0;
SetLineStyle(minor);
for(int col = minor_gap; col < 640; col += minor_gap)
{
_pImg->draw(DrawableLine(col, 0, col, 640));
}
for(int row = minor_gap; row < 640; row += minor_gap)
{
_pImg->draw(DrawableLine(0, row, 640, row));
}
SetLineStyle(major);
for(int col = major_gap; col < 640; col += major_gap)
{
_pImg->draw(DrawableLine(col, 0, col, 640));
}
for(int row = major_gap; row < 640; row += major_gap)
{
_pImg->draw(DrawableLine(0, row, 640, row));
}
_pImg->write("test.jpg");
system("display test.jpg &");
return 0;
}