LDicomDS::SetWindow
#include "ltdic.h"
L_UINT16 LDicomDS::SetWindow(uWindowIndex, pWindowAttributes, uFlags)
L_UINT uWindowIndex; |
/* index */ |
pDICOMWINDOWATTRIBS pWindowAttributes; |
/* pointer to a structure */ |
L_UINT uFlags; |
/* reserved for future use */ |
Sets the attributes that describe the window center and the window width.
Parameter |
Description |
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 isnert 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
Example
This example will add a new "Window Width" and "Window Center" to the dataset , or replace the existing one(s).
L_INT LDicomDS_SetWindowExample(LDicomDS &InDS, L_UINT uBitsStored, L_BOOL bAdd/*Add a new window or replace the existing one(s)*/ ) { L_INT nRet; DICOMWINDOWATTRIBS WindowAttributes ={0}; L_UINT uWindowCount=0; L_UINT uWindowIndex=0; WindowAttributes.uStructSize = sizeof(DICOMWINDOWATTRIBS); nRet = InDS.GetWindowCount (&uWindowCount); if(nRet != DICOM_SUCCESS) { return nRet; } if(uWindowCount > 0) { nRet = InDS.GetWindow (0,&WindowAttributes, sizeof(DICOMWINDOWATTRIBS),0); if(nRet != DICOM_SUCCESS) { return nRet; } // 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) nRet = InDS.DeleteWindow (0); if(nRet != DICOM_SUCCESS) { return nRet; } uWindowIndex = 0; } // Add the new window return InDS.SetWindow (uWindowIndex,&WindowAttributes,0); }