Function Reference


_GDIPlus_TextureCreate2

Creates a TextureBrush object based on an image, a wrap mode and a defining rectangle

#include <GDIPlus.au3>
_GDIPlus_TextureCreate2 ( $hImage, $nX, $nY, $nWidth, $nHeight [, $iWrapMode = 0] )

Parameters

$hImage Pointer to an Image object
$nX Leftmost coordinate of the image portion to be used by this brush
$nY Uppermost coordinate of the image portion to be used by this brush
$nWidth Width of the brush and width of the image portion to be used by the brush
$nHeight Height of the brush and height of the image portion to be used by the brush
$iWrapMode [optional] Wrap mode that specifies how repeated copies of an image are used to tile an area when it is
    0 - Tiling without flipping
    1 - Tiles are flipped horizontally as you move from one tile to the next in a row
    2 - Tiles are flipped vertically as you move from one tile to the next in a column
    3 - Tiles are flipped horizontally as you move along a row and flipped vertically as you move along a column
    4 - No tiling takes place

Return Value

Success: a pointer to a new TextureBrush object.
Failure: 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

After you are done with the object, call _GDIPlus_BrushDispose() to release the object resources.

Related

_GDIPlus_BrushDispose

See Also

Search GdipCreateTexture2 in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; X64 running support
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"

    ;get AutoIt install dir
    Local $sRegPath = "HKLM\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt"

    Local $sFile = RegRead($sRegPath, "InstallDir") & "\Examples\GUI\logo4.gif"
    If Not FileExists($sFile) Then
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", $sFile & " not found!", 30)
        Return False
    EndIf

    _GDIPlus_Startup()
    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile) ;create an image object based on a file
    If @error Then
        _GDIPlus_Shutdown()
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "An error has occured - unable to load image!", 30)
        Return False
    EndIf

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", 320, 200)
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a Graphics object from a window handle
    _GDIPlus_GraphicsClear($hGraphics, 0xFF404040) ;clear graphic handle with dark grey (background)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    Local $hTexture = _GDIPlus_TextureCreate2($hImage, 5, 4, 59, 59) ;create texture brush only from a defined rectangle
    _GDIPlus_GraphicsFillEllipse($hGraphics, 10, 40, 300, 120, $hTexture) ;draw ellipse with texture as a brush

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup resources
    _GDIPlus_BrushDispose($hTexture)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example