#include "ltdic.h"
L_LTDIC_API L_UINT16 L_DicomSetOverlayAttributes(hDS, uOverlayIndex, pOverlayAttributes, uFlags)
HDICOMDS hDS; |
a DICOM handle |
L_UINT uOverlayIndex; |
the overlay index |
pOVERLAYATTRIBUTES pOverlayAttributes; |
pointer to the overlay attributes structure |
L_UINT uFlags; |
flags that determine function behavior |
Sets overlay attributes for a certain index.
Parameter | Description | |
hDS | A DICOM handle. | |
uOverlayIndex | The index of the overlay for which to set the attributes. This index is zero-based. | |
pOverlayAttributes | Pointer to a structure containing the overlay attributes to set. | |
uFlags | Binary flags that determine the behavior of the function. Possible values are: | |
Value | Meaning | |
SET_OVERLAY_ATTRIB_NO_OVERRIDE | Set this flag if you don't want to update an overlay that already exists in the dataset. |
DICOM_SUCCESS |
The function was successful. |
>0 |
An error occurred. Refer to Return Codes. |
Before calling this function, initialize pOverlayAttributes->uStructSize to be sizeof(OVERLAYATTRIBUTES) and initialize all the OVERLAYATTRIBUTES structure members.
Required DLLs and Libraries
For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application |
Win32, x64, Linux.
//This function will delete all overlays in a dataset
L_UINT16 DeleteAllOverlays(HDICOMDS hDicomDS) // handle to Dicom DS
{
L_UINT uOverlayCount = 0;
L_UINT16 uRet;
L_UINT16 uOverlayIndex;
uRet = L_DicomGetOverlayCount(hDicomDS,&uOverlayCount);
if(DICOM_SUCCESS != uRet)
return uRet;
for(uOverlayIndex = 0 ; uOverlayIndex < uOverlayCount ; uOverlayIndex++)
{
uRet = L_DicomDeleteOverlay(hDicomDS,uOverlayIndex,0);
if(DICOM_SUCCESS != uRet)
return uRet;
}
return DICOM_SUCCESS;
}
// This function will store the overlays associated
// with a bitmap handle inside the DICOM dataset
L_INT DicomSetOverlayAttributesExample(
HDICOMDS hDicomDS,
pBITMAPHANDLE pBitmap)
{
OVERLAYATTRIBUTES OverlayAttributes;
BITMAPHANDLE OverlayBitmap;
L_UINT uOverlayCount;
L_UINT uOverlayIndex;
L_INT nLEADRet;
L_UINT16 uDICOMRet;
//(1)Sanity Check !
if((NULL == pBitmap) || (NULL == hDicomDS))
return DICOM_ERROR_NULL_PTR;
//(2)Do we have any overlays at all ?
nLEADRet = L_GetOverlayCount(pBitmap, &uOverlayCount, 0);
if(SUCCESS != nLEADRet)
return DICOM_ERROR_PARAMETER;
// If no overlays just return
if(0 == uOverlayCount)
return DICOM_SUCCESS;
//(3)Blow away all the overlays in the file
uDICOMRet = DeleteAllOverlays(hDicomDS);
if(DICOM_SUCCESS != uDICOMRet)
return uDICOMRet;
//(4) Loop through the overlays and add them into the DICOM file
for(uOverlayIndex = 0 ; uOverlayIndex < uOverlayCount ; uOverlayIndex++)
{
memset(&OverlayAttributes , 0 , sizeof(OVERLAYATTRIBUTES));
memset(&OverlayBitmap , 0 , sizeof(BITMAPHANDLE));
// Get overlay attributes
nLEADRet = L_GetOverlayAttributes(pBitmap, uOverlayIndex, &OverlayAttributes, sizeof(OverlayAttributes), OVERLAYATTRIBUTES_ORIGIN | OVERLAYATTRIBUTES_FLAGS | OVERLAYATTRIBUTES_BITINDEX | OVERLAYATTRIBUTES_DICOM);
if(SUCCESS != nLEADRet)
return DICOM_ERROR_PARAMETER;
// Set overlay attributes inside DICOM
uDICOMRet = L_DicomSetOverlayAttributes(hDicomDS,uOverlayIndex,&OverlayAttributes,0);
if(DICOM_SUCCESS != uDICOMRet)
return uDICOMRet;
// burn overlays which need to be part of the image
if(OverlayAttributes.uFlags &OVERLAY_USEBITPLANE)
{
nLEADRet = L_UpdateBitmapOverlayBits(pBitmap, uOverlayIndex, SETOVERLAYBITS_FROMOVERLAY);
if(SUCCESS != nLEADRet)
return DICOM_ERROR_PARAMETER;
}
// Get the overlay data (if it's not part of the image)
nLEADRet = L_GetOverlayBitmap(pBitmap, uOverlayIndex, &OverlayBitmap, sizeof(BITMAPHANDLE), OVERLAY_NOCOPY);
if(SUCCESS != nLEADRet)
return DICOM_ERROR_PARAMETER;
// Set overlay data into DICOM
uDICOMRet = L_DicomSetOverlayBitmap(hDicomDS,uOverlayIndex,&OverlayBitmap,0);
if(DICOM_SUCCESS != uDICOMRet)
return uDICOMRet;
}
return DICOM_SUCCESS;
}