PowerBasic Museum 2020-A

Legacy Software (PBWIN 9.0+/PBCC 5.0+) => Source Code => Graphics and Multimedia => GDI+ (GDI Plus) => Topic started by: José Roca on June 23, 2008, 05:09:18 PM

Title: GDI+: GdipDrawPath
Post by: José Roca on June 23, 2008, 05:09:18 PM


The following example draws a GraphicsPath object.

C++


VOID Example_DrawPath(HDC hdc)
{
   Graphics graphics(hdc);

   // Create a GraphicsPath, and add an ellipse.
   GraphicsPath ellipsePath;
   ellipsePath.AddEllipse(Rect(100, 50, 200, 100));

   // Create a Pen object.
   Pen blackPen(Color(255, 0, 0, 0), 3);

   // Draw ellipsePath.
   graphics.DrawPath(&blackPen, &ellipsePath);
}


PowerBASIC


SUB GDIP_DrawPath (BYVAL hdc AS DWORD)

   LOCAL hStatus AS LONG
   LOCAL pGraphics AS DWORD
   LOCAL pPen AS DWORD
   LOCAL pEllipsePath AS DWORD

   hStatus = GdipCreateFromHDC(hdc, pGraphics)

   ' Create a GraphicsPath object, and add an ellipse
   hStatus = GdipCreatePath(%FillModeAlternate, pEllipsePath)
   hStatus = GdipAddPathEllipseI(pEllipsePath, 100, 50, 200, 100)

   ' // Create a Pen
   hStatus = GdipCreatePen1(GDIP_ARGB(255, 0, 0, 0), 3, %UnitPixel, pPen)

   ' // Draw ellipsePath.
   hStatus = GdipDrawPath(pGraphics, pPen, pEllipsePath)

   ' // Cleanup
   IF pEllipsePath THEN GdipDeletePath(pEllipsePath)
   IF pPen THEN GdipDeletePen(pPen)
   IF pGraphics THEN GdipDeleteGraphics(pGraphics)

END SUB


(http://www.jose.it-berater.org/captures/GdipDrawPath.png)