• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

GDI+: GdipSetLineWrapMode

Started by José Roca, June 22, 2008, 01:54:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following example creates a linear gradient brush and uses it to fill a rectangle. Next, the code modifies the brush's wrap mode and uses the modified brush to fill another rectangle.

C++


VOID Example_SetWrapMode(HDC hdc)
{
   Graphics myGraphics(hdc);

   LinearGradientBrush linGrBrush(
      Rect(0, 0, 100, 50),
      Color(255, 255, 0, 0),  // red
      Color(255, 0, 0, 255),  // blue
      LinearGradientModeHorizontal);

   // Fill a large area using the gradient brush with the default wrap mode.
   myGraphics.FillRectangle(&linGrBrush, 0, 0, 800, 50);

   linGrBrush.SetWrapMode(WrapModeTileFlipX);

   // Fill a large area using the gradient brush with the new wrap mode.
   myGraphics.FillRectangle(&linGrBrush, 0, 75, 800, 50);
}


PowerBASIC


SUB GDIP_SetLineWrapMode (BYVAL hdc AS DWORD)

   LOCAL hStatus AS LONG
   LOCAL pGraphics AS DWORD
   LOCAL pLinBrush AS DWORD
   LOCAL rc AS RECTF
   LOCAL colorRed AS DWORD
   LOCAL colorBlue AS DWORD

   hStatus = GdipCreateFromHDC(hdc, pGraphics)

   rc.x = 0 : rc.y = 0 : rc.Width = 100 : rc.Height = 50
   colorRed = GDIP_ARGB(255, 255, 0, 0)
   colorBlue = GDIP_ARGB(255, 0, 0, 255)
   hStatus = GdipCreateLineBrushFromRect(rc, colorRed, colorBlue, %LinearGradientModeHorizontal, %WrapModeTile, pLinBrush)

   ' // Fill a large area using the gradient brush with the default wrap mode.
   hStatus = GdipFillRectangle(pGraphics, pLinBrush, 0, 0, 800, 50)

   hStatus = GdipSetLineWrapMode(pLinBrush, %WrapModeTileFlipX)

   ' // Fill a large area using the gradient brush with the new wrap mode.
   hStatus = GdipFillRectangle(pGraphics, pLinBrush, 0, 75, 800, 50)

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

END SUB