• Welcome to Jose's Read Only Forum 2023.
 

GDI+: GdipFillRectangles

Started by José Roca, June 23, 2008, 06:25:11 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following example draws a group of rectangles and fills them.

C++


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

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

   // Create an array of RectF objects.
   RectF rect1(0.0f, 0.0f, 100.0f, 200.0f);
   RectF rect2(100.5f, 200.5f, 200.5f, 50.5f);
   RectF rect3(300.8f, 0.8f, 50.8f, 150.8f);
   RectF rects[3] = {rect1, rect2, rect3};

   // Fill the rectangles.
   graphics.FillRectangles(&blackBrush, rects, 3);
}


PowerBASIC


SUB GDIP_FillRectangles (BYVAL hdc AS DWORD)

   LOCAL hStatus AS LONG
   LOCAL pGraphics AS DWORD
   LOCAL pBrush AS DWORD
   DIM   rcf(2) AS RECTF

   hStatus = GdipCreateFromHDC(hdc, pGraphics)

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

   ' // Create an array of RectF objects.
   rcf(0).x = 0.0! : rcf(0).y = 0.0! : rcf(0).Width = 100.0! : rcf(0).Height = 200.0!
   rcf(1).x = 100.5! : rcf(1).y = 200.5! : rcf(1).Width = 200.5! : rcf(1).Height = 50.5!
   rcf(2).x = 300.8! : rcf(2).y = 0.8! : rcf(2).Width = 50.8! : rcf(2).Height = 150.8!

   ' // Fill the rectangles.
   hStatus = GdipFillRectangles(pGraphics, pBrush, rcf(0), 3)

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

END SUB