Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 18:06

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



GDIPlus slow ScreenCapture

Discussion on GDIPlus slow ScreenCapture within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1
 
Silbi's Avatar
 
elite*gold: 0
Join Date: Jan 2008
Posts: 16
Received Thanks: 0
Question GDIPlus slow ScreenCapture

I need to check the color of exactly 1 pixel that always has the same coordinates.

On Windows 10 with Aero my pc takes around 17ms to check the color on the desktop and over 30ms with moving images.

The most time is spent on the _ScreenCapture_Capture function although it only captures 1 pixel.

Is there any faster implementation for this?



I'm using this to calculate the average computing time per pixel:
Code:
#include <GDIPlus.au3> ; for GDI+
#include <ScreenCapture.au3>

; GDI+ method
_GDIPlus_Startup() ;initialize GDI+
$n1 = 200 ; iterations
$start_time=TimerInit()
For $i = 1 To $n1
	Local $iColor = 0
	Local $hHBmp = _ScreenCapture_Capture("", 0, 0, 1, 1) ;create a GDI bitmap by capturing an area on desktop
	Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI to GDI+ bitmap
	_WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore
	$iColor = _GDIPlus_BitmapGetPixel($hBitmap, 0, 0) ;get current pixel color
Next
$time=int(TimerDiff($start_time))/$n1
ConsoleWrite("GDIPlus average ms/pixel: "&$time&@crlf)

;cleanup GDI+ resources
_GDIPlus_Shutdown()

Exit
Silbi is offline  
Old 06/18/2020, 18:24   #2
 
elite*gold: 0
Join Date: Apr 2011
Posts: 363
Received Thanks: 166
Quote:
Originally Posted by Silbi View Post
I need to check the color of exactly 1 pixel that always has the same coordinates.

On Windows 10 with Aero my pc takes around 17ms to check the color on the desktop and over 30ms with moving images.

The most time is spent on the _ScreenCapture_Capture function although it only captures 1 pixel.

Is there any faster implementation for this?



I'm using this to calculate the average computing time per pixel:
Code:
#include <GDIPlus.au3> ; for GDI+
#include <ScreenCapture.au3>

; GDI+ method
_GDIPlus_Startup() ;initialize GDI+
$n1 = 200 ; iterations
$start_time=TimerInit()
For $i = 1 To $n1
	Local $iColor = 0
	Local $hHBmp = _ScreenCapture_Capture("", 0, 0, 1, 1) ;create a GDI bitmap by capturing an area on desktop
	Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI to GDI+ bitmap
	_WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore
	$iColor = _GDIPlus_BitmapGetPixel($hBitmap, 0, 0) ;get current pixel color
Next
$time=int(TimerDiff($start_time))/$n1
ConsoleWrite("GDIPlus average ms/pixel: "&$time&@crlf)

;cleanup GDI+ resources
_GDIPlus_Shutdown()

Exit
Your code is similar to this one, unfortunately since autoit is an interpreted language performance time won't improve
Code:
#include <WinAPI.au3>
$desktopHWND = 0
$desktop_dc = _WinAPI_GetDC($desktopHWND)
$hDll = DllOpen("gdi32.dll")

$n1 = 200 ; iterations
$x = 15
$y = 15
$start_time=TimerInit()

For $i = 1 To $n1
	$res = DllCall($hDll,"dword","GetPixel","HANDLE",$desktop_dc,"int",$x,"int",$y); returns dword of pixel color
 Next


$time=int(TimerDiff($start_time))/$n1
MsgBox(0,"","GDIPlus average ms/pixel: "&$time&@crlf)

 DllClose($hDll)
As you can see you can use c++ for this task since it uses windows apis

Edit 2:
C++ time still 16ms which it isn't that bad
elmarcia is offline  
Reply


Similar Threads Similar Threads
[C++] GDIPLUS Memory Leak
09/08/2019 - C/C++ - 1 Replies
Hello Guys, i need help with some code of mine. I am using GDIPlus and am trying to create a Get Pixel Function. My Function works fine, but unfortunately i get some weird memory issues. My GDI-Object counter in task manager increases, but I dont know why. Especially since it is not a big increase, but a small one, like 2 GDI Objects in 5 minutes eventhough i call the function multiple times per second. I added the function down here. Best regards, thanks for the help! INT GetColor(INT iX,...
Suche aktuelles GDIPlus include
04/22/2015 - AutoIt - 2 Replies
Heyho ich hab nur ein kleines Anliegen, kann mir jemand eine aktuelle Version der GDIPlus.au3 hochladen mitsamt der anhänge wie GDIPlusConstants.au3 etc., bei mir fehlt die _GDIPlus_ImageRotateFlip Funktion und einen offiziellen Download einer neueren .au3 hab ich auf die schnelle nicht gefunden.
GDIPlus - Bild-Objekte werden nicht gelöscht
07/14/2014 - AutoIt - 3 Replies
#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) Global $pic Global $u_pic Global $hGUI
GDIPlus Bitmap.GetHeight() liefert 0
04/30/2012 - C/C++ - 2 Replies
Hallo EPVP, Ich "spiele" mich derzeit mit GDIPlus und will die Höhe/Breite einer Bitmap ermitteln und dann in einer Messagebox auszugeben Leider liefert die Messagebox den Wert 0 aus und ich finde den Fehler einfach nicht... #include <Gdiplus.h> ... #pragma comment(lib, "gdiplus.lib")
Screencapture wird schon beim start ausgeführt.
11/13/2011 - AutoIt - 3 Replies
Wie der Titel schon sagt macht mein momentanes Script schon ein Screenshot wenn ich es öffne, das soll aber so nicht sein. 1. Screenshot bei klicken auf Button 2. Screenshot bei drücken von F12 ( auch hidden ? ) 3. Oben nur ein Minimieren Knopf, im moment ist dort garnichts Script #include <WindowsConstants.au3> #include <ScreenCapture.au3> GUICreate ( "Premaiders Desktop Tool",310,270,-1,-1,$WS_CAPTION)



All times are GMT +2. The time now is 18:06.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.