• Welcome to Jose's Read Only Forum 2023.
 

GDI+: GdipScaleTextureTransform

Started by José Roca, June 29, 2008, 04:29:28 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following example creates a texture brush and sets the transformation of the brush. The code then uses the transformed brush to fill a rectangle.

C++


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

   Image image(L"HouseAndTree.Gif");
   TextureBrush textureBrush(&image);
   textureBrush.RotateTransform(30);                      // first rotate
   textureBrush.ScaleTransform(3, 1, MatrixOrderAppend);  // then scale
   graphics.FillRectangle(&textureBrush, 0, 0, 400, 200);
}


PowerBASIC


SUB GDIP_ScaleTextureTransform (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 = GdipRotateTextureTransform(pTextureBrush, 30, %MatrixOrderPrepend)     ' first rotate
   hStatus = GdipScaleTextureTransform(pTextureBrush, 3, 1, %MatrixOrderAppend)   ' then scale
   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.