﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
896	CPU intencive yet simple and powerful addition to PixelSearch	ao0921@…		"Would help greatly because algorithm is VERY CPU intensive and is effectively useless using UDF.

That could search the for a pixel that is the closes to a given $X and $Y input withing a square.
PixelSearchCloseBy ( x, y, squareSize, color, [, shade-variation [, step [, hwnd]]] )
Basically a search starting from he x and y and checking for similar colors around expanding pixel by pixel in square with a side = squareSize.

Here what I came up with to the best of what i know about C++:

int PixelSearchCloseBy(int x, int y, int squareSize, int color){
 int out[2]={-1,-1};
 int left, right, top, bottom, xx;
 HDC hdc = GetDC(HWND_DESKTOP);
 for(int i=1; i < squareSize/2; i++){
         left  = x-i;
         right = x+i;
         top   = y-i;
         bottom= y+i;
         for(xx=left;xx<right;xx++){//check top side of the squre
              if(GetPixel(hdc,xx,top)){out[0]=xx;out[1]=top;return out;}  
         }
         for(xx=top;xx<bottom;xx++){//check right side
              if(GetPixel(hdc,right,xx)){out[0]=right;out[1]=xx;return out;}  
         }
         for(xx=right;xx<left;xx--){//bottom side
              if(GetPixel(hdc,xx,bottom)){out[0]=xx;out[1]=bottom;return out;}  
         }
         for(xx=bottom;xx<top;xx--){//left side
              if(GetPixel(hdc,left,xx)){out[0]=left;out[1]=xx;return out;}  
         }
 }   
} 

// whatever you can do - appreciated"	Feature Request	closed		AutoIt		None	Rejected		
