LDicomDS::SetPaletteColorLUTData

Summary

Sets red, green or blue "Palette Color Lookup Table" data.

Syntax

#include "ltdic.h"

L_UINT16 LDicomDS::SetPaletteColorLUTData(pLUTData, uDataSize, PaletteColorLUTType, uFlags)

Parameters

L_UINT16 * pLUTData

Pointer to the buffer that holds the "Palette Color Lookup Table Data" to set.

L_UINT uDataSize

Size of the buffer pointed to by pLUTData.

DICOMPALETTECOLORLUTTYPE 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)

L_UINT uFlags

Reserved for future use. Pass 0.

Returns

Value Meaning
0 The function was successful.
> 0 An error occurred. Refer to Return Codes.

Comments

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

Platforms

Win32, x64

See Also

Functions

Topics

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;  
} 

Help Version 22.0.2022.12.7
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS DICOM C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.