Problem with GdViewer coordinates

Discussions about document viewing.
Post Reply
prosigma
Posts: 8
Joined: Tue Nov 10, 2009 2:26 pm

Problem with GdViewer coordinates

Post by prosigma » Tue Feb 09, 2010 5:38 pm

Hello,

I encountered a new problem with the GdPicture-Library. I recently updated GdPicture.NET because of a bug with the GdViewer. But now there occured another problem, where it did work before updating.

I've got my Form with a GdViewer control on it. When the MouseMove event of this control fires, a label below the control shows the coordinates. I get these by using the GdViewer.GetMouseLeftInDocument() and GdViewer.GetMouseTopInDocument() methods. Before the update, these coordinates did not vary when zooming. Now, when zooming, the documents maximum right and bottom coordinate changes. (I tested this by zooming and checking the right bottom coordinate after each zoom step)
Another thing i noticed is, that not only the coordinates change when zooming, but also the HorizontalResolution and VerticalResolution properties.

I tried to convert them by using the CoordDocumentToViewer() and CoordViewerToDocument() methods, but this isn't working either.

How can i get the absolute coordinates of the mouse on the document with ignoring the current zoom level?

Regards,
prosigma

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Problem with GdViewer coordinates

Post by Loïc » Tue Feb 09, 2010 5:55 pm

Hi,

I suppose you are viewing PDF. This behavior is not a bug and was exactly the same in all previous versions.
A PDF document is not a raster bitmap. So you have to get coordinates in Inches.

You can do that easily:

Code: Select all

X = GdViewer.GetMouseLeftInDocument / GdViewer.HorizontalResolution
Y = GdViewer.GetMouseTopInDocument / GdViewer.VerticalResolution
Hope this helps.

Kind regards,

Loïc

prosigma
Posts: 8
Joined: Tue Nov 10, 2009 2:26 pm

Re: Problem with GdViewer coordinates

Post by prosigma » Tue Feb 09, 2010 6:12 pm

Thanks,

it was actually a PDF when i thought it was a TIFF. And with the TIFF it works well as before.
When loading a PDF file i now render it first and load this image again into the GdViewer, then i have the coordinates the same format as with TIFF.

Apart from that, thanks alot for the quick reply!

Regards,
prosigma

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest