Setting the attributes and bitmaps for all overlays inside a DICOM dataset Example for C#
//This example uses the predefined variable “LEADRasterView1”
of type “AxLEADRasterView” from “LEADTOOLS Toolkit”.
//This example uses the predefined variable “LEADRasterView2” of type “AxLEADRasterView”
from “LEADTOOLS Toolkit”.
//LEADDICOM1 is a DICOM Dataset defined outside this method
public void TestSettingTheAttributesAndBitmapsForAllOverlaysInsideDICOMDataset()
{
// This function will store the overlays associated
// with a bitmap handle inside the DICOM dataset
LTRASTERPROCLib.LEADOverlayAttributes OverlayAttributesDS
= null;
LTRASTERPROCLib.LEADOverlayAttributes OverlayAttributesRaster
= null;
int GroupNumber = 0;
bool IsOverlayInDataset = false;
int OverlayCount = 0;
int OverlayIndex = 0;
short iRet = 0;
LTRASTERPROCLib.LEADRasterProcess Process = new LTRASTERPROCLib.LEADRasterProcess();
IsOverlayInDataset = false;
GroupNumber = 0;
OverlayIndex = 0;
Process.EnableMethodErrors
= false;
// Do we have any overlays at all?
OverlayCount = Process.GetOverlayCount(LEADRasterView1.Raster,
0);
// If no overlays just exit sub
if (OverlayCount == 0)
{
MessageBox.Show("error");
return;
}
// Blow away all the overlays in the file
for (OverlayIndex = 0; OverlayIndex < OverlayCount;
OverlayIndex++)
{
LEADDICOM1.DeleteOverlay(OverlayIndex,
0);
}
OverlayAttributesDS = LEADDICOM1.OverlayAttributes;
// Loop through the overlays and add them into the DICOM
file
for (OverlayIndex = 0; OverlayIndex < OverlayCount;
OverlayIndex++)
{
// Get overlay attributes
iRet = Process.GetOverlayAttributes(LEADRasterView1.Raster,
(short)OverlayIndex, (int)(LTRASTERPROCLib.OverlayAttributesConstants.OVERLAYATTRIBUTES_ORIGIN
| LTRASTERPROCLib.OverlayAttributesConstants.OVERLAYATTRIBUTES_FLAGS |
LTRASTERPROCLib.OverlayAttributesConstants.OVERLAYATTRIBUTES_BITINDEX
| LTRASTERPROCLib.OverlayAttributesConstants.OVERLAYATTRIBUTES_DICOM));
if (iRet != 0)
{
MessageBox.Show("error");
return;
}
OverlayAttributesRaster = Process.OverlayAttributes;
OverlayAttributesDS.OriginX = OverlayAttributesRaster.OriginX;
OverlayAttributesDS.OriginY = OverlayAttributesRaster.OriginY;
OverlayAttributesDS.Flags = OverlayAttributesRaster.Flags;
OverlayAttributesDS.Color = System.Convert.ToUInt32(System.Drawing.ColorTranslator.FromOle(System.Convert.ToInt32(OverlayAttributesRaster.Color)));
OverlayAttributesDS.BitPosition = OverlayAttributesRaster.BitPosition;
OverlayAttributesDS.Rows = OverlayAttributesRaster.Rows;
OverlayAttributesDS.Columns = OverlayAttributesRaster.Columns;
OverlayAttributesDS.Type = OverlayAttributesRaster.Type;
OverlayAttributesDS.BitsAllocated =
OverlayAttributesRaster.BitsAllocated;
OverlayAttributesDS.Subtype = OverlayAttributesRaster.Subtype;
OverlayAttributesDS.Label = OverlayAttributesRaster.Label;
OverlayAttributesDS.ROIArea = OverlayAttributesRaster.ROIArea;
OverlayAttributesDS.ROIMean = OverlayAttributesRaster.ROIMean;
OverlayAttributesDS.ROIStandardDeviation
= OverlayAttributesRaster.ROIStandardDeviation;
OverlayAttributesDS.NumberFramesInOverlay
= OverlayAttributesRaster.NumberFramesInOverlay;
OverlayAttributesDS.ImageFrameOrigin
= OverlayAttributesRaster.ImageFrameOrigin;
OverlayAttributesDS.ActivationLayer
= OverlayAttributesRaster.ActivationLayer;
OverlayAttributesDS.Description = OverlayAttributesRaster.Description;
// Set overlay attributes inside DICOM
iRet = LEADDICOM1.SetOverlayAttributes(OverlayIndex,
0);
if (iRet != 0)
{
MessageBox.Show("error");
return;
}
// burn overlays which need to be part
of the image
if (((int)OverlayAttributesRaster.Flags
& (int)LTRASTERPROCLib.OverlayAttributesFlagsConstants.OVERLAY_USEBITPLANE)
!= 0)
{
iRet = Process.UpdateOverlayBits(LEADRasterView1.Raster,
(short)OverlayIndex, (int)LTRASTERPROCLib.OverlayBitsConstants.SETOVERLAYBITS_FROMOVERLAY);
if (iRet != 0)
{
MessageBox.Show("error");
return;
}
}
// Get the overlay data (if it's not
part of the image)
LEADRasterView2.Raster.Free();
iRet = Process.GetOverlayBitmap(LEADRasterView1.Raster,
(short)OverlayIndex, LEADRasterView2.Raster, (int)LTRASTERPROCLib.OverlayConstants.OVERLAY_COPY);
if (iRet != 0)
{
MessageBox.Show("error");
return;
}
// Set overlay data into
DICOM LEADDICOM1.OverlayBitmap = LEADRasterView2.Raster.Bitmap;
iRet = LEADDICOM1.SetOverlayBitmap(OverlayIndex,
0);
if (iRet != 0)
{
MessageBox.Show("error");
return;
}
}
}