Click here to Skip to main content
13,147,591 members (29,037 online)
Rate this:
Please Sign up or sign in to vote.
See more:
hi all
i have an image of the desktop,the image size is smaller than the desktop size
how can i find a point on the desktop corresponding to the a point in the image
Posted 24-Oct-11 7:51am
SAKryukov 24-Oct-11 14:01pm
How corresponding? 1) coordinate transform from bitmap to screen coordinates, 2) image is a reduced image of the desktop and you need to find a point on desktop mapped to a point on the image?
SAKryukov 24-Oct-11 14:10pm
What, no platform, language, UI library specified? Does not matter much though...
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Please see my comment to the question. In both cases, this is not a problem for gradate students. It means the solution of linear equations which is a work for middle school or early high school student (it depends on your school system, but it requires level well below the required entry level of a college, university or a technical school student). It's reduced to the ability to solve equations like

<br />
X<sub>1</sub> = X<sub>0</sub> + K × X<sub>2</sub><br />
Y<sub>1</sub> = Y<sub>0</sub> + K × Y<sub>2</sub><br />

Wake up and solve them.

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Assuming you have a point on the image relative to the top left hand corner of the image in terms of image coordinates, then it is a simple matter of scaling:

Xdesktop = Ximage * (Widthdesktop / Widthimage)

Ydesktop = Yimage * (Heightdesktop / Heightimage)

Obviously, you won't necessarily get to exactly that point - there will be an error of a pixel or two depending on the relative sizes.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Let the coordinates of point on image be x,y. Then your corresponding point on desktop will be like this.

new point = new point(x* Desktopwidth/imagewidth,y*Desktopheight/imageheight)

This is in theory, but i hope you get my point. If you don't then reply.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170915.1 | Last Updated 24 Oct 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100