Getting 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 GettingAttributesAndBitmapsForAllOverlaysInsideDICOMDataset() 
 
   ' This example 
 will extract the overlays from a 
   ' DICOM 
 dataset and associate them with a bitmap, 
   ' the bitmap 
 is assumed to be extracted from the 
   ' same DICOM 
 dataset. 
   Dim iRet 
 As Short 
   Dim lOverlayCount 
 As Integer 
   Dim lOverlayIndex 
 As Integer 
   Dim OverlayAttributesDS 
 As LTRASTERPROCLib.LEADOverlayAttributes 
   Dim OverlayAttributesRaster 
 As LTRASTERPROCLib.LEADOverlayAttributes 
   Dim RasterProcess 
 As New LTRASTERPROCLib.LEADRasterProcess 
   Dim GroupNumber 
 As Integer 
   Dim bIsOverlayInDataSet 
 As Boolean 
   Dim iLEADOverlayIndex 
 As Short 
   Dim lFlags 
 As Integer 
   Dim crColor 
 As Integer 
   lOverlayCount 
 = 0 
   lOverlayIndex 
 = 0 
   GroupNumber 
 = 0 
   bIsOverlayInDataSet 
 = False 
   iLEADOverlayIndex 
 = 0 
   lFlags = 
 0
   LEADDICOM1.GetBitmapValue(0, 0, LTDICLib.DicomColorOrderConstants.ORDER_BGRORGRAY, 
 0) 
   LEADRasterView1.Raster.Bitmap 
 = LEADDICOM1.Bitmap
   ' 
 Do we have any overlays at all? 
   lOverlayCount 
 = LEADDICOM1.OverlayCount 
 
   If (lOverlayCount 
 = 0) Then 
      Exit 
 Sub 
   End If
   ' 
 Go through the overlays one by one 
   lOverlayIndex 
 = 0 
   iLEADOverlayIndex 
 = 0 
   ' Reset 
 the overlay bitmap 
   If (LEADRasterView2.Raster.Bitmap 
 > 0) Then 
      LEADRasterView2.Raster.Free() 
 
   End If 
   LEADRasterView2.Raster.CreateBitmap(1, 
 1, 1) 
   While (lOverlayIndex 
 < lOverlayCount) 
      NEXTINDEX: 
 
      GroupNumber 
 = 0 
      bIsOverlayInDataSet 
 = False 
      lFlags 
 = 0
      ' 
 Get the attributes of this overlay 
      iRet 
 = LEADDICOM1.GetOverlayAttributes(lOverlayIndex, 
 0) 
      If 
 (iRet <> 0) Then 
         MessageBox.Show("error") 
 
         Exit 
 Sub 
      End 
 If 
      GroupNumber 
 = LEADDICOM1.OverlayGroupNumber(lOverlayIndex, 0) 
      bIsOverlayInDataSet 
 = LEADDICOM1.IsOverlayInDataSet(lOverlayIndex, 0)
      If 
 (bIsOverlayInDataSet = False) Then 
         lOverlayIndex 
 = lOverlayIndex + 1 
         GoTo 
 NEXTINDEX 
      End 
 If
      OverlayAttributesDS 
 = LEADDICOM1.OverlayAttributes 
      OverlayAttributesRaster 
 = RasterProcess.OverlayAttributes
      ' 
 Auto paint and process overlays 
      lFlags 
 = OverlayAttributesDS.Flags 
      lFlags 
 = lFlags Or LTRASTERPROCLib.OverlayAttributesFlagsConstants.OVERLAY_AUTOPAINT 
 Or LTRASTERPROCLib.OverlayAttributesFlagsConstants.OVERLAY_AUTOPROCESS 
 
      OverlayAttributesRaster.Flags 
 = lFlags 
      OverlayAttributesRaster.OriginX 
 = OverlayAttributesDS.OriginX 
      OverlayAttributesRaster.OriginY 
 = OverlayAttributesDS.OriginY 
      crColor 
 = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.White) 
      OverlayAttributesRaster.Color 
 = System.Convert.ToUInt32(crColor) 
      OverlayAttributesRaster.BitPosition 
 = OverlayAttributesDS.BitPosition 
      OverlayAttributesRaster.Rows 
 = OverlayAttributesDS.Rows 
      OverlayAttributesRaster.Columns 
 = OverlayAttributesDS.Columns 
      OverlayAttributesRaster.Type 
 = OverlayAttributesDS.Type 
      OverlayAttributesRaster.BitsAllocated 
 = OverlayAttributesDS.BitsAllocated 
      OverlayAttributesRaster.Subtype 
 = OverlayAttributesDS.Subtype 
      OverlayAttributesRaster.Label 
 = OverlayAttributesDS.Label 
      OverlayAttributesRaster.ROIArea 
 = OverlayAttributesDS.ROIArea 
      OverlayAttributesRaster.ROIMean 
 = OverlayAttributesDS.ROIMean 
      OverlayAttributesRaster.ROIStandardDeviation 
 = OverlayAttributesDS.ROIStandardDeviation 
      OverlayAttributesRaster.NumberFramesInOverlay 
 = OverlayAttributesDS.NumberFramesInOverlay 
      OverlayAttributesRaster.ImageFrameOrigin 
 = OverlayAttributesDS.ImageFrameOrigin 
      OverlayAttributesRaster.ActivationLayer 
 = OverlayAttributesDS.ActivationLayer 
      OverlayAttributesRaster.Description 
 = OverlayAttributesDS.Description
      iRet 
 = RasterProcess.SetOverlayAttributes(LEADRasterView1.Raster, 
 iLEADOverlayIndex, 0) 
      If 
 (iRet <> 0) Then 
         MessageBox.Show("error") 
 
         Exit 
 Sub 
      End 
 If
      ' 
 Is the overlay embedded inside the image data ? 
      lFlags 
 = OverlayAttributesDS.Flags 
      If 
 (lFlags And LTRASTERPROCLib.OverlayAttributesFlagsConstants.OVERLAY_USEBITPLANE) 
 Then 
         ' 
 Add this overlay to the list of overlays in the bitmap handle 
         iRet 
 = RasterProcess.SetOverlayAttributes(LEADRasterView1.Raster, 
 iLEADOverlayIndex, LTRASTERPROCLib.OverlayAttributesConstants.OVERLAYATTRIBUTES_FLAGS 
 Or LTRASTERPROCLib.OverlayAttributesConstants.OVERLAYATTRIBUTES_BITINDEX 
 Or LTRASTERPROCLib.OverlayAttributesConstants.OVERLAYATTRIBUTES_ORIGIN 
 Or LTRASTERPROCLib.OverlayAttributesConstants.OVERLAYATTRIBUTES_DICOM 
 Or LTRASTERPROCLib.OverlayAttributesConstants.OVERLAYATTRIBUTES_COLOR) 
 
         If 
 (iRet <> 0) Then 
            MessageBox.Show("error") 
 
            Exit 
 Sub 
         End 
 If
         ' 
 Make sure to extract the overlay data from the image data 
         iRet 
 = RasterProcess.UpdateOverlayBits(LEADRasterView1.Raster, iLEADOverlayIndex, 
 LTRASTERPROCLib.OverlayBitsConstants.SETOVERLAYBITS_FROMBITMAP) 
         If 
 (iRet <> 0) Then 
            MessageBox.Show("error") 
 
            Exit 
 Sub 
         End 
 If 
         ' 
 The overlay is inside overlay data Else 
         ' 
 Add this overlay to the list of overlays in the bitmap handle 
         iRet 
 = RasterProcess.SetOverlayAttributes(LEADRasterView1.Raster, 
 iLEADOverlayIndex, LTRASTERPROCLib.OverlayAttributesConstants.OVERLAYATTRIBUTES_FLAGS 
 Or LTRASTERPROCLib.OverlayAttributesConstants.OVERLAYATTRIBUTES_ORIGIN 
 Or LTRASTERPROCLib.OverlayAttributesConstants.OVERLAYATTRIBUTES_DICOM 
 Or LTRASTERPROCLib.OverlayAttributesConstants.OVERLAYATTRIBUTES_COLOR) 
 
         If 
 (iRet <> 0) Then 
            MessageBox.Show("error") 
 
            Exit 
 Sub 
         End 
 If
         ' 
 Get the overlay bitmap from the overlay data 
         iRet 
 = LEADDICOM1.GetOverlayBitmap(lOverlayIndex, 
 0) 
         If 
 (iRet <> 0) Then 
            MessageBox.Show("error") 
 
            Exit 
 Sub 
         End 
 If 
         ' 
 store it temp. in RasterView2 
         If 
 (LEADRasterView2.Raster.Bitmap > 0) Then 
            LEADRasterView2.Raster.Free() 
 
         End 
 If 
         LEADRasterView2.Raster.Bitmap 
 = LEADDICOM1.OverlayBitmap
         ' 
 Set the bitmap for this overlay inside the ' list of overlays we have 
 in the bitmap handle
         iRet 
 = RasterProcess.SetOverlayBitmap(LEADRasterView1.Raster, 
 iLEADOverlayIndex, LEADRasterView2.Raster, LTRASTERPROCLib.OverlayConstants.OVERLAY_COPY) 
 
         If 
 (iRet <> 0) Then 
            MessageBox.Show("error") 
 
            Exit 
 Sub 
         End 
 If 
      End 
 If 
      lOverlayIndex 
 = lOverlayIndex + 1 
      iLEADOverlayIndex 
 = iLEADOverlayIndex + 1 
   End While 
 
End Sub