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 30, 2008, 04:12:39 AM

Title: GDI+: GdipSetTextureWrapMode
Post by: José Roca on June 30, 2008, 04:12:39 AM


The following example creates a texture brush, sets the wrap mode of the brush, and uses the brush to fill a rectangle.

C++


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

   Image image(L"HouseAndTree.gif");
   TextureBrush textureBrush(&image);
   textureBrush.SetWrapMode(WrapModeTileFlipX);
   graphics.FillRectangle(&textureBrush, 0, 0, 400, 200);
}


PowerBASIC


SUB GDIP_SetTextureWrapMode (BYVAL hdc AS DWORD)

   LOCAL hStatus AS LONG
   LOCAL pGraphics AS DWORD
   LOCAL pImage AS DWORD
   LOCAL pTextureBrush AS DWORD
   LOCAL strFileName AS STRING

   hStatus = GdipCreateFromHDC(hdc, pGraphics)

   strFileName = UCODE$("HouseAndTree.gif")
   hStatus = GdipLoadImageFromFile(STRPTR(strFileName), pImage)
   hStatus = GdipCreateTexture(pImage, %WrapModeTile, pTextureBrush)
   hStatus = GdipSetTextureWrapMode(pTextureBrush, %WrapModeTileFlipX)
   hStatus = GdipFillRectangleI(pGraphics, pTextureBrush, 0, 0, 400, 200)

   ' // Cleanup
   IF pImage THEN GdipDisposeImage(pImage)
   IF pTextureBrush THEN GdipDeleteBrush(pTextureBrush)
   IF pGraphics THEN GdipDeleteGraphics(pGraphics)

END SUB


The following illustration shows the output of the preceding code.

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