Page 1 of 1

Omitted elliptical arc commands not working

Posted: 2009-08-07T16:05:55-07:00
by rmagick
This is ImageMagick 6.5.4-8 on Ubuntu.

I'm trying to reproduce this SVG example (http://www.w3.org/TR/SVG11/painting.html#FillProperties) using MagickWand
Image
Using the MagickWand drawing API I created this MVG file:

Code: Select all

push graphic-context
 scale 0.355,0.355
 push graphic-context
  fill-rule 'NonZero'
  stroke-width 3
  stroke '#000000000000'
  fill '#FFFF00000000'
  path 'M600,81A107,107 0 0 1 600,295 107,107 0 0 1 600,81ZM600,139A49,49 0 0 1 600,237 49,49 0 0 1 600,139Z'
 pop graphic-context
pop graphic-context
I use this command to render it:

Code: Select all

convert -size 426x142 test.mvg test.png
Here's the output:
Image
I see that MagickWand has omitted the A when the 2nd A immediately follows an A. I understand that this is permitted by the SVG standard.

If I manually edit the MVG file to add the omitted A's, however, the result is correct.

Code: Select all

  path 'M600,81A107,107 0 0 1 600,295 A107,107 0 0 1 600,81ZM600,139A49,49 0 0 1 600,237 A49,49 0 0 1 600,139Z'
Image

Re: Omitted elliptical arc commands not working

Posted: 2009-08-08T19:45:22-07:00
by magick
Using the MagickWand drawing API I created this MVG file
We'll need a working program that uses the MagickWand drawing API to produce the path that is failing. We need to determine if the problem is in your code or the MagickWand drawing API.

Re: Omitted elliptical arc commands not working

Posted: 2009-08-09T12:20:02-07:00
by rmagick
Sure thing. Here you go. Please let me know if you need anything else.

Code: Select all

/*
 *  gcc `MagickWand-config --cflags --cppflags` -o arcbug arcbug.c `MagickWand-config --ldflags --libs`
 */
#include <stdio.h>
#include <stdlib.h>
#include <wand/MagickWand.h>

int main(int argc, char **argv)
{
    MagickWand *wand;
    DrawingWand *drawing;
    PixelWand *red, *white;

    MagickWandGenesis();

    red = NewPixelWand();
    PixelSetColor(red, "red");
    white = NewPixelWand();
    PixelSetColor(white, "white");

    drawing = NewDrawingWand();

    DrawSetFillColor(drawing, red);
    DrawPathStart(drawing);
    DrawPathMoveToAbsolute(drawing, 600.0, 81.0);
    DrawPathEllipticArcAbsolute(drawing, 107.0, 107.0, 0.0, MagickFalse, MagickTrue, 600.0, 295.0);
    DrawPathEllipticArcAbsolute(drawing, 107.0, 107.0, 0.0, MagickFalse, MagickTrue, 600.0, 81.0);
    DrawPathClose(drawing);

    DrawPathMoveToAbsolute(drawing, 600.0, 139.0);
    DrawPathEllipticArcAbsolute(drawing, 49.0, 49.0, 0.0, MagickFalse, MagickTrue, 600.0, 237.0);
    DrawPathEllipticArcAbsolute(drawing, 49.0, 49.0, 0.0, MagickFalse, MagickTrue, 600.0, 139.0);
    DrawPathClose(drawing);
    DrawPathFinish(drawing);

    wand = NewMagickWand();
    MagickNewImage(wand, 1200, 400, white);
    MagickDrawImage(wand, drawing);
    MagickWriteImage(wand, "arcbug.png");
    MagickWriteImage(wand, "arcbug.mvg");

    DestroyDrawingWand(drawing);
    DestroyMagickWand(wand);
    DestroyPixelWand(red);
    DestroyPixelWand(white);

    MagickWandTerminus();
}
Here's the arcbug.mvg file:

Code: Select all

fill '#FFFF00000000'
path 'M600,81A107,107 0 0 1 600,295 107,107 0 0 1 600,81ZM600,139
A49,49 0 0 1 600,237 49,49 0 0 1 600,139Z'
For comparision, here's the path element from the SVG example:

Code: Select all

<path d="M 600,81 A 107,107 0 0,1 600,295 A 107,107 0 0,1 600,81 z
             M 600,139 A 49,49 0 0,1 600,237 A 49,49 0 0,1 600,139 z" />
Here's the arcbug.png file:
Image

Re: Omitted elliptical arc commands not working

Posted: 2009-08-09T12:36:01-07:00
by magick
We can reproduce the problem you reported and have a patch in the Subversion trunk available sometime tomorrow. The patch will also be in the next point release of ImageMagick. Thanks.