C++ Pixel Search Help

01/20/2017 09:27 pra3337#1
Auto it:
Code:
 $pix = PixelSearch(0,590,177,767,0x550043)
  if IsArray($pix)  =  True Then
   EndIf
C++:
Code:
 HDC hdc;
	hdc = GetDC(GetActiveWindow());
	int x, y ;

			for(x=0; x<177;x++)
			{
		for(y=590; y<767;y++)
		{
COLORREF CC=  GetPixel( hdc, x,y );
if(CC== 4455333)
{
cout <<"found!<<endl;
}
}
}
in auto it its faster to search for the pixel >
but in c++ take 10 sec to find!
so how do i speed it in C++!!!
01/20/2017 10:55 Shadow992#2
Quote:
Originally Posted by pra3337 View Post
Auto it:
Code:
 $pix = PixelSearch(0,590,177,767,0x550043)
  if IsArray($pix)  =  True Then
   EndIf
C++:
Code:
 HDC hdc;
	hdc = GetDC(GetActiveWindow());
	int x, y ;

			for(x=0; x<177;x++)
			{
		for(y=590; y<767;y++)
		{
COLORREF CC=  GetPixel( hdc, x,y );
if(CC== 4455333)
{
cout <<"found!<<endl;
}
}
}
in auto it its faster to search for the pixel >
but in c++ take 10 sec to find!
so how do i speed it in C++!!!
You do it by learning the language! Obviously everytime calling GetPixel is slow as fuck. Better get the whole Image/Screen at once, safe it to a buffer and iterate over buffer.

However there is one rule of thumb for C++ and PixelSearch:
"You do not do it in C++! You just dont!"