VintaSoft Annotation .NET Plug-in Discussions
Questions, comments and suggestions concerning VintaSoft Annotation .NET Plug-in.
Board index < VintaSoft Imaging < VintaSoft Annotation .NET Plug-in Discussions
imageViewer1.FocusedImage.Rotate(90);- the image rotates but the annotations stay where they are.
imageViewer1.FocusedImage.Rotate(90);
foreach (AnnotationBase ab in imageViewer1.Annotations.SelectedCollection)
{
ab.Rotation = 90;
}
- which does rotate the annotation, but does not leave it in the same relative position on the image.VintasoftImage vsImage = annotationViewer1.Images[0];
int imageWidth = vsImage.Width;
int imageHeight = vsImage.Height;
vsImage.Rotate(90);
foreach (AnnotationBase ab in annotationViewer1.Annotations.SelectedCollection)
{
PointF oldLocation = ab.Location;
PointF newLocation = new PointF(imageHeight - oldLocation.Y, oldLocation.X);
ab.Location = newLocation;
ab.Rotation = 90;
}
Formulas for rotations to 180 and 270 degrees can be calculated in the same way.int prevRotationAngle = 0;
private void RotateImageWithAnno(int rotationAngle)
{
while (rotationAngle > 360) rotationAngle -= 360;
while (rotationAngle < 0) rotationAngle += 360;
if ((rotationAngle % 90) != 0) return;
VintasoftImage vsImage = annotationViewer1.Images[0];
int imageWidth = vsImage.Width;
int imageHeight = vsImage.Height;
vsImage.Rotate(rotationAngle);
foreach (AnnotationBase ab in annotationViewer1.Annotations.SelectedCollection)
{
PointF oldLocation = ab.Location;
PointF newLocation = oldLocation;
switch (rotationAngle)
{
case 90:
newLocation = new PointF(imageHeight - oldLocation.Y, oldLocation.X);
break;
case 180:
newLocation = new PointF(imageWidth - oldLocation.X, imageHeight - oldLocation.Y);
break;
case 270:
newLocation = new PointF(oldLocation.Y, imageWidth - oldLocation.X);
break;
}
ab.Location = newLocation;
ab.Rotation = rotationAngle + prevRotationAngle;
}
prevRotationAngle += rotationAngle;
}
private void buttonRotate90_Click(object sender, EventArgs e)
{
RotateImageWithAnno(90);
}
private void buttonRotate270_Click(object sender, EventArgs e)
{
RotateImageWithAnno(-90);
}
Best regards, Alexander