Available in LEADTOOLS Medical Imaging toolkits. |
LDicomDS::SetPaletteColorLUTData
#include "ltdic.h"
L_UINT16 LDicomDS::SetPaletteColorLUTData(pLUTData, uDataSize, PaletteColorLUTType, uFlags)
L_UINT16 * pLUTData; |
/* pointer to the input buffer */ |
L_UINT uDataSize; |
/* size of the input buffer */ |
DICOMPALETTECOLORLUTTYPE PaletteColorLUTType; |
/* type of palette color lookup table */ |
L_UINT uFlags; |
/* reserved for future use */ |
Sets red, green or blue "Palette Color Lookup Table" data.
Parameter |
Description |
|
pLUTData |
Pointer to the buffer that holds the "Palette Color Lookup Table Data" to set. |
|
uDataSize |
Size of the buffer pointed to by pLUTData. |
|
PaletteColorLUTType |
Type of palette color lookup table data to set. The following are possible values: |
|
|
Value |
Meaning |
|
DICOMPALETTECOLORLUTTYPE_RED |
Set "Red Palette Color Lookup Table Data" (0028,1201) |
|
DICOMPALETTECOLORLUTTYPE_GREEN |
Set "Green Palette Color Lookup Table Data" (0028,1202) |
|
DICOMPALETTECOLORLUTTYPE_BLUE |
Set "Blue Color Lookup Table Data" (0028,1203) |
uFlags |
Reserved for future use. Pass 0. |
Returns
0 |
The function was successful. |
> 0 |
An error occurred. Refer to Return Codes. |
Comments
This function will set the data for the "Red", "Green" or "Blue" "Palette Color Lookup Table".
Before calling this function you must call LDicomDS::SetPaletteColorLUTAttributes to set the attributes of the "Palette Color Lookup Table", otherwise this function will fail and return DICOM_ERROR_LUT_DESCRIPTOR_MISSING.
Required DLLs and Libraries
LTDIC For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application |
Win32, x64
See Also
Example
This example will set the attributes and the date for a Palette Color Lookup Table
//#define SET_SIZE(PSTRUCTPTR) (PSTRUCTPTR)->uStructSize = sizeof(*PSTRUCTPTR) L_INT LDicomDS_SetPaletteColorLUTDataExample(LDicomDS &InDS) { L_INT nRet; L_INT nLUTIndex; L_UINT16 * pRedLUTData = NULL; L_UINT16 * pGreenLUTData = NULL; L_UINT16 * pBlueLUTData = NULL; DICOMPALCOLORLUTATTRIBS PaletteColorLUTAttributes = {0} ; // Remember to set the size for each structure PaletteColorLUTAttributes.uStructSize = sizeof(DICOMPALCOLORLUTATTRIBS); PaletteColorLUTAttributes.RedLUTDescriptor.uStructSize = sizeof(DICOMLUTDESCRIPTOR); PaletteColorLUTAttributes.GreenLUTDescriptor.uStructSize = sizeof(DICOMLUTDESCRIPTOR); PaletteColorLUTAttributes.BlueLUTDescriptor.uStructSize = sizeof(DICOMLUTDESCRIPTOR); // Initialize Red Palette Color Lookup Table Descriptor (0028,1101) PaletteColorLUTAttributes.RedLUTDescriptor.nFirstStoredPixelValueMapped = 0; PaletteColorLUTAttributes.RedLUTDescriptor.uEntryBits = 16; PaletteColorLUTAttributes.RedLUTDescriptor.uNumberOfEntries = 0x10000; // Initialize Green Palette Color Lookup Table Descriptor (0028,1102) PaletteColorLUTAttributes.GreenLUTDescriptor.nFirstStoredPixelValueMapped = 0; PaletteColorLUTAttributes.GreenLUTDescriptor.uEntryBits = 16; PaletteColorLUTAttributes.GreenLUTDescriptor.uNumberOfEntries = 0x10000; // Initialize Blue Palette Color Lookup Table Descriptor (0028,1103) PaletteColorLUTAttributes.BlueLUTDescriptor.nFirstStoredPixelValueMapped = 0; PaletteColorLUTAttributes.BlueLUTDescriptor.uEntryBits = 16; PaletteColorLUTAttributes.BlueLUTDescriptor.uNumberOfEntries = 0x10000; // Allocate a buffer to hold Red Palette Color Lookup Table Data pRedLUTData = (L_UINT16*)malloc(0x10000 * sizeof(L_UINT16)); if(!pRedLUTData) { return DICOM_ERROR_MEMORY; } // Allocate a buffer to hold Green Palette Color Lookup Table Data pGreenLUTData = (L_UINT16*)malloc(0x10000 * sizeof(L_UINT16)); if(!pGreenLUTData) { free(pRedLUTData); return DICOM_ERROR_MEMORY; } // Allocate a buffer to hold Blue Palette Color Lookup Table Data pBlueLUTData = (L_UINT16*)malloc(0x10000 * sizeof(L_UINT16)); if(!pBlueLUTData) { free(pRedLUTData); free(pGreenLUTData); return DICOM_ERROR_MEMORY; } for(nLUTIndex = 0; nLUTIndex <= 0xFFFF; nLUTIndex++) { pRedLUTData [nLUTIndex] = (L_UINT16) nLUTIndex ; pGreenLUTData [nLUTIndex] = (L_UINT16) nLUTIndex/2; pBlueLUTData [nLUTIndex] = (L_UINT16) nLUTIndex/4; } // Delete all the elements that describe the "Palette Color Lookup Table". nRet = InDS.DeletePaletteColorLUT (0); if(nRet != DICOM_SUCCESS) { free(pRedLUTData); free(pGreenLUTData); free(pBlueLUTData); return nRet; } // Set the new "Palette Color Lookup Table" attributes nRet = InDS.SetPaletteColorLUTAttributes (&PaletteColorLUTAttributes, 0); if(nRet != DICOM_SUCCESS) { free(pRedLUTData); free(pGreenLUTData); free(pBlueLUTData); return nRet; } // Set Red Palette Color Lookup Table Data nRet = InDS.SetPaletteColorLUTData (pRedLUTData,0x10000,DICOMPALETTECOLORLUTTYPE_RED,0); if(nRet != DICOM_SUCCESS) { free(pRedLUTData); free(pGreenLUTData); free(pBlueLUTData); return nRet; } // Set Green Palette Color Lookup Table Data nRet = InDS.SetPaletteColorLUTData (pGreenLUTData,0x10000,DICOMPALETTECOLORLUTTYPE_GREEN,0); if(nRet != DICOM_SUCCESS) { free(pRedLUTData); free(pGreenLUTData); free(pBlueLUTData); return nRet; } // Set Blue Palette Color Lookup Table Data nRet = InDS.SetPaletteColorLUTData (pBlueLUTData,0x10000,DICOMPALETTECOLORLUTTYPE_BLUE,0); if(nRet != DICOM_SUCCESS) { free(pRedLUTData); free(pGreenLUTData); free(pBlueLUTData); return nRet; } free(pRedLUTData); free(pGreenLUTData); free(pBlueLUTData); return DICOM_SUCCESS; }