name22

LCD Simulator

Oct 15th, 2011
252
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <WindowsConstants.au3>
  2. #include <GUIConstants.au3>
  3. #include <GDIPlus.au3>
  4. #include <WinAPI.au3>
  5.  
  6. ;Anzahl der "künstlichen" Pixel auf der X und Y Achse
  7. $iPixelsX = 90
  8. $iPixelsY = 30
  9.  
  10. ;Größe der "künstlichen" Pixel
  11. $iPixelWidth = 8
  12. $iPixelHeight = 8
  13.  
  14. $iARGB_BG = 0xFF006000 ;Hintergrundfarbe (ARGB)
  15. $iARGB_Pixel = 0xFF000000 ;Pixelfarbe (ARGB)
  16.  
  17. ;Größe des Fensters (wird aus Pixelgröße und Anzahl berechnet)
  18. $iWidth = $iPixelsX * $iPixelWidth
  19. $iHeight = $iPixelsY * $iPixelHeight
  20.  
  21. Global $aPixelStatus[$iPixelsX][$iPixelsY]
  22. For $iX = 0 To $iPixelsX - 1
  23.     For $iY = 0 To $iPixelsY - 1
  24.         $aPixelStatus[$iX][$iY] = 0
  25.     Next
  26. Next
  27.  
  28. Opt("GUIOnEventMode", 1)
  29.  
  30. $hWnd = GUICreate("LCD Simulator", $iWidth, $iHeight)
  31. GUISetState()
  32.  
  33. $hDC_Window = _WinAPI_GetDC($hWnd)
  34. $hDC_Bitmap = _WinAPI_CreateCompatibleDC($hDC_Window)
  35. $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC_Window, $iWidth, $iHeight)
  36. _WinAPI_SelectObject($hDC_Bitmap, $hBitmap)
  37.  
  38. _GDIPlus_Startup()
  39.  
  40. $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC_Bitmap)
  41. _GDIPlus_GraphicsScaleTransform($hGraphics, $iPixelWidth, $iPixelHeight)
  42. _GDIPlus_GraphicsClear($hGraphics, $iARGB_BG)
  43.  
  44. $hBrush_BG = _GDIPlus_BrushCreateSolid(0xFF6060FF)
  45. $hBrush_PixelOn = _GDIPlus_BrushCreateSolid($iARGB_Pixel)
  46. $hBrush_PixelOff = _GDIPlus_BrushCreateSolid(0xFF6060FF)
  47.  
  48. GUISetOnEvent($GUI_EVENT_CLOSE, "_Close", $hWnd)
  49. GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_Click", $hWnd)
  50. OnAutoItExitRegister("_Exit")
  51.  
  52. _GDIPlus_GraphicsFillRect($hGraphics, 1, 2, $iPixelsX - 2, $iPixelsY - 4, $hBrush_BG)
  53. _WinAPI_BitBlt($hDC_Window, 0, 0, $iWidth, $iHeight, $hDC_Bitmap, 0, 0, $SRCCOPY)
  54.  
  55. While Sleep(1000)
  56. WEnd
  57.  
  58. Func _Click()
  59.     $aCursorPos = GUIGetCursorInfo($hWnd)
  60.     $iX_Pixel = Floor($aCursorPos[0] / $iPixelWidth)
  61.     $iY_Pixel = Floor($aCursorPos[1] / $iPixelHeight)
  62.  
  63.     Switch $aPixelStatus[$iX_Pixel][$iY_Pixel]
  64.         Case 1
  65.             _GDIPlus_GraphicsFillRect($hGraphics, $iX_Pixel, $iY_Pixel, 1, 1, $hBrush_PixelOff)
  66.         Case 0
  67.             _GDIPlus_GraphicsFillRect($hGraphics, $iX_Pixel, $iY_Pixel, 1, 1, $hBrush_PixelOn)
  68.     EndSwitch
  69.     _WinAPI_BitBlt($hDC_Window, 0, 0, $iWidth, $iHeight, $hDC_Bitmap, 0, 0, $SRCCOPY)
  70.     $aPixelStatus[$iX_Pixel][$iY_Pixel] = BitXOR($aPixelStatus[$iX_Pixel][$iY_Pixel], 1)
  71. EndFunc
  72.  
  73. Func _Close()
  74.     Exit
  75. EndFunc
  76.  
  77. Func _Exit()
  78.     _WinAPI_ReleaseDC($hWnd, $hDC_Window)
  79.     _WinAPI_DeleteDC($hDC_Bitmap)
  80.     _WinAPI_DeleteObject($hBitmap)
  81.  
  82.     _GDIPlus_GraphicsDispose($hGraphics)
  83.     _GDIPlus_BrushDispose($hBrush_PixelOn)
  84.     _GDIPlus_BrushDispose($hBrush_PixelOff)
  85.     _GDIPlus_BrushDispose($hBrush_BG)
  86.     _GDIPlus_Shutdown()
  87. EndFunc
  88.  
  89.  
  90. ; #FUNCTION# ====================================================================================================================
  91. ; Name...........: _GDIPlus_GraphicsScaleTransform
  92. ; Description ...: Updates a Graphics object's world transformation matrix with the product of itself and a scaling matrix
  93. ; Syntax.........: _GDIPlus_GraphicsScaleTransform($hGraphics, $nScaleX, $nScaleY[, $iOrder = 0])
  94. ; Parameters ....: $hGraphics - Pointer to a Graphics object
  95. ;                  $nX        - The horizontal scaling factor in the scaling matrix
  96. ;                  $nY        - The vertical scaling factor in the scaling matrix
  97. ;                  $iOrder    - Order of matrices multiplication:
  98. ;                  |0 - The scaling matrix is on the left
  99. ;                  |1 - The scaling matrix is on the right
  100. ; Return values .: Success      - True
  101. ;                  Failure      - False and either:
  102. ;                  |@error and @extended are set if DllCall failed
  103. ;                  |$GDIP_STATUS contains a non zero value specifying the error code
  104. ; Remarks .......: None
  105. ; Related .......: None
  106. ; Link ..........; @@MsdnLink@@ GdipScaleWorldTransform
  107. ; Example .......; No
  108. ; ===============================================================================================================================
  109. Func _GDIPlus_GraphicsScaleTransform($hGraphics, $nScaleX, $nScaleY, $iOrder = 0)
  110.     Local $aResult = DllCall($ghGDIPDll, "uint", "GdipScaleWorldTransform", "hwnd", $hGraphics, "float", $nScaleX, "float", $nScaleY, "int", $iOrder)
  111.  
  112.     If @error Then Return SetError(@error, @extended, False)
  113.     $GDIP_STATUS = $aResult[0]
  114.     Return $aResult[0] = 0
  115. EndFunc   ;==>_GDIPlus_GraphicsScaleTransform
  116.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×