Setting the attributes and bitmaps for all overlays inside a DICOM dataset Example for VB.NET
'LEADDICOM1 is a DICOM Dataset defined outside this method
'This example uses the predefined variable "LEADRasterView1"
of type "AxLEADRasterView" from "LEADTOOLS Toolkit".
'This example uses the predefined variable "LEADRasterView2"
of type "AxLEADRasterView" from "LEADTOOLS Toolkit".
Private Sub TestSettingTheAttributesAndBitmapsForAllOverlaysInsideDICOMDataset()
' This function will store the overlays associated
' with a bitmap handle inside the DICOM dataset
Dim OverlayAttributesDS As LTRASTERPROCLib.LEADOverlayAttributes
Dim OverlayAttributesRaster As LTRASTERPROCLib.LEADOverlayAttributes
Dim GroupNumber As Integer
Dim IsOverlayInDataset As Boolean
Dim OverlayCount As Integer
Dim OverlayIndex As Integer
Dim iRet As Short
Dim Process As New LTRASTERPROCLib.LEADRasterProcess
IsOverlayInDataset = False
GroupNumber = 0 OverlayIndex = 0
Process.EnableMethodErrors
= False
' Do we have any overlays at all?
OverlayCount = Process.GetOverlayCount(LEADRasterView1.Raster,
0)
' If no overlays just exit sub
If (OverlayCount = 0) Then
MessageBox.Show("error")
Exit Sub
End If
' Blow away all the overlays in the file
For OverlayIndex = 0 To OverlayCount - 1
LEADDICOM1.DeleteOverlay(OverlayIndex,
0)
Next
OverlayAttributesDS = LEADDICOM1.OverlayAttributes
' Loop through the overlays and add them into the DICOM
file
For OverlayIndex = 0 To OverlayCount - 1
' Get overlay attributes
iRet = Process.GetOverlayAttributes(LEADRasterView1.Raster,
OverlayIndex, LTRASTERPROCLib.OverlayAttributesConstants.OVERLAYATTRIBUTES_ORIGIN
Or LTRASTERPROCLib.OverlayAttributesConstants.OVERLAYATTRIBUTES_FLAGS
Or LTRASTERPROCLib.OverlayAttributesConstants.OVERLAYATTRIBUTES_BITINDEX
Or LTRASTERPROCLib.OverlayAttributesConstants.OVERLAYATTRIBUTES_DICOM)
If (iRet <> 0) Then
MessageBox.Show("error")
Exit Sub
End If
OverlayAttributesRaster = Process.OverlayAttributes
OverlayAttributesDS.OriginX = OverlayAttributesRaster.OriginX
OverlayAttributesDS.OriginY = OverlayAttributesRaster.OriginY
OverlayAttributesDS.Flags = OverlayAttributesRaster.Flags
OverlayAttributesDS.Color = System.Convert.ToUInt32(System.Drawing.ColorTranslator.FromOle(System.Convert.ToInt32(OverlayAttributesRaster.Color)))
OverlayAttributesDS.BitPosition = OverlayAttributesRaster.BitPosition
OverlayAttributesDS.Rows = OverlayAttributesRaster.Rows
OverlayAttributesDS.Columns = OverlayAttributesRaster.Columns
OverlayAttributesDS.Type = OverlayAttributesRaster.Type
OverlayAttributesDS.BitsAllocated =
OverlayAttributesRaster.BitsAllocated
OverlayAttributesDS.Subtype = OverlayAttributesRaster.Subtype
OverlayAttributesDS.Label = OverlayAttributesRaster.Label
OverlayAttributesDS.ROIArea = OverlayAttributesRaster.ROIArea
OverlayAttributesDS.ROIMean = OverlayAttributesRaster.ROIMean
OverlayAttributesDS.ROIStandardDeviation
= OverlayAttributesRaster.ROIStandardDeviation
OverlayAttributesDS.NumberFramesInOverlay
= OverlayAttributesRaster.NumberFramesInOverlay
OverlayAttributesDS.ImageFrameOrigin
= OverlayAttributesRaster.ImageFrameOrigin
OverlayAttributesDS.ActivationLayer
= OverlayAttributesRaster.ActivationLayer
OverlayAttributesDS.Description = OverlayAttributesRaster.Description
' Set overlay attributes inside DICOM
iRet = LEADDICOM1.SetOverlayAttributes(OverlayIndex,
0)
If (iRet <> 0) Then
MessageBox.Show("error")
Exit Sub
End If
' burn overlays which need to be part
of the image
If (OverlayAttributesRaster.Flags And
LTRASTERPROCLib.OverlayAttributesFlagsConstants.OVERLAY_USEBITPLANE)Then
iRet = Process.UpdateOverlayBits(LEADRasterView1.Raster,
OverlayIndex, LTRASTERPROCLib.OverlayBitsConstants.SETOVERLAYBITS_FROMOVERLAY)
If (iRet <>
0)Then
MessageBox.Show("error")
Exit
Sub
End If
End If
' Get the overlay data (if it's not
part of the image)
LEADRasterView2.Raster.Free()
iRet = Process.GetOverlayBitmap(LEADRasterView1.Raster,
OverlayIndex, LEADRasterView2.Raster, LTRASTERPROCLib.OverlayConstants.OVERLAY_COPY)
If (iRet <> 0) Then
MessageBox.Show("error")
Exit Sub
End If
' Set overlay data into DICOM
LEADDICOM1.OverlayBitmap = LEADRasterView2.Raster.Bitmap
iRet = LEADDICOM1.SetOverlayBitmap(OverlayIndex,
0)
If (iRet <> 0) Then
MessageBox.Show("error")
Exit Sub
End If
Next
End Sub