User Guide > How to Work with... > ART Annotations > Using ImageGear.ART Namespace > Operating with ART Marks > Rotating & Flipping the ART Page & Marks |
To rotate or flip the entire ART page, please use the following methods:
These methods perform “deep” rotation/flipping; they are updating the coordinates of all marks within the page accordingly.
To rotate or flip the mark(s) separately, please use the following methods of the Mark:
The rotation/flipping center point of these methods must be provided in the same coordinate system, as the marks were created and added to the ART page (image or device). |
If the ART page should be rotated synchronously with the underlying image (ImGearPage), there are some aspects that should be taken into account. If the marks have image coordinates, their position is calculated relatively to the top-left corner of the image, so in the case of rotation by 90 or 270 degrees along with underlying image, the coordinates of the marks should be corrected (i.e., they should be shifted) to put the ART page in the correct position in regard to ImGearPage. Here is a code example for how to rotate by 90 degrees for both ART and the underlying page:
C# Example |
Copy Code |
---|---|
private void menuEditRotate90_Click(object sender, System.EventArgs e) { ImGearPoint center = new ImGearPoint(imGearPageView.Page.DIB.Width / 2, imGearPageView.Page.DIB.Height / 2); artGUI.Page.Rotate(center, ImGearRotationValues.VALUE_90); ImGearPoint centerAfterRotation = CalculateCenterPointShift(center, ImGearRotationValues.VALUE_90); foreach (ImGearARTMark mark in artGUI.Page) { mark.Move(centerAfterRotation.X - center.X, centerAfterRotation.Y - center.Y); } ImGearProcessing.Rotate(imGearPageView.Page, ImGearRotationValues.VALUE_90); imGearPageView.Update(); } private ImGearPoint CalculateCenterPointShift(ImGearPoint center, ImGearRotationValues rotationAngle) { switch (rotationAngle) { case ImGearRotationValues.VALUE_90: return new ImGearPoint(imGearPageView.Page.DIB.Height - center.Y, center.X); case ImGearRotationValues.VALUE_180: return new ImGearPoint(imGearPageView.Page.DIB.Width - center.X, imGearPageView.Page.DIB.Height - center.Y); case ImGearRotationValues.VALUE_270: return new ImGearPoint(center.Y, imGearPageView.Page.DIB.Width - center.X); default: return center; } } |
VB.NET Example |
Copy Code |
---|---|
Private Sub mnuEditRot90_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuEditRot90.Click Dim center As ImGearPoint = New ImGearPoint(ImGearPageView1.Page.DIB.Width / 2, ImGearPageView1.Page.DIB.Height / 2) artGUI.Page.Rotate(center, ImGearRotationValues.VALUE_90) Dim centerAfterRotation As ImGearPoint = CalculateCenterPointShift(center, ImGearRotationValues.VALUE_90) For Each mark As ImGearARTMark In artGUI.Page mark.Move(centerAfterRotation.X - center.X, centerAfterRotation.Y - center.Y) Next ImGearProcessing.Rotate(ImGearPageView1.Page, ImGearRotationValues.VALUE_90) ImGearPageView1.Update() End Sub Private Function CalculateCenterPointShift(ByVal center As ImGearPoint, ByVal rotationAngle As ImGearRotationValues) As ImGearPoint Select Case (rotationAngle) Case ImGearRotationValues.VALUE_90 Return New ImGearPoint(ImGearPageView1.Page.DIB.Height - center.Y, center.X) Case ImGearRotationValues.VALUE_180 Return New ImGearPoint(ImGearPageView1.Page.DIB.Width - center.X, ImGearPageView1.Page.DIB.Height - center.Y) Case ImGearRotationValues.VALUE_270 Return New ImGearPoint(center.Y, ImGearPageView1.Page.DIB.Width - center.X) Case Else Return center End Select End Function |