Setting palette color LUT data and attributes Example for C#
//LEADDICOM1 is a DICOM Dataset defined outside this method
public void TestSettingPaletteColorLUTDataAttributes()
{
//This example will set the attributes and the data for
a
//Palette Color Lookup Table
int lLUTIndex = 0;
short iRet = 0;
int[] RedLUTData = null;
int[] GreenLUTData = null;
int[] BlueLUTData = null;
LTDICLib.LPaletteColorLUTAttributes PaletteColorLUTAttributes
= null;
PaletteColorLUTAttributes = LEADDICOM1.PaletteColorLUTAttributes
;
// Initialize Red Palette Color Lookup Table Descriptor
(0028,1101)
PaletteColorLUTAttributes.RedLUTDescriptorFirstMapped
= 0;
PaletteColorLUTAttributes.RedLUTDescriptorEntryBits
= 16;
PaletteColorLUTAttributes.RedLUTDescriptorNumberOfEntries
= 0X10000;
// Initialize Green Palette Color Lookup Table Descriptor
(0028,1102)
PaletteColorLUTAttributes.GreenLUTDescriptorFirstMapped
= 0;
PaletteColorLUTAttributes.GreenLUTDescriptorEntryBits
= 16;
PaletteColorLUTAttributes.GreenLUTDescriptorNumberOfEntries
= 0X10000;
// Initialize Blue Palette Color Lookup Table Descriptor
(0028,1103)
PaletteColorLUTAttributes.BlueLUTDescriptorFirstMapped
= 0;
PaletteColorLUTAttributes.BlueLUTDescriptorEntryBits
= 16;
PaletteColorLUTAttributes.BlueLUTDescriptorNumberOfEntries
= 0X10000;
RedLUTData = new int[PaletteColorLUTAttributes.RedLUTDescriptorNumberOfEntries
+ 1];
GreenLUTData = new int[PaletteColorLUTAttributes.GreenLUTDescriptorNumberOfEntries
+ 1];
BlueLUTData = new int[PaletteColorLUTAttributes.BlueLUTDescriptorNumberOfEntries
+ 1];
for (lLUTIndex = 0; lLUTIndex < PaletteColorLUTAttributes.BlueLUTDescriptorNumberOfEntries;
lLUTIndex++)
{
RedLUTData[lLUTIndex] = lLUTIndex;
GreenLUTData[lLUTIndex] = lLUTIndex / 2;
BlueLUTData[lLUTIndex] = lLUTIndex
/ 4;
}
// Delete all the elements that describe the "Palette
Color Lookup Table".
iRet = LEADDICOM1.DeletePaletteColorLUT(0);
if (iRet != 0)
{
MessageBox.Show("error");
return;
}
// Set the new "Palette Color Lookup Table"
attributes
iRet = LEADDICOM1.SetPaletteColorLUTAttributes(0);
if (iRet != 0)
{
MessageBox.Show("error");
return;
}
// Set Red Palette Color Lookup Table Data
iRet = LEADDICOM1.SetPaletteColorLUTData(RedLUTData,
LTDICLib.DicomPaletteColorLUTConstants.DICOM_PALETTE_COLOR_LUT_TYPE_RED,
0);
if (iRet != 0)
{
MessageBox.Show("error");
return;
}
// Set Green Palette Color Lookup Table Data
iRet = LEADDICOM1.SetPaletteColorLUTData(GreenLUTData,
LTDICLib.DicomPaletteColorLUTConstants.DICOM_PALETTE_COLOR_LUT_TYPE_GREEN,
0);
if (iRet != 0)
{
MessageBox.Show("error");
return;
}
// Set Blue Palette Color Lookup Table Data
iRet = LEADDICOM1.SetPaletteColorLUTData(BlueLUTData,
LTDICLib.DicomPaletteColorLUTConstants.DICOM_PALETTE_COLOR_LUT_TYPE_BLUE,
0);
if (iRet != 0)
{
MessageBox.Show("error");
return;
}
}