Setting palette color LUT data and attributes Example for Delphi
//This example will set the attributes and the data for a
//Palette Color Lookup Table
var
nLUTIndex: Integer;
nRet: Integer;
RedLUTData: Array of Integer;
GreenLUTData: Array of Integer;
BlueLUTData: Array of Integer;
PaletteColorLUTAttributes: LPaletteColorLUTAttributes;
begin
PaletteColorLUTAttributes:= LEADDicomDS1.PaletteColorLUTAttributes;
// Initialize Red Palette Color Lookup Table Descriptor (0028,1101)
PaletteColorLUTAttributes.RedLUTDescriptorFirstMapped:= 0;
PaletteColorLUTAttributes.RedLUTDescriptorEntryBits:= 16;
PaletteColorLUTAttributes.RedLUTDescriptorNumberOfEntries:= $10000;
// Initialize Green Palette Color Lookup Table Descriptor (0028,1102)
PaletteColorLUTAttributes.GreenLUTDescriptorFirstMapped:= 0;
PaletteColorLUTAttributes.GreenLUTDescriptorEntryBits:= 16;
PaletteColorLUTAttributes.GreenLUTDescriptorNumberOfEntries:= $10000;
// Initialize Blue Palette Color Lookup Table Descriptor (0028,1103)
PaletteColorLUTAttributes.BlueLUTDescriptorFirstMapped:= 0;
PaletteColorLUTAttributes.BlueLUTDescriptorEntryBits:= 16;
PaletteColorLUTAttributes.BlueLUTDescriptorNumberOfEntries:= $10000;
SetLength(RedLUTData, PaletteColorLUTAttributes.RedLUTDescriptorNumberOfEntries);
SetLength(GreenLUTData, PaletteColorLUTAttributes.GreenLUTDescriptorNumberOfEntries);
SetLength(BlueLUTData, PaletteColorLUTAttributes.BlueLUTDescriptorNumberOfEntries);
for nLUTIndex:= 0 to (PaletteColorLUTAttributes.BlueLUTDescriptorNumberOfEntries - 1) do
begin
RedLUTData[nLUTIndex]:= nLUTIndex;
GreenLUTData[nLUTIndex]:= Trunc(nLUTIndex / 2);
BlueLUTData[nLUTIndex]:= Trunc(nLUTIndex / 4);
end;
// Delete all the elements that describe the 'Palette Color Lookup Table'.
nRet:= LEADDicomDS1.DeletePaletteColorLUT(0);
if(nRet <> 0)then
begin
ShowMessage('error');
Exit;
end;
// Set the new 'Palette Color Lookup Table' attributes
nRet:= LEADDicomDS1.SetPaletteColorLUTAttributes (0);
if(nRet <> 0)then
begin
ShowMessage('error');
Exit;
end;
// Set Red Palette Color Lookup Table Data
nRet:= LEADDicomDS1.SetPaletteColorLUTData (RedLUTData, DICOM_PALETTE_COLOR_LUT_TYPE_RED, 0);
if(nRet <> 0)then
begin
ShowMessage('error');
Exit;
end;
// Set Green Palette Color Lookup Table Data
nRet:= LEADDicomDS1.SetPaletteColorLUTData (GreenLUTData, DICOM_PALETTE_COLOR_LUT_TYPE_GREEN, 0);
if(nRet <> 0)then
begin
ShowMessage('error');
Exit;
End;
// Set Blue Palette Color Lookup Table Data
nRet:= LEADDicomDS1.SetPaletteColorLUTData (BlueLUTData, DICOM_PALETTE_COLOR_LUT_TYPE_BLUE, 0);
if(nRet <> 0)then
begin
ShowMessage('error');
Exit;
end;
end;