The following example creates a texture brush and sets the transformation of the brush. The code then uses the transformed brush to fill an ellipse.
C++
VOID Example_SetTransform(HDC hdc)
{
Graphics graphics(hdc);
Matrix matrix(2, 0, 0, 1, 0, 0); // Horizontal stretch
Image image(L"HouseAndTree.gif");
TextureBrush textureBrush(&image);
textureBrush.SetTransform(&matrix);
graphics.FillEllipse(&textureBrush, 0, 0, 400, 200);
}
PowerBASIC
SUB GDIP_SetTextureTransform (BYVAL hdc AS DWORD)
LOCAL hStatus AS LONG
LOCAL pGraphics AS DWORD
LOCAL pImage AS DWORD
LOCAL pTextureBrush AS DWORD
LOCAL pMatrix AS DWORD
LOCAL strFileName AS STRING
hStatus = GdipCreateFromHDC(hdc, pGraphics)
hStatus = GdipCreateMatrix2(2, 0, 0, 1, 0, 0, pMatrix) ' // Horizontal stretch
strFileName = UCODE$("HouseAndTree.gif")
hStatus = GdipLoadImageFromFile(STRPTR(strFileName), pImage)
hStatus = GdipCreateTexture(pImage, %WrapModeTile, pTextureBrush)
hStatus = GdipSetTextureTransform(pTextureBrush, pMatrix)
hStatus = GdipFillEllipseI(pGraphics, pTextureBrush, 0, 0, 400, 200)
' // Cleanup
IF pMatrix THEN GdipDeleteMatrix(pMatrix)
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/GdipSetTextureTransform.png)