[VB]Get position of image on screen

12/21/2013 14:45 Growec#1
Hello, please I need your help. I'm trying to get X and Y of image on screen. I know, I must make screenshot and search image (I have image that I'm trying to get location in Resources), but I don't know, how to search it. Can anyone help me? Thanks advance

I have done it! :P
12/22/2013 13:16 MrDami123#2
When you have the image, you need to get the size and then you can calculate the position you need.
When you have always the same imagesize, you could say the programm to choose a spezific area, but I don't recommend it.

[Only registered and activated users can see links. Click Here To Register...]
12/22/2013 13:59 'Heaven.#3
[Only registered and activated users can see links. Click Here To Register...]
12/22/2013 18:06 BeginnerDO#4
Ey,

Here is one fastly and not-tested code file:
First I dont remember is it (x,y) or (y,x). So thats might be the first one which causes problems :)

Code:
private function find_pixel (pic as bitmap, pic2 as bitmap) as string 
pic = 'image where u want to search another picture'
pic2 = 'image you are finding from pic'
Dim pixelCol as color 

for x = 0 to pic.width -1
	for y=0 to pic.height -1
		PixelCol = pic.getPixel(y,x) 'or (x,y) I dont remember..'
		
		if PixelCol = pic2.getPixel(0,0) then 'first pixel is 100% same color'
			'now depend on image size and what u want to do but there is one solution (to check whole image):'
				for i=0 to pic2.width - 1
					for j=0 to pic2.height -1
						if pic.getPixel(y+j, x+i) = pic2.getPixel(i,j) then
						'match -> lets check next pixel'
						else
						'not same image'
						next y 
						exit for 'exit for j'
						end if 
						
						Return y,x 'or (y+j, x+i) or what pixel u want? first is starting pixel and secong last pixel'
					next j
				next i
		end if 
		
	next y
next x

end function
The above is ok for smaller images but its a bit slow. To do the same faster, take a look:
[Only registered and activated users can see links. Click Here To Register...]