Interactive PowerBasic Forum

Legacy Software (PBWIN 9.0+/PBCC 5.0+) => Source Code => Graphics and Multimedia => GDI+ (GDI Plus) => Topic started by: José Roca on June 22, 2008, 03:41:39 PM

Title: GDI+: GdipFillRegion
Post by: José Roca on June 22, 2008, 03:41:39 PM


The following example creates a region from a rectangle and then fills the region.

C++


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

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

   // Create a Region object from a rectangle.
   Region ellipseRegion(Rect(0, 0, 200, 100));

   // Fill the region.
   graphics.FillRegion(&blackBrush, &ellipseRegion);
}


PowerBASIC


SUB GDIP_FillRegion (BYVAL hdc AS DWORD)

   LOCAL hStatus AS LONG
   LOCAL pGraphics AS DWORD
   LOCAL pBrush AS DWORD
   LOCAL pRegion AS DWORD
   LOCAL rcf AS RECTF

   hStatus = GdipCreateFromHDC(hdc, pGraphics)

   ' // Create a SolidBrush
   hStatus = GdipCreateSolidFill(GDIP_ARGB(255, 0, 0, 0), pBrush)

   ' // Create a Region object from a rectangle.
   rcf.x = 0 : rcf.y = 0 : rcf.Width = 200 : rcf.Height = 100
   hStatus = GdipCreateRegionRect(rcf, pRegion)

   ' // Fill the rectangle.
   hStatus = GdipFillRegion(pGraphics, pBrush, pRegion)

   ' // Cleanup
   IF pRegion THEN GdipDeleteRegion(pRegion)
   IF pBrush THEN GdipDeleteBrush(pBrush)
   IF pGraphics THEN GdipDeleteGraphics(pGraphics)

END SUB


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