Jump to content

Search the Community

Showing results for tags '_gdiplus_graphicsclear'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. I'm really new to working with the GDI API. What I want my script to do is: get a screenshot of a 100x100 region go through a list of captured colors in this region highlight them in red prompt if I want to continue to another captured color somehow make the red parts of the region go back to normal/reset/clear/revert to original screenshot Repeat Steps 2 to 4 Here's my work on how far I got: #include <ScreenCapture.au3> #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <Array.au3> Global $g_hGUI, $g_hGfxCtxt, $g_hBitmap, $g_hBMP, $g_hGraphics HotKeySet('{F1}', 'Example') While 1 WEnd Func Example() AutoItSetOption("GUIOnEventMode", 1) Opt("MouseCoordMode", 0) Local $iW = 50, $iH = 50 Local Const $iWidth = $iW * 2, $iHeight = $iH * 2, $iBgColor = 0x303030 ;$iBGColor format RRGGBB ; create a GDI bitmap by capturing a confined region with the mouse cursor as the center $myMouseCoords = MouseGetPos() Local $hHBmp = _ScreenCapture_Capture("", $myMouseCoords[0] - $iW, $myMouseCoords[1] - $iH, $myMouseCoords[0] + $iW, $myMouseCoords[1] + $iH, False) _GDIPlus_Startup() ;initialize GDI+ ; create a GUI with the dimensions fitting the captured region for previewing screenshot $g_hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) GUISetBkColor($iBgColor, $g_hGUI) ;set GUI background color GUISetState(@SW_SHOW) #Region GDI+ setup $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;create a graphics object from a window handle $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $g_hGraphics) ; Scaling: Magnify the captured screen by /2, zoom out by *2 $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap) $g_hBMP = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI to GDI+ bitmap _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore Local $iX = 0.0, $iY = 0.0 ;define start coordinate #EndRegion GDI+ setup Local $aColorCoords[$iHeight * $iWidth][2], $pixelCounter For $iRow = 0 To $iHeight - 1 For $iCol = 0 To $iWidth - 1 $iColor = _GDIPlus_BitmapGetPixel($g_hBMP, $iCol, $iRow) ;get current pixel color $aColorCoords[$pixelCounter][0] = $iColor $aColorCoords[$pixelCounter][1] = $iCol & "," & $iRow $pixelCounter += 1 Next Next GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $aUniqueColors = _ArrayUnique($aColorCoords, 0, 0, 0, $ARRAYUNIQUE_NOCOUNT) ; Creates an array of unique colors from the whole capture _ArrayColInsert($aUniqueColors, 1) #Region CORE PROBLEM For $findUnique = 0 To UBound($aUniqueColors) - 1 ; Find and stores the total of every color captured _GDIPlus_GraphicsClear($g_hGfxCtxt, 0xFF000000 + $iBgColor) ; clear bitmap for repaint $aColorIndexes = _ArrayFindAll($aColorCoords, $aUniqueColors[$findUnique][0]) $aUniqueColors[$findUnique][1] = UBound($aColorIndexes) $totalQueries = UBound($aUniqueColors) For $getIndex = 0 To UBound($aColorIndexes) - 1 $sThisCoordSet = $aColorCoords[$aColorIndexes[$getIndex]][1] $iCommaPosition = StringInStr($sThisCoordSet, ',') $iColorCoordX = StringMid($sThisCoordSet, 1, $iCommaPosition - 1) ; The index yields a string of the coords; they need to be parsed to integers $iColorCoordY = StringMid($sThisCoordSet, $iCommaPosition + 1) ; +1 ignores the comma p('$iColorCoordX', $iColorCoordX) p('$iColorCoordY', $iColorCoordY) _GDIPlus_BitmapSetPixel($g_hBMP, $iColorCoordX, $iColorCoordY, 0xFFFF0000) Next _GDIPlus_GraphicsDrawImage($g_hGfxCtxt, $g_hBMP, $iX, $iY) ; draw bitmap to backbuffer _GDIPlus_GraphicsDrawImageRect($g_hGraphics, $g_hBitmap, 0, 0, $iWidth, $iHeight) ;copy drawn bitmap to graphics handle (GUI) Sleep(100) Next #EndRegion CORE PROBLEM EndFunc ;==>Example Func _Exit() ;cleanup GDI+ resources _GDIPlus_GraphicsDispose($g_hGfxCtxt) _GDIPlus_GraphicsDispose($g_hGraphics) _GDIPlus_BitmapDispose($g_hBitmap) _GDIPlus_BitmapDispose($g_hBMP) _GDIPlus_Shutdown() GUIDelete($g_hGUI) Exit EndFunc ;==>_Exit _GDIPLUS_GraphicsClear() doesn't work. I tried it on $g_hGraphics, $g_hBitmap, $g_hGfxCtxt, and $g_hBMP which are my graphics objects located in #Region GDI+ setup. My usage is under the #Region CORE PROBLEM. I wonder what I'm misunderstanding here.
×
×
  • Create New...