Setting the attributes and bitmaps for all overlays inside a DICOM dataset Example for Delphi
// This function will store the overlays associated
// with a bitmap handle inside the DICOM dataset
var
OverlayAttributesDS: LEADOverlayAttributes;
OverlayAttributesRaster: LEADOverlayAttributes;
OverlayCount: LongInt;
OverlayIndex: LongInt;
nRet: Integer;
Process: LEADRasterProcess;
begin
Process:= CoLEADRasterProcess.Create();
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)then
begin
ShowMessage('error');
Exit;
end;
// Blow away all the overlays in the file
for OverlayIndex:= 0 to OverlayCount - 1 do
LEADDicomDS1.DeleteOverlay(OverlayIndex, 0);
OverlayAttributesDS:= LEADDicomDS1.OverlayAttributes;
// Loop through the overlays and add them into the DICOM file
for OverlayIndex:= 0 to OverlayCount - 1 do
begin
// Get overlay attributes
nRet:= Process.GetOverlayAttributes (LEADRasterView1.Raster, OverlayIndex, OVERLAYATTRIBUTES_ORIGIN Or OVERLAYATTRIBUTES_FLAGS Or OVERLAYATTRIBUTES_BITINDEX Or OVERLAYATTRIBUTES_DICOM);
if(nRet <> 0)then
begin
ShowMessage('error');
Exit;
end;
OverlayAttributesRaster:= Process.OverlayAttributes;
OverlayAttributesDS.OriginX:= OverlayAttributesRaster.OriginX;
OverlayAttributesDS.OriginY:= OverlayAttributesRaster.OriginY;
OverlayAttributesDS.Flags:= OverlayAttributesRaster.Flags;
OverlayAttributesDS.Color:= 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
nRet:= LEADDicomDS1.SetOverlayAttributes (OverlayIndex, 0);
if(nRet <> 0)then
begin
ShowMessage('error');
Exit;
end;
// burn overlays which need to be part of the image
if((OverlayAttributesRaster.Flags And OVERLAY_USEBITPLANE)=OVERLAY_USEBITPLANE)then
begin
nRet:= Process.UpdateOverlayBits(LEADRasterView1.Raster, OverlayIndex, SETOVERLAYBITS_FROMOVERLAY);
if(nRet <> 0)then
ShowMessage('error');
end;
// Get the overlay data (if it//s not part of the image)
LEADRasterView2.Raster.Free();
nRet:= Process.GetOverlayBitmap (LEADRasterView1.Raster, OverlayIndex, LEADRasterView2.Raster, OVERLAY_COPY);
if(nRet <> 0)then
begin
ShowMessage('error');
Exit;
end;
// Set overlay data into DICOM
LEADDicomDS1.OverlayBitmap:= LEADRasterView2.Raster.Bitmap;
nRet:= LEADDicomDS1.SetOverlayBitmap (OverlayIndex, 0);
if(nRet <> 0)then
begin
ShowMessage('error');
Exit;
end;
end;
end;