Setting the attributes and bitmaps for all overlays inside a DICOM dataset Example for C++ 6.0 and later
void CDicomDlg::DeleteAllOverlays()
{
long lOverlayCount = 0;
short iRet;
long lOverlayIndex;
lOverlayCount = m_pLEADDicomDS->GetOverlayCount ();
for(lOverlayIndex = 0; lOverlayIndex<lOverlayCount; lOverlayIndex++)
{
iRet = m_pLEADDicomDS->DeleteOverlay(lOverlayIndex,0);
if(iRet != 0)
{
AfxMessageBox("error");
return;
}
}
return;
}
void CDicomDlg::OnButtonSetOverlays()
{
// This function will store the overlays associated
// with a bitmap handle inside the DICOM dataset
ILEADOverlayAttributesPtr pOverlayAttributesDS = NULL;
ILEADOverlayAttributesPtr pOverlayAttributesRaster = NULL;
ILEADRasterProcessPtr pRasterProcess=NULL;
long GroupNumber = 0;
BOOL bIsOverlayInDataset = FALSE;
short iOverlayCount;
short iOverlayIndex=0;
short iRet;
CoCreateInstance(CLSID_LEADRasterProcess,
NULL,
CLSCTX_ALL,
IID_ILEADRasterProcess,
(void**)&pRasterProcess);
pRasterProcess->EnableMethodErrors = FALSE;
// Do we have any overlays at all?
iOverlayCount = pRasterProcess->GetOverlayCount (m_LEADRasterView1.GetRaster(), 0);
// If no overlays just return
if(iOverlayCount == 0)
{
AfxMessageBox("error");
return;
}
// Blow away all the overlays in the file
DeleteAllOverlays();
pOverlayAttributesDS = m_pLEADDicomDS->GetOverlayAttributes ();
// Loop through the overlays and add them into the DICOM file
for(iOverlayIndex=0; iOverlayIndex<iOverlayCount; iOverlayIndex++)
{
// Get overlay attributes
iRet = pRasterProcess->GetOverlayAttributes (m_LEADRasterView1.GetRaster(), iOverlayIndex,
OVERLAYATTRIBUTES_ORIGIN |
OVERLAYATTRIBUTES_FLAGS |
OVERLAYATTRIBUTES_BITINDEX |
OVERLAYATTRIBUTES_DICOM);
if(iRet != 0)
{
AfxMessageBox("error");
return;
}
pOverlayAttributesRaster = pRasterProcess->GetOverlayAttributes ();
pOverlayAttributesDS->OriginX = pOverlayAttributesRaster->OriginX;
pOverlayAttributesDS->OriginY = pOverlayAttributesRaster->OriginY;
pOverlayAttributesDS->Flags = pOverlayAttributesRaster->Flags;
pOverlayAttributesDS->Color = pOverlayAttributesRaster->Color;
pOverlayAttributesDS->BitPosition = pOverlayAttributesRaster->BitPosition;
pOverlayAttributesDS->Rows = pOverlayAttributesRaster->Rows;
pOverlayAttributesDS->Columns = pOverlayAttributesRaster->Columns;
pOverlayAttributesDS->Type = pOverlayAttributesRaster->Type;
pOverlayAttributesDS->BitsAllocated = pOverlayAttributesRaster->BitsAllocated;
pOverlayAttributesDS->Subtype = pOverlayAttributesRaster->Subtype;
pOverlayAttributesDS->Label = pOverlayAttributesRaster->Label;
pOverlayAttributesDS->ROIArea = pOverlayAttributesRaster->ROIArea;
pOverlayAttributesDS->ROIMean = pOverlayAttributesRaster->ROIMean;
pOverlayAttributesDS->ROIStandardDeviation = pOverlayAttributesRaster->ROIStandardDeviation;
pOverlayAttributesDS->NumberFramesInOverlay = pOverlayAttributesRaster->NumberFramesInOverlay;
pOverlayAttributesDS->ImageFrameOrigin = pOverlayAttributesRaster->ImageFrameOrigin;
pOverlayAttributesDS->ActivationLayer = pOverlayAttributesRaster->ActivationLayer;
pOverlayAttributesDS->Description = pOverlayAttributesRaster->Description;
// Set overlay attributes inside DICOM
iRet = m_pLEADDicomDS->SetOverlayAttributes(iOverlayIndex,0);
if(iRet != 0)
{
AfxMessageBox("error");
return;
}
// burn overlays which need to be part of the image
if(pOverlayAttributesRaster->Flags & OVERLAY_USEBITPLANE)
{
iRet = pRasterProcess->UpdateOverlayBits(m_LEADRasterView1.GetRaster(),
iOverlayIndex,
SETOVERLAYBITS_FROMOVERLAY);
if(iRet != 0)
{
AfxMessageBox("error");
return;
}
}
// Get the overlay data (if it's not part of the image)
m_LEADRasterView2.GetRaster().Free();
iRet = pRasterProcess->GetOverlayBitmap (m_LEADRasterView1.GetRaster(),
iOverlayIndex,
m_LEADRasterView2.GetRaster(),
OVERLAY_COPY);
if(iRet != 0)
{
AfxMessageBox("error");
return;
}
// Set overlay data into DICOM
m_pLEADDicomDS->OverlayBitmap = m_LEADRasterView2.GetRaster().GetBitmap();
iRet = m_pLEADDicomDS->SetOverlayBitmap (iOverlayIndex, 0);
if(iRet != 0)
{
AfxMessageBox("error");
return;
}
}
return;
}