05-29-2008, 16:30
|
specialtouch
Joined on 04-01-2008
Posts 2
|
How to rotate transformation matrix along with viewperspective?
|
 
 
|
|
|
How do I convert the transformation matrix of a RasterImageViewer after
its image has had its view perspective rotated?
I have a situation where I am performing custom drawing of Regions on
the surface of a RasterImageViewer. The Region is described in logical
coordinates, so before drawing the Region in the OnPostImagePaint
method, I transform its coordinates to physical using the
RasterImageViewer's Transform property Matrix:
// Transform region coordinates from logical to physical
Matrix matrix = base.Transform;
region.Transform(matrix);
// Draw the region
DrawRegion(region);
The problem I am having is after I have applied a rotation to the image,
the transformation matrix does not account for the change in rotation.
The rotation applied is always a multiple of 90 and I am using the
RotateViewPerspective method to apply the rotation. If I rotate the
transformation matrix, I seem to get the correct region for 180 degree
rotation, but not for 90 and 270 degree rotation:
// Transform region coordinates from logical to physical
Matrix matrix = base.Transform.Clone();
matrix.RotateAt(rotationApplied, new PointF((float)(base.Image.Width /
2.0), (float)(base.Image.Height / 2.0)));
region.Transform(matrix);
The +-90 degree rotations are always offset and I don't understand why. Does anyone know if there is some other step I am overlooking?
|
|
|
|
|
Report
|
|
|
|