Setting palette color LUT data and attributes Example for VB.NET

'LEADDICOM1 is a DICOM Dataset defined outside this method
Private Sub TestSettingPaletteColorLUTDataAttributes()
   'This example will set the attributes and the data for a
   'Palette Color Lookup Table
   Dim lLUTIndex As Integer
   Dim iRet As Short
   Dim RedLUTData() As Integer
   Dim GreenLUTData() As Integer
   Dim BlueLUTData() As Integer
   Dim PaletteColorLUTAttributes As LTDICLib.LPaletteColorLUTAttributes
   PaletteColorLUTAttributes = LEADDICOM1.PaletteColorLUTAttributes

   ' Initialize Red Palette Color Lookup Table Descriptor (0028,1101)
   PaletteColorLUTAttributes.RedLUTDescriptorFirstMapped = 0
   PaletteColorLUTAttributes.RedLUTDescriptorEntryBits = 16
   PaletteColorLUTAttributes.RedLUTDescriptorNumberOfEntries = &H10000

   ' Initialize Green Palette Color Lookup Table Descriptor (0028,1102)
   PaletteColorLUTAttributes.GreenLUTDescriptorFirstMapped = 0
   PaletteColorLUTAttributes.GreenLUTDescriptorEntryBits = 16
   PaletteColorLUTAttributes.GreenLUTDescriptorNumberOfEntries = &H10000

   ' Initialize Blue Palette Color Lookup Table Descriptor (0028,1103)
   PaletteColorLUTAttributes.BlueLUTDescriptorFirstMapped = 0
   PaletteColorLUTAttributes.BlueLUTDescriptorEntryBits = 16
   PaletteColorLUTAttributes.BlueLUTDescriptorNumberOfEntries = &H10000
   ReDim RedLUTData(PaletteColorLUTAttributes.RedLUTDescriptorNumberOfEntries)
   ReDim GreenLUTData(PaletteColorLUTAttributes.GreenLUTDescriptorNumberOfEntries)
   ReDim BlueLUTData(PaletteColorLUTAttributes.BlueLUTDescriptorNumberOfEntries)

   For lLUTIndex = 0 To (PaletteColorLUTAttributes.BlueLUTDescriptorNumberOfEntries - 1)
      RedLUTData(lLUTIndex) = lLUTIndex
      GreenLUTData(lLUTIndex) = lLUTIndex / 2
      BlueLUTData(lLUTIndex) = lLUTIndex / 4
   Next
   ' Delete all the elements that describe the "Palette Color Lookup Table".
   iRet = LEADDICOM1.DeletePaletteColorLUT(0)
   If (iRet <> 0) Then
      MessageBox.Show("error")
      Exit Sub
   End If
   ' Set the new "Palette Color Lookup Table" attributes
   iRet = LEADDICOM1.SetPaletteColorLUTAttributes(0)
   If (iRet <> 0) Then
      MessageBox.Show("error")
      Exit Sub
   End If
   ' Set Red Palette Color Lookup Table Data
   iRet = LEADDICOM1.SetPaletteColorLUTData(RedLUTData, LTDICLib.DicomPaletteColorLUTConstants.DICOM_PALETTE_COLOR_LUT_TYPE_RED, 0)
   If (iRet <> 0) Then
      MessageBox.Show("error")
      Exit Sub
   End If
   ' Set Green Palette Color Lookup Table Data
   iRet = LEADDICOM1.SetPaletteColorLUTData(GreenLUTData, LTDICLib.DicomPaletteColorLUTConstants.DICOM_PALETTE_COLOR_LUT_TYPE_GREEN, 0)
   If (iRet <> 0) Then
      MessageBox.Show("error")
      Exit Sub
   End If
   ' Set Blue Palette Color Lookup Table Data
   iRet = LEADDICOM1.SetPaletteColorLUTData(BlueLUTData, LTDICLib.DicomPaletteColorLUTConstants.DICOM_PALETTE_COLOR_LUT_TYPE_BLUE, 0)
   If (iRet <> 0) Then
      MessageBox.Show("error")
      Exit Sub
   End If
End Sub