• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

GDI+: GdipFillRegion

Started by José Roca, June 22, 2008, 03:41:39 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



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