Funktionreferenz


_WinAPI_PlgBlt


Performs a bit-block transfer of color data from the specified rectangle in the source DC to the specified parallelogram in the DC context

#include <WinAPIGdi.au3>
_WinAPI_PlgBlt ( $hDestDC, Const ByRef $aPoint, $hSrcDC, $iXSrc, $iYSrc, $iWidth, $iHeight [, $hMask = 0 [, $iXMask = 0 [, $iYMask = 0]]] )

Parameter

$hDestDC Handle to the destination device context.
$aPoint The 2D array ([x1, y1], [x2, y2], [x3, y3]) that identify three corners of the destination parallelogram.
The upper-left corner of the source rectangle is mapped to the first point in this array, the upper-right
corner to the second point in this array, and the lower-left corner to the third point. The lower-right
corner of the source rectangle is mapped to the implicit fourth point in the parallelogram.
$hSrcDC Handle to the source device context.
$iXSrc The x-coordinate, in logical units, of the upper-left corner of the source rectangle.
$iYSrc The y-coordinate, in logical units, of the upper-left corner of the source rectangle.
$iWidth The width, in logical units, of the source rectangle.
$iHeight The height, in logical units, of the source rectangle.
$hMask [optional] Handle to the monochrome bitmap that is used to mask the colors of the source rectangle.
$iXMask [optional] The x-coordinate, in logical units, of the upper-left corner of the monochrome bitmap. Default is 0.
$iYMask [optional] The y-coordinate, in logical units, of the upper-left corner of the monochrome bitmap. Default is 0.

Rückgabewert

Success: True
Failure: False

Bemerkungen

The _WinAPI_PlgBlt() works with device-dependent bitmaps. If the source and destination device contexts represent
incompatible devices, the function returns an error.

The fourth vertex of the parallelogram (D) is defined by treating the first three points (A, B, and C) as vectors
and computing D = B + CA.

If the bitmask is specified, a value of 1 in the mask indicates that the source pixel color should be copied to the
destination. A value of 0 in the mask indicates that the destination pixel color is not to be changed. If the mask
rectangle is smaller than the source and destination rectangles, the function replicates the mask pattern.

Scaling, translation, and reflection transformations are allowed in the source device context; however, rotation
and shear transformations are not. If the mask bitmap is not a monochrome bitmap, an error occurs. The stretching
mode for the destination device context is used to determine how to stretch or compress the pixels, if that is
necessary.

Siehe auch

Suche nach PlgBlt in der MSDN Bibliothek.

Beispiel

#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIGdiDC.au3>
#include <WinAPIHObj.au3>
#include <WinAPIMisc.au3>
#include <WinAPIRes.au3>
#include <WinAPISysWin.au3>
#include <WindowsConstants.au3>

Opt('TrayAutoPause', 0)

; Load image
Global $g_hBitmap = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Compass.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
Local $tSIZE = _WinAPI_GetBitmapDimension($g_hBitmap)
Local $W = DllStructGetData($tSIZE, 'X')
Local $H = DllStructGetData($tSIZE, 'Y')

; Create GUI
Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), $W, $H + 26)
Global $g_idPic = GUICtrlCreatePic('', 0, 0, $W, $H)
GUICtrlCreateGraphic(0, $H, $W, 1)
GUICtrlSetBkColor(-1, 0xDFDFDF)
Global $g_idSlider = GUICtrlCreateSlider(0, $H + 1, $W, 25, BitOR($TBS_BOTH, $TBS_NOTICKS))
Global $g_hSlider = GUICtrlGetHandle(-1)
GUICtrlSetLimit(-1, 360, 0)
GUICtrlSetData(-1, 0)

; Set bitmap to control with rotate
_SetBitmapRotate($g_idPic, $g_hBitmap, 0)

; Register WM_HSCROLL message for live scrolling and show GUI
GUIRegisterMsg($WM_HSCROLL, 'WM_HSCROLL')
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _SetBitmapRotate($hWnd, $hBitmap, $iAngle)
    If Not IsHWnd($hWnd) Then
        $hWnd = GUICtrlGetHandle($hWnd)
        If Not $hWnd Then
            Return 0
        EndIf
    EndIf

    Local $aW[2], $aH[2]
    Local $aPoint[3][2]
    Local $tRECT = _WinAPI_GetClientRect($hWnd)
    $aW[0] = DllStructGetData($tRECT, 3) - DllStructGetData($tRECT, 1)
    $aH[0] = DllStructGetData($tRECT, 4) - DllStructGetData($tRECT, 2)
    Local $tSIZE = _WinAPI_GetBitmapDimension($g_hBitmap)
    $aW[1] = DllStructGetData($tSIZE, 1)
    $aH[1] = DllStructGetData($tSIZE, 2)
    $aPoint[0][0] = ($aW[0] - $aW[1]) / 2
    $aPoint[0][1] = ($aH[0] - $aH[1]) / 2
    $aPoint[1][0] = $aPoint[0][0] + $aW[1]
    $aPoint[1][1] = $aPoint[0][1]
    $aPoint[2][0] = $aPoint[0][0]
    $aPoint[2][1] = $aPoint[0][1] + $aH[1]
    Local $hDC = _WinAPI_GetDC($hWnd)
    Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC)
    Local $hMask = _WinAPI_CreateBitmap($aW[0], $aH[0], 1, 1)
    Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hMask)
    Local $hBrush = _WinAPI_SelectObject($hDestDC, _WinAPI_GetStockObject($DC_BRUSH))
    Local $hPen = _WinAPI_SelectObject($hDestDC, _WinAPI_GetStockObject($DC_PEN))
    _WinAPI_SetDCBrushColor($hDestDC, 0xFFFFFF)
    _WinAPI_SetDCPenColor($hDestDC, 0xFFFFFF)
    _WinAPI_Ellipse($hDestDC, _WinAPI_CreateRectEx($aPoint[0][0] + 43, $aPoint[0][1] + 43, $aPoint[1][0] - 86, $aPoint[2][1] - 86))
    Local $hBmp = _WinAPI_CreateCompatibleBitmapEx($hDC, $aW[0], $aH[0], 0xFFFFFF)
    _WinAPI_SelectObject($hDestDC, $hBrush)
    _WinAPI_SelectObject($hDestDC, $hPen)
    _WinAPI_SelectObject($hDestDC, $hBmp)
    Local $hSrcDC = _WinAPI_CreateCompatibleDC($hDC)
    Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hBitmap)
    _WinAPI_RotatePoints($aPoint, $aW[0] / 2, $aH[0] / 2, $iAngle)
    _WinAPI_PlgBlt($hDestDC, $aPoint, $hSrcDC, 0, 0, $aW[1], $aH[1])
    _WinAPI_RotatePoints($aPoint, $aW[0] / 2, $aH[0] / 2, -2 * $iAngle)
    _WinAPI_PlgBlt($hDestDC, $aPoint, $hSrcDC, 0, 0, $aW[1], $aH[1], $hMask)
    _WinAPI_SelectObject($hDestDC, $hDestSv)
    _WinAPI_DeleteDC($hDestDC)
    _WinAPI_SelectObject($hSrcDC, $hSrcSv)
    _WinAPI_DeleteDC($hSrcDC)
    _WinAPI_DeleteObject($hMask)
    _WinAPI_ReleaseDC($hWnd, $hDC)
    Local $hObj = _SendMessage($hWnd, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp)
    If $hObj Then
        _WinAPI_DeleteObject($hObj)
    EndIf
    $hObj = _SendMessage($hWnd, $STM_GETIMAGE)
    If $hObj <> $hBmp Then
        _WinAPI_DeleteObject($hBmp)
    EndIf
    Return 1
EndFunc   ;==>_SetBitmapRotate

Func WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam, $lParam

    Switch $hWnd
        Case $g_hForm
            Switch $lParam
                Case $g_hSlider
                    _SetBitmapRotate($g_idPic, $g_hBitmap, GUICtrlRead($g_idSlider))
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_HSCROLL