I have a situation where I have a RasterImage, but no RasterImageViewer. I have a rectangle, in logical image coordinates, relative to a view perspective of TopLeft. How would I find out what the correct location of that rectange would be if the image were loaded with a view perspective of, for instance, TopLeft90?

This is easy to do using the Leadtools.Transformer class and the RasterImageViewer.Transform property, when you have a RasterImageViewer, however I haven't found a way to do this without using a viewer, and I can't seem to work out the math required to do without one. I'm guessing I could simply build my own matrix and use the Leadtools.Transformer class with that, but then what should my matrix look like?

I'm not completely sure, but it may be possible with our Transformer class with the right Matrix because it's just doing a rotation and translation operation with Linear Algebra. I'm a bit rusty on that branch of math but should be able to figure it out once I completely understand your goal.

Are you trying to figure out where a point/rectangle would be located if you were to rotate it or get the equivalent location of that point so that it stays put if the image were rotated? For example, you have a 100x100 image in top-left. You have a point 0,0. When you do this calculation are you trying to get where 0,0 will be if it were rotated 90 CW in relation to the original image (100,0) or are you trying to figure out where on your original image 0,0 is on the rotated image (0,-100)? In other words, which direction are you trying to convert?

Also, what exactly are you trying to use this information for? What's your overall goal?

User Profile

View All Posts by User

View Thanks

#3
Posted
:
Wednesday, July 15, 2009 10:13:24 PM(UTC)

I'm trying to achieve the first of the two operations you described. I have a point/rect at 0,0 and I want to know where that part of the image would go to if it were rotated by 90° CW.

I've attached an image showing visually what I'd like to achieve, basically, I want to know where the red rectangle in my image ended up.

Regards,

Josh.

Joshua attached the following image(s):

User Profile

View All Posts by User

View Thanks

#4
Posted
:
Wednesday, July 15, 2009 10:15:19 PM(UTC)

I've attached a simple sample project that allows you to test different transformations on a point with our Transformer class. The basic process is to Transform the point to physical coordinates using one transform, then convert it back to bitmap coordinates with another.

We use the System.Drawing.Drawing2D.Matrix which is an affine matrix which does a rotation, then translation. Elements 0-3 are the rotation and 4-5 are the translation.

For the goal you described, you need to transform the point from bitmap to client (logical to physical) with the rotation and translation, then convert that point to bitmap coordinates with the identity matrix. Your matrices would look like this:

On another note, you should always use RasterImageViewer.GetDpiTransform instead of .Transform. GetDpiTransform takes into account if RasterImageViewer.UseDpi is set to true and returns a matrix that embeds this value. GetDpiTransform returns a clone of the matrix inside the viewer so you should always dispose it after using it.

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.