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

See Also

Functions:

LDicomDS::GetPaletteColorLUTAttributes, LDicomDS::GetPaletteColorLUTData, LDicomDS::SetPaletteColorLUTAttributes, LDicomDS::DeletePaletteColorLUT, Class Members

Topics:

LUT Encoding Overview

 

LUT Encoding: Palette Color Table

Example

   //This example will set the attributes and the date for a 
// Palette Color Lookup Table
L_UINT16 MySetPaletteColorLUTData(LDicomDS &InDS) 
{
   L_INT                   nLUTIndex;   
   L_UINT16                uRet; 
   L_UINT16                *pRedLUTData               = NULL; 
   L_UINT16                *pGreenLUTData             = NULL; 
   L_UINT16                *pBlueLUTData              = NULL; 
   DICOMPALCOLORLUTATTRIBS PaletteColorLUTAttributes  = {0} ; 
   

   // Remember  to set the size for each structure
   SET_SIZE(&PaletteColorLUTAttributes); 
   SET_SIZE(&(PaletteColorLUTAttributes.RedLUTDescriptor)); 
   SET_SIZE(&(PaletteColorLUTAttributes.GreenLUTDescriptor)); 
   SET_SIZE(&(PaletteColorLUTAttributes.BlueLUTDescriptor)); 
      
   // 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] = nLUTIndex; 
      pGreenLUTData  [nLUTIndex] = nLUTIndex/2; 
      pBlueLUTData   [nLUTIndex] = nLUTIndex/4;   
   }
   // Delete all the elements that describe the "Palette Color Lookup Table".
   uRet = InDS.DeletePaletteColorLUT (0); 
   if(uRet != DICOM_SUCCESS) 
   {
      free(pRedLUTData); 
      free(pGreenLUTData); 
      free(pBlueLUTData); 
      return uRet;   
   }
   // Set the new "Palette Color Lookup Table" attributes
   uRet = InDS.SetPaletteColorLUTAttributes (&PaletteColorLUTAttributes, 0); 
   if(uRet != DICOM_SUCCESS) 
   {
      free(pRedLUTData); 
      free(pGreenLUTData); 
      free(pBlueLUTData); 
      return uRet;   
   }
   // Set Red Palette Color Lookup Table Data
   uRet = InDS.SetPaletteColorLUTData (pRedLUTData,0x10000,DICOMPALETTECOLORLUTTYPE_RED,0); 
   if(uRet != DICOM_SUCCESS) 
   {
      free(pRedLUTData); 
      free(pGreenLUTData); 
      free(pBlueLUTData); 
      return uRet;   
   }
   // Set Green Palette Color Lookup Table Data
   uRet = InDS.SetPaletteColorLUTData (pGreenLUTData,0x10000,DICOMPALETTECOLORLUTTYPE_GREEN,0); 
   if(uRet != DICOM_SUCCESS) 
   {
      free(pRedLUTData); 
      free(pGreenLUTData); 
      free(pBlueLUTData); 
      return uRet;   
   }
   // Set Blue Palette Color Lookup Table Data
   uRet = InDS.SetPaletteColorLUTData (pBlueLUTData,0x10000,DICOMPALETTECOLORLUTTYPE_BLUE,0); 
   if(uRet != DICOM_SUCCESS) 
   {
      free(pRedLUTData); 
      free(pGreenLUTData); 
      free(pBlueLUTData); 
      return uRet;   
   }

   free(pRedLUTData); 
   free(pGreenLUTData); 
   free(pBlueLUTData); 
   return DICOM_SUCCESS; 

}