wmf coder chord, pie and arc fix

Peter Boos <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.core
Message-ID <[email protected]>
diff.patch (text/x-diff, 2.4 KB)
Hi Bob,

I worked a little bit on the problem with wmf and pie/arc/chord.
I attached you a patch, which fixes those problems, but I'm not
sure if this code fixes all cases:
1. DrawPathEllipticArcAbsolute(): I'm not sure what exactly those
   three parameters are about x_axis_rotation, large_arc_flag,
   sweep_flag. If I change the sweep_flag, the pie is not drawn
   correctly anymore...
2. In chord, a substract the two positions of the arc oordinates
   from the bottom/left coordinates. This could be wrong or could
   be fine-tuned.
Anyway, I would say, this is a good starting point for other
people who run into the same issue.

Regards,

	Peter

Index: coders/wmf.c
===================================================================
RCS file: /ImageMagick/ImageMagick/coders/wmf.c,v
retrieving revision 1.61
diff -u -r1.61 wmf.c
--- coders/wmf.c	24 Jan 2004 01:13:03 -0000	1.61
+++ coders/wmf.c	12 Feb 2004 16:38:36 -0000
@@ -930,14 +930,21 @@
       if (finish == magick_arc_ellipse)
         DrawEllipse(WmfDrawingWand, XC(O.x), YC(O.y), Rx, Ry, 0, 360);
       else if (finish == magick_arc_pie)
-        DrawEllipse(WmfDrawingWand, XC(O.x), YC(O.y), Rx, Ry, phi_s, phi_e);
-      else if (finish == magick_arc_chord)
         {
-          DrawArc(WmfDrawingWand, XC(O.x), YC(O.y), Rx, Ry, phi_s, phi_e);
-          DrawLine(WmfDrawingWand, XC(start.x), YC(start.y), XC(end.x), YC(end.y));
+		  DrawPathStart(WmfDrawingWand);
+		  DrawPathMoveToAbsolute(WmfDrawingWand, XC(O.x+start.x), YC(O.y+start.y));
+		  DrawPathEllipticArcAbsolute(WmfDrawingWand, Rx, Ry, 0, 0, 1, XC(O.x+end.x), YC(O.y+end.y));
+		  DrawPathLineToAbsolute(WmfDrawingWand, XC(O.x), YC(O.y));
+		  DrawPathClose(WmfDrawingWand);
+		  DrawPathFinish(WmfDrawingWand);
         }
-      else      /* if (finish == magick_arc_open) */
-        DrawArc(WmfDrawingWand, XC(O.x), YC(O.y), Rx, Ry, phi_s, phi_e);
+        else if (finish == magick_arc_chord)
+        {
+          DrawArc(WmfDrawingWand, XC(draw_arc->TL.x), YC(draw_arc->TL.y), XC(draw_arc->BR.x), XC(draw_arc->BR.y), phi_s, phi_e);
+          DrawLine(WmfDrawingWand, XC(draw_arc->BR.x-start.x), YC(draw_arc->BR.y-start.y), XC(draw_arc->BR.x-end.x), YC(draw_arc->BR.y-end.y));
+        }
+        else      /* if (finish == magick_arc_open) */
+          DrawArc(WmfDrawingWand, XC(draw_arc->TL.x), YC(draw_arc->TL.y), XC(draw_arc->BR.x), XC(draw_arc->BR.y), phi_s, phi_e);
     }
 
   /* Restore graphic wand */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.