Function Reference


_WinAPI_BitBlt

Performs a bit-block transfer of color data

#include <WinAPIGdi.au3>
_WinAPI_BitBlt ( $hDestDC, $iXDest, $iYDest, $iWidth, $iHeight, $hSrcDC, $iXSrc, $iYSrc, $iROP )

Parameters

$hDestDC Handle to the destination device context
$iXDest X value of the upper-left corner of the destination rectangle
$iYDest Y value of the upper-left corner of the destination rectangle
$iWidth Width of the source and destination rectangles
$iHeight Height of the source and destination rectangles
$hSrcDC Handle to the source device context
$iXSrc X value of the upper-left corner of the source rectangle
$iYSrc Y value of the upper-left corner of the source rectangle
$iROP Specifies a raster operation code. These codes define how the color data for the source rectangle is to be combined with the color data for the destination rectangle to achieve the final color:
$BLACKNESS - Fills the destination rectangle using the color associated with palette index 0
$CAPTUREBLT - Includes any window that are layered on top of your window in the resulting image
$DSTINVERT - Inverts the destination rectangle
$MERGECOPY - Merges the color of the source rectangle with the brush currently selected in hDest, by using the AND operator.
$MERGEPAINT - Merges the color of the inverted source rectangle with the colors of the destination rectangle by using the OR operator.
$NOMIRRORBITMAP - Prevents the bitmap from being mirrored
$NOTSRCCOPY - Copies the inverted source rectangle to the destination
$NOTSRCERASE - Combines the colors of the source and destination rectangles by using the OR operator and then inverts the resultant color.
$PATCOPY - Copies the brush selected in hdcDest, into the destination bitmap
$PATINVERT - Combines the colors of the brush currently selected in hDest, with the colors of the destination rectangle by using the XOR operator.
$PATPAINT - Combines the colors of the brush currently selected in hDest, with the colors of the inverted source rectangle by using the OR operator. The result of this operation is combined with the color of the destination rectangle by using the OR operator.
$SRCAND - Combines the colors of the source and destination rectangles by using the AND operator
$SRCCOPY - Copies the source rectangle directly to the destination rectangle
$SRCERASE - Combines the inverted color of the destination rectangle with the colors of the source rectangle by using the AND operator.
$SRCINVERT - Combines the colors of the source and destination rectangles by using the XOR operator
$SRCPAINT - Combines the colors of the source and destination rectangles by using the OR operator
$WHITENESS - Fills the destination rectangle using the color associated with index 1 in the physical palette.

Return Value

Success: True
Failure: False

See Also

Search BitBlt in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WinAPIGdi.au3>
#include <WinAPIGdiDC.au3>
#include <WinAPIHObj.au3>
#include <WindowsConstants.au3>

Global $g_hGUI, $g_hHBITMAP, $g_hDC, $g_hDC_Backbuffer, $g_oDC_Obj, $g_hGfxCtxt, $g_hPen

Example()

Func Example()
        AutoItSetOption("GUIOnEventMode", 1)

        _GDIPlus_Startup() ;initialize GDI+
        Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x202020 ;$iBGColor format RRGGBB

        $g_hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
        GUISetBkColor($iBgColor, $g_hGUI) ;set GUI background color
        GUISetState(@SW_SHOW)

        ;create a faster buffered graphics frame set for smoother gfx object movements
        Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight) ;create an empty bitmap
        $g_hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) ;convert GDI+ bitmap to GDI bitmap
        _GDIPlus_BitmapDispose($hBitmap) ;delete GDI+ bitmap because not needed anymore

        $g_hDC = _WinAPI_GetDC($g_hGUI) ;get device context from GUI
        $g_hDC_Backbuffer = _WinAPI_CreateCompatibleDC($g_hDC) ;creates a memory device context compatible with the specified device
        $g_oDC_Obj = _WinAPI_SelectObject($g_hDC_Backbuffer, $g_hHBITMAP) ;selects an object into the specified device context
        $g_hGfxCtxt = _GDIPlus_GraphicsCreateFromHDC($g_hDC_Backbuffer) ;create a graphics object from a device context (DC)
        _GDIPlus_GraphicsSetSmoothingMode($g_hGfxCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;set smoothing mode (8 X 4 box filter)
        _GDIPlus_GraphicsSetPixelOffsetMode($g_hGfxCtxt, $GDIP_PIXELOFFSETMODE_HIGHQUALITY)

        $g_hPen = _GDIPlus_PenCreate() ;create a pen object

        GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

        Local Const $fDeg = ACos(-1) / 180 ;ACos(-1) is nearly pi
        Local $iX_Center = $iWidth / 2, $iY_Center = $iHeight / 2, $iXPos, $iYPos, $fAngle = 0, $iRound = 0
        Local Const $iDots = 7, $fAngelDist = 360 / $iDots, $iRadius = 250
        Local $aCoordinates[$iDots][2] ;create an array to save coordinates of the x/y coordinates
        Do
                _GDIPlus_GraphicsClear($g_hGfxCtxt, 0xFF000000 + $iBgColor) ;clear bitmap with given color (AARRGGBB format)
                For $i = 0 To $iDots - 1
                        $iXPos = $iX_Center + Cos($fAngle * $fDeg) * $iRadius ;calculate x position
                        $iYPos = $iY_Center + Sin($fAngle * $fDeg) * $iRadius ;calculate y position
                        $aCoordinates[$i][0] = $iXPos
                        $aCoordinates[$i][1] = $iYPos
                        _GDIPlus_PenSetColor($g_hPen, 0xFFFFFF00) ;set pen color for inner lines
                        _GDIPlus_PenSetWidth($g_hPen, 2) ;set pen size for outer lines
                        _GDIPlus_GraphicsDrawLine($g_hGfxCtxt, $aCoordinates[$i][0], $aCoordinates[$i][1], _ ;draw inner lines
                                        $aCoordinates[Mod(($i + $iDots / 2), $iDots)][0], $aCoordinates[Mod(($i + $iDots / 2), $iDots)][1], $g_hPen) ;draw to opposite side
                        _GDIPlus_PenSetColor($g_hPen, 0xFFFF8000) ;set pen color
                        _GDIPlus_PenSetWidth($g_hPen, 3) ;set pen size
                        ;array of coordinates should be filled before first draw to screen
                        If $i < $iDots - 1 Then _GDIPlus_GraphicsDrawLine($g_hGfxCtxt, $aCoordinates[$i][0], $aCoordinates[$i][1], $aCoordinates[$i + 1][0], $aCoordinates[$i + 1][1], $g_hPen) ;;draw outer lines
                        $fAngle += $fAngelDist ;increase angle to next dot
                Next
                ;draw last line to 1st line
                _GDIPlus_GraphicsDrawLine($g_hGfxCtxt, $aCoordinates[$i - 1][0], $aCoordinates[$i - 1][1], $aCoordinates[0][0], $aCoordinates[0][1], $g_hPen)

                If $iRound Then _WinAPI_BitBlt($g_hDC, 0, 0, $iWidth, $iHeight, $g_hDC_Backbuffer, 0, 0, $SRCCOPY) ;copy backbuffer to screen (GUI)
                $fAngle -= 0.5 ;decrease overall angle
                $iRound += 1
        Until Not Sleep(30) ;Sleep() always returns 1 and Not 1 is 0 correspond to False

        _Exit()
EndFunc   ;==>Example

Func _Exit() ;cleanup GDI+ resources
        _GDIPlus_PenDispose($g_hPen)
        _WinAPI_SelectObject($g_hDC_Backbuffer, $g_oDC_Obj)
        _GDIPlus_GraphicsDispose($g_hGfxCtxt)
        _WinAPI_DeleteObject($g_hHBITMAP)
        _WinAPI_ReleaseDC($g_hGUI, $g_hDC)
        GUIDelete($g_hGUI)
        Exit
EndFunc   ;==>_Exit