Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <WindowsConstants.au3>
- #include <GUIConstants.au3>
- #include <GDIPlus.au3>
- #include <WinAPI.au3>
- ;Anzahl der "künstlichen" Pixel auf der X und Y Achse
- $iPixelsX = 90
- $iPixelsY = 30
- ;Größe der "künstlichen" Pixel
- $iPixelWidth = 8
- $iPixelHeight = 8
- $iARGB_BG = 0xFF006000 ;Hintergrundfarbe (ARGB)
- $iARGB_Pixel = 0xFF000000 ;Pixelfarbe (ARGB)
- ;Größe des Fensters (wird aus Pixelgröße und Anzahl berechnet)
- $iWidth = $iPixelsX * $iPixelWidth
- $iHeight = $iPixelsY * $iPixelHeight
- Global $aPixelStatus[$iPixelsX][$iPixelsY]
- For $iX = 0 To $iPixelsX - 1
- For $iY = 0 To $iPixelsY - 1
- $aPixelStatus[$iX][$iY] = 0
- Next
- Next
- Opt("GUIOnEventMode", 1)
- $hWnd = GUICreate("LCD Simulator", $iWidth, $iHeight)
- GUISetState()
- $hDC_Window = _WinAPI_GetDC($hWnd)
- $hDC_Bitmap = _WinAPI_CreateCompatibleDC($hDC_Window)
- $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC_Window, $iWidth, $iHeight)
- _WinAPI_SelectObject($hDC_Bitmap, $hBitmap)
- _GDIPlus_Startup()
- $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC_Bitmap)
- _GDIPlus_GraphicsScaleTransform($hGraphics, $iPixelWidth, $iPixelHeight)
- _GDIPlus_GraphicsClear($hGraphics, $iARGB_BG)
- $hBrush_BG = _GDIPlus_BrushCreateSolid(0xFF6060FF)
- $hBrush_PixelOn = _GDIPlus_BrushCreateSolid($iARGB_Pixel)
- $hBrush_PixelOff = _GDIPlus_BrushCreateSolid(0xFF6060FF)
- GUISetOnEvent($GUI_EVENT_CLOSE, "_Close", $hWnd)
- GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_Click", $hWnd)
- OnAutoItExitRegister("_Exit")
- _GDIPlus_GraphicsFillRect($hGraphics, 1, 2, $iPixelsX - 2, $iPixelsY - 4, $hBrush_BG)
- _WinAPI_BitBlt($hDC_Window, 0, 0, $iWidth, $iHeight, $hDC_Bitmap, 0, 0, $SRCCOPY)
- While Sleep(1000)
- WEnd
- Func _Click()
- $aCursorPos = GUIGetCursorInfo($hWnd)
- $iX_Pixel = Floor($aCursorPos[0] / $iPixelWidth)
- $iY_Pixel = Floor($aCursorPos[1] / $iPixelHeight)
- Switch $aPixelStatus[$iX_Pixel][$iY_Pixel]
- Case 1
- _GDIPlus_GraphicsFillRect($hGraphics, $iX_Pixel, $iY_Pixel, 1, 1, $hBrush_PixelOff)
- Case 0
- _GDIPlus_GraphicsFillRect($hGraphics, $iX_Pixel, $iY_Pixel, 1, 1, $hBrush_PixelOn)
- EndSwitch
- _WinAPI_BitBlt($hDC_Window, 0, 0, $iWidth, $iHeight, $hDC_Bitmap, 0, 0, $SRCCOPY)
- $aPixelStatus[$iX_Pixel][$iY_Pixel] = BitXOR($aPixelStatus[$iX_Pixel][$iY_Pixel], 1)
- EndFunc
- Func _Close()
- Exit
- EndFunc
- Func _Exit()
- _WinAPI_ReleaseDC($hWnd, $hDC_Window)
- _WinAPI_DeleteDC($hDC_Bitmap)
- _WinAPI_DeleteObject($hBitmap)
- _GDIPlus_GraphicsDispose($hGraphics)
- _GDIPlus_BrushDispose($hBrush_PixelOn)
- _GDIPlus_BrushDispose($hBrush_PixelOff)
- _GDIPlus_BrushDispose($hBrush_BG)
- _GDIPlus_Shutdown()
- EndFunc
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _GDIPlus_GraphicsScaleTransform
- ; Description ...: Updates a Graphics object's world transformation matrix with the product of itself and a scaling matrix
- ; Syntax.........: _GDIPlus_GraphicsScaleTransform($hGraphics, $nScaleX, $nScaleY[, $iOrder = 0])
- ; Parameters ....: $hGraphics - Pointer to a Graphics object
- ; $nX - The horizontal scaling factor in the scaling matrix
- ; $nY - The vertical scaling factor in the scaling matrix
- ; $iOrder - Order of matrices multiplication:
- ; |0 - The scaling matrix is on the left
- ; |1 - The scaling matrix is on the right
- ; Return values .: Success - True
- ; Failure - False and either:
- ; |@error and @extended are set if DllCall failed
- ; |$GDIP_STATUS contains a non zero value specifying the error code
- ; Remarks .......: None
- ; Related .......: None
- ; Link ..........; @@MsdnLink@@ GdipScaleWorldTransform
- ; Example .......; No
- ; ===============================================================================================================================
- Func _GDIPlus_GraphicsScaleTransform($hGraphics, $nScaleX, $nScaleY, $iOrder = 0)
- Local $aResult = DllCall($ghGDIPDll, "uint", "GdipScaleWorldTransform", "hwnd", $hGraphics, "float", $nScaleX, "float", $nScaleY, "int", $iOrder)
- If @error Then Return SetError(@error, @extended, False)
- $GDIP_STATUS = $aResult[0]
- Return $aResult[0] = 0
- EndFunc ;==>_GDIPlus_GraphicsScaleTransform
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement