Aligning Mammography Images in DicomObjects.NET

Sometimes people want to right-align Mammography images, so that they can have a pair sitting alongside each other, with the Image on the left being right-aligned and the Image on the right left-aligned.

In DicomObjects.NET, you only have 3 alignment options:

  • None
  • StretchCentred
  • StretchTopLeft

We might add the StretchTopRight option later, but for now, you can use the following code to do the same.

Dim m As Matrix
m = DicomViewer1.Images(0).Matrix(DicomViewer1)

Dim ps(2) As Point
ps(0) = New Point(0, 0)
ps(1) = New Point(DicomViewer1.Images(0).Size.Width, 0)

m.TransformPoints(ps)

Dim length As Long
length = ps(1).X - ps(0).X

Dim offset As Long
offset = DicomViewer1.Width / DicomViewer1.MultiColumns - length

Dim x, y As Single
x = DicomViewer1.Images(0).Area.X + offset
y = DicomViewer1.Images(0).Area.Y

DicomViewer1.Images(0).StretchMode = Enums.StretchModes.None
DicomViewer1.Images(0).Zoom = DicomGlobal.Zoom(m)
DicomViewer1.Images(0).Scroll = New Point(x, y)
Relevance: