L_DicomSetPaletteColorLUTData

#include "ltdic.h"

L_LTDIC_API L_UINT16 L_DicomSetPaletteColorLUTData(hDS, pLUTData, uDataSize, PaletteColorLUTType, uFlags)

HDICOMDS hDS;

/* a DICOM handle */

L_UINT16 * pLUTData;

/* pointer to the input buffer */

L_UINT uDataSize;

/* size of the input buffer */

DICOMPALETTECOLORLUTTYPE PaletteColorLUTType;

/* type of palette color lookup table to set */

L_UINT uFlags;

/* reserved for future use */

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

Parameter

Description

hDS

A DICOM handle.

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. Possible values are:

 

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 L_DicomSetPaletteColorLUTAttributes 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

Platforms

Win32, x64

See Also

Functions:

L_DicomGetPaletteColorLUTAttributes, L_DicomGetPaletteColorLUTData, L_DicomSetPaletteColorLUTAttributes, L_DicomDeletePaletteColorLUT

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

#define SET_SIZE(p) (p)->uStructSize = sizeof(*(p));

L_INT DicomSetPaletteColorLUTDataExample(HDICOMDS hDicomDS)
{
   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] = (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".
   uRet = L_DicomDeletePaletteColorLUT(hDicomDS,0);
   if(uRet != DICOM_SUCCESS)
   {
      free(pRedLUTData);
      free(pGreenLUTData);
      free(pBlueLUTData);
      return uRet;
   }

   // Set the new "Palette Color Lookup Table" attributes
   uRet = L_DicomSetPaletteColorLUTAttributes(hDicomDS,&PaletteColorLUTAttributes, 0);
   if(uRet != DICOM_SUCCESS)
   {
      free(pRedLUTData);
      free(pGreenLUTData);
      free(pBlueLUTData);
      return uRet;
   }

   // Set Red Palette Color Lookup Table Data
   uRet = L_DicomSetPaletteColorLUTData(hDicomDS,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 = L_DicomSetPaletteColorLUTData(hDicomDS,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 = L_DicomSetPaletteColorLUTData(hDicomDS,pBlueLUTData,0x10000,DICOMPALETTECOLORLUTTYPE_BLUE,0);

   free(pRedLUTData);
   free(pGreenLUTData);
   free(pBlueLUTData);
   return uRet;
}