Move DicomLabel when Image is Flipped/Rotated

Moving (using the mouse) DicomLabel could be a little bit tricky when the ImageTied is set to true and flip/rotate operations have been applied to the DicomImage.

The following sample vb6 code is referring to our DicomViewer VB6 sample program, where Label Moving is happening in DicomViewer's MouseMove event.

Select Case SelectedImage.RotateState
  Case 0: ' normal
    Select Case SelectedImage.FlipState
       Case 0:  ' normal
            OffsetX = x - InitialX
            OffsetY = y - InitialY
       Case 1:  ' horizontal flip
            OffsetX = InitialX - x
            OffsetY = y - InitialY
       Case 2: ' vertically flip
            OffsetX = x - InitialX
            OffsetY = InitialY - y
       Case 3: ' flip both direction
            OffsetX = InitialX - x
            OffsetY = InitialY - y
    End Select

  Case 1: ' Left
    Select Case  SelectedImage.FlipState
       Case 0: ' normal
            OffsetX = InitialY - y
            OffsetY = x - InitialX
       Case 1: ' horizontal flip
            OffsetX = y - InitialY
            OffsetY = x - InitialX
       Case 2: ' vertically flip
            OffsetX = InitialY - y
            OffsetY = InitialX - x
       Case 3: ' flip both direction
            OffsetX = y - InitialY
            OffsetY = InitialX - x
    End Select

  Case 2: ' 180
    Select Case SelectedImage.FlipState
       Case 0:  ' normal
            OffsetX = InitialX - x
            OffsetY = InitialY - y
       Case 1:  ' horizontal flip
            OffsetX = x - InitialX
            OffsetY = InitialY - y
       Case 2: ' vertically flip
            OffsetX = InitialX - x
            OffsetY = y - InitialY
       Case 3: ' flip both direction
            OffsetX = x - InitialX
            OffsetY = y - InitialY
    End Select

  Case 3: ' 270
    Select Case  SelectedImage.FlipState
       Case 0: ' normal
            OffsetX = y - InitialY
            OffsetY = InitialX - x
       Case 1: ' horizontal flip
            OffsetX = InitialY - y
            OffsetY = InitialX - x
       Case 2: ' vertically flip
            OffsetX = y - InitialY
            OffsetY = x - InitialX
       Case 3: ' flip both direction
            OffsetX = InitialY - y
            OffsetY = x - InitialX
    End Select
 End Select

OffsetX and OffsetY need to be recalculated when flip/rotate have been applied to the Image. There are ONLY 8 different cases (4 rotations * 2 Horizontal Flips), not 16 cases as shown in the above sample code, so the sample code could be simplified if needed.

Relevance: