• Welcome to Jose's Read Only Forum 2023.
 

GDI+: GdipFillPath

Started by José Roca, June 23, 2008, 06:13:24 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following example fills a path.

C++


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

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

   // Create a SolidBrush object.
   SolidBrush blackBrush(Color(255, 0, 0, 0));

   // Draw ellipsePath.
   graphics.FillPath(&blackBrush, &ellipsePath);
}


PowerBASIC


SUB GDIP_FillPath (BYVAL hdc AS DWORD)

   LOCAL hStatus AS LONG
   LOCAL pGraphics AS DWORD
   LOCAL pBrush 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 SolidBrush
   hStatus = GdipCreateSolidFill(GDIP_ARGB(255, 0, 0, 0), pBrush)

   ' // Fill ellipsePath.
   hStatus = GdipFillPath(pGraphics, pBrush, pEllipsePath)

   ' // Cleanup
   IF pBrush THEN GdipDeleteBrush(pBrush)
   IF pEllipsePath THEN GdipDeletePath(pEllipsePath)
   IF pGraphics THEN GdipDeleteGraphics(pGraphics)

END SUB