Error

# Re: Transposing a logical coordinate rectangle from one view perspective to another, without using a

#1 Posted : Wednesday, July 15, 2009 3:14:15 AM(UTC)

Groups: Registered
Posts: 28

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?

Regards,

Josh.

#2 Posted : Wednesday, July 15, 2009 10:15:36 AM(UTC)

Posts: 764

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?

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

Groups: Registered
Posts: 28

Hi Greg,

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):

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

Groups: Registered
Posts: 28

Except the image itself doesn't actually shift like it looks like it does in my image...

#5 Posted : Thursday, July 16, 2009 11:54:21 AM(UTC)

Posts: 764

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:

Physical: [0,1,-1,0,bitmap height,0]
Logical: [1,0,0,1,0,0]
File Attachment(s):

#6 Posted : Wednesday, August 5, 2009 9:08:06 AM(UTC)

Posts: 764

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.