A GDI+ application displays an extra line that connects two separate polygons when the GDI+ application uses the SetLineJoin function and the StartFigure function (921911)



The information in this article applies to:

  • Platform SDK Redistributable: GDI+

SYMPTOMS

A Microsoft GDI+ application displays an extra line that connects two separate polygons when the GDI+ application uses the SetLineJoin function and the StartFigure function.

The GDI+ application outputs linear data by using the Pen class and the GraphicsPath class in GDI+. An instance of the GraphicsPath class that has two separate polygons is created. However, the GDI+ application displays an extra line that connects the two polygons when the two polygons are drawn by using GDI+.

CAUSE

If you use the StartFigure function after another StartFigure function, the second figure is connected to the first figure. This occurs even if you use the CloseFigure function to close the first figure.

WORKAROUND

To work around this problem, use the StartFigure function at the start of the second figure.

For example, use code that resembles the following code example.
void PaintGDIPlus(HDC hdc) {
  Graphics gr(hdc);
  GraphicsPath gp;
  Pen pen(Color(250,255,0,0), 3);
  pen.SetLineJoin(LineJoinRound);
  pen.SetLineCap(LineCapRound, LineCapRound, DashCapRound);
  //Uncomment this line to see the problem.
  //gp.StartFigure();
  gp.AddLine(841, 298, 842, 300);
  gp.AddLine(842, 300, 842, 302);
  //This line has already closed the figure.
  gp.AddLine(842, 302, 841, 298);
  //Uncomment this line to see the problem.
  //gp.CloseFigure();

  //This StartFigure() function starts the new figure and disconnects from the old figure.
  gp.StartFigure();
  gp.AddLine(87, 291, 85, 293);
  gp.AddLine(85, 293, 83, 295);
  gp.AddLine(83, 295, 85, 293);
  gp.AddLine(85, 293, 87, 291);
  gr.DrawPath(&pen, &gp);
}

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

REFERENCES

For more information about the GraphicsPath::StartFigure function, visit the following Microsoft Web site:

Modification Type:MajorLast Reviewed:7/18/2006
Keywords:kbGDIPlus kbtshoot kbprb KB921911 kbAudDeveloper