Link to home
Start Free TrialLog in
Avatar of lisa_g
lisa_g

asked on

Locating Bitmaps

Hi ppl,

Does anyone know how to locate a bitmap on the screen that is not part of your program - ie reading pixels from absolute coordinates on the screen. For example, in wordpad, finding the coordinates of the top left hand corner of the "save" icon by reading pixels and matching it with a "save" icon bitmap in memory, if you get what i mean. Or if there is a better way than that which works generally (not wordpad specific) i'd love to know. Wordpad is just an example btw, that's not the exact implementation of what i want to do :)

I'm using Delphi 2 btw.
Avatar of lisa_g
lisa_g

ASKER

Edited text of question
Hi,
I think you try to solve the general problems of patern recognition :-) It is FEASIBLE only if the image you have is approximatelly equivalent to the image on the screen. The easiest way is as follows:

1 - Get the screen DC
2 - Starting from the top left corner of the screen BY USING MEAN SQUARE ERROR criterion and using IMAGE DIFFERENCE examine all the screen and choose the position giving the minimum difference.

This is time consuming but not problematic...
Regards, (ANY WAY WHY?)
Igor
Hello.

I don't know about Delphi2, but if you want to direct access to the screen, you have a global varibe named "Screen", declard in the "Form.pas" unit, at least in Delphi3.

If you want to access other application, you'll have to mass with API calls. good luck.

Semuel.
Avatar of lisa_g

ASKER

Well, i'll have an exact copy of the bitmap in memory, ie it matches what is on the screen perfectly - i just want to know where it is... so how do i read pixels off the screen? Nasty stuff is it? :(
ASKER CERTIFIED SOLUTION
Avatar of Matvey
Matvey

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lisa_g

ASKER

Thanks a lot...

Should be handy :)

(have you tested the code?)
Hi there,
The code Matvey provides is good for exact match. (Copyright? how funny thanks...)
For inexact match we should compute each pixel difference and sum sqr's of all then
sqrt the result. By choosing the (x,y) that gives minimum diference sum we do inexact match which is known in literature as Optimum Match in Mean Square Distance Sense.
(For your information only)
Regards,
Igor
Hi Igor, you're right of course - I also said it will find only exactly matching image parts.

Lisa, I tested it and it worked OK, though a bit slow.

c u