L_DicomSetWindow

#include "ltdic.h"

L_UINT16 EXT_FUNCTION L_DicomSetWindow(hDS, uWindowIndex, pWindowAttributes, uFlags)

HDICOMDS hDS;

/* a DICOM handle */

L_UINT uWindowIndex;

/* the window index*/

pDICOMWINDOWATTRIBS pWindowAttributes;

/* pointer to a window attributes structure that holds the new values */

L_UINT uFlags;

/* reserved for future use */

Sets the attributes that describe window center and window width.

Parameter

Description

hDS

A DICOM handle.

uWindowIndex

Index to the window center , window width value to be updated. According to the DICOM standard if multiple values are present for the window center and window width, both attributes shall have the same number of values and shall be considered as pairs. This index is zero-based.

pWindowAttributes

Pointer to a structure containing the window-related attributes to set.

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 attributes that describe window center and window width.

Before calling this function, initialize pWindowAttributes->uStructSize to be sizeof (DICOMWINDOWATTRIBS) and initialize all the members of the structure.

If "Window Center" (0028,1050) does not already exist in the dataset this function will insert it and set its value to pWindowAttributes->fWindowCenter.

If "Window Width" (0028,1051) does not already exist in the dataset this function will insert it and set its value to pWindowAttributes->fWindowWidth.

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:

L_DicomGetWindowCount, L_DicomGetVOILUTCount, L_DicomGetWindow, L_DicomDeleteWindow, L_DicomGetVOILUT, L_DicomSetVOILUT, L_DicomGetVOILUTData, L_DicomDeleteVOILUT

Topics:

LUT Encoding Overview

 

LUT Encoding: VOI LUT

Example

// This example will add a new "Window Width" and 
// "Window Center" to the dataset , or replace 
// the existing one(s)
L_UINT16 MySetWindow(HDICOMDS hDicomDS, L_UINT uBitsStored, L_BOOL bAdd)
{
   DICOMWINDOWATTRIBS   WindowAttributes ={0};
   L_UINT16             uRet;
   L_UINT               uWindowCount=0;
   L_UINT               uWindowIndex=0;

   SET_SIZE(&WindowAttributes);
   uRet = L_DicomGetWindowCount(hDicomDS,&uWindowCount);
   if(uRet != DICOM_SUCCESS)
   {      
      return uRet;   
   }

   if(uWindowCount>0)
   {
      uRet = L_DicomGetWindow(hDicomDS,0,&WindowAttributes, sizeof(DICOMWINDOWATTRIBS),0);
      if(uRet != DICOM_SUCCESS)
      {      
         return uRet;   
      }      

      // Half the width for the first window
      WindowAttributes.fWindowWidth    = WindowAttributes.fWindowWidth  /2;
      WindowAttributes.fWindowCenter   = WindowAttributes.fWindowCenter /2;
   }
   else
   {   
      // This represents an identity VOI LUT transformation in the case 
      // where no Modality LUT is specified and the stored pixel data are 
      // uBitsStored bit unsigned integers.
      WindowAttributes.fWindowWidth    = 1 << uBitsStored      ;
      WindowAttributes.fWindowCenter   = 1 << (uBitsStored-1)  ;
   }

   uWindowIndex = uWindowCount;
   if(!bAdd)
   {
      // Delete the existing window(s)
      uRet = L_DicomDeleteWindow(hDicomDS,0);
      if(uRet != DICOM_SUCCESS)
      {      
         return uRet;      
      }
      uWindowIndex = 0;
   }   

   // Add the new window
   return L_DicomSetWindow(hDicomDS,uWindowIndex,&WindowAttributes,0);   
}