Re: Getting Pixel Position in an image
Re: Getting Pixel Position in an image
- Subject: Re: Getting Pixel Position in an image
- From: Guy English <email@hidden>
- Date: Tue, 21 Dec 2004 16:56:07 -0500
Hi,
Once you work out where you are in the image view space you'll
need to transform your point one final step - into the scalled image
space. For this you'll need to know a) how scaled your image and b)
the lower left hand point (or top-left if the view is flipped) of the
visible region of the image (in image space - ie the pixel point).
Then you just do
image_space_click.x = (mouse.x / scale) + image_visible_frame.origin.x
image_space_click.y = (mouse.y / scale) + image_visible_frame.origin.y
Hope fully that helps.
Guy
On 21 Dec 2004 07:26:15 -0000, Anish Kumar <email@hidden> wrote:
>
>
> Hi All,
>
> Can anyone please tell me how to get the "Pixel position" of a pixel that
> is currently under
> the mouse for an image that is displayed in a sub-class of NSView. I know
> how to get the
> current mouse location in the image views co-ordinates, but I can't use
> this value in my
> application for the following reason.
>
> Basically I am developing an annotation feature for my application (Similar
> to ACROBAT's
> annotation feature) and the user can enter their comments/annotation for
> the image and a
> icon will be placed on the location where the annotation was made to the
> image. Clicking
> the icon will display the annotation that was made there.
>
> The problem I face here is:- as long as the image is not zoomed, the
> annotation icons are in
> their correct position. When I zoom the image, the icons are misplaced as I
> am using the
> mouse locations for placing the icons to the image. Now if I use the PIXEL
> POSITION in the
> image instead of the mouse location I can place the annotation icons at the
> correct pixel
> position irrespective of the zoom-level of the image.
>
> So can anyone please tell me how to get the pixel-positions in an image.(
> something similar
> to Adobe photoshop's INFO window, where they display the X-Y coordinates
> of the cursor,
> that doesn't change for a particular position in the image even if the
> image is zoomed
> (zoom-in or zoom-out) to any level.
>
> thanks in advance,
> -Anish
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden