public int CreateLayer(DicomGraphicLayer graphicLayer)
Public Function CreateLayer( _ByVal graphicLayer As DicomGraphicLayer _) As Integer
public:int CreateLayer(DicomGraphicLayer^ graphicLayer)
graphicLayer
A Graphic Layer attributes , which holds the attributes of the layer to be created.
The index of the newly created layer.
If for example there are already 2 items under the "Graphic Layer Sequence" (0070,0060) and we call this method, then the index of the new layer will be 2. This method will fail and throw a DicomExceptionCode.Parameter exception if a layer with the same name as the new layer already exists in the Data Set.
This example will initialize a new DICOM dataset, insert a new layer with one graphic object and one text object.
using Leadtools;using Leadtools.Dicom;public void DicomLayerSample(){//Make sure to initialize the DICOM engine, this needs to be done only once//In the whole applicationDicomEngine.Startup();using (DicomDataSet dicomDataset = new DicomDataSet()){// We can also initialize in here the "Grayscale Softcopy Presentation State" classdicomDataset.Initialize(DicomClassType.Undefined, DicomDataSetInitializeType.ExplicitVRLittleEndian);//We can remove individual layers by calling RemoveLayerByIndex and RemoveLayerByNamedicomDataset.RemoveAllLayers(true);DicomGraphicLayer graphicLayer = new DicomGraphicLayer();graphicLayer.LayerOrder = 1;graphicLayer.LayerDescription = "First Layer";graphicLayer.LayerName = "LAYER0";graphicLayer.Grayscale = 0;graphicLayer.RgbLayerColor[0] = 255;dicomDataset.CreateLayer(graphicLayer);Debug.Assert(dicomDataset.GetLayerIndex("LAYER0") == 0);DicomGraphicLayer graphicLayer1 = dicomDataset.GetLayerInformation(0);Debug.Assert(graphicLayer1 != null);Debug.Assert(graphicLayer1.LayerOrder == 1);graphicLayer.LayerName = "LAYER1";dicomDataset.SetLayerInformation(0, graphicLayer);Debug.Assert(dicomDataset.LayerCount == 1);// We can also call GetLayerElementByName to get the layer elementDicomElement layer = dicomDataset.GetLayerElementByIndex(0);Debug.Assert(layer != null);dicomDataset.RemoveLayerGraphicObjects(layer);Debug.Assert(dicomDataset.GetLayerGraphicObjectCount(layer) == 0);dicomDataset.RemoveLayerTextObjects(layer);Debug.Assert(dicomDataset.GetLayerTextObjectCount(layer) == 0);dicomDataset.Save(Path.Combine(LEAD_VARS.ImagesDir, "DICOM", "PresentationState.dcm"), DicomDataSetSaveFlags.None);}DicomEngine.Shutdown();}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images";}
Imports LeadtoolsImports Leadtools.DicomPublic Sub DicomLayerSample()'Make sure to initialize the DICOM engine, this needs to be done only once'In the whole applicationDicomEngine.Startup()Dim dicomDataset As DicomDataSet = New DicomDataSet()Using (dicomDataset)' We can also initialize in here the "Grayscale Softcopy Presentation State" classdicomDataset.Initialize(DicomClassType.Undefined, DicomDataSetInitializeType.ExplicitVRLittleEndian)'We can remove individual layers by calling RemoveLayerByIndex and RemoveLayerByNamedicomDataset.RemoveAllLayers(True)Dim graphicLayer As DicomGraphicLayer = New DicomGraphicLayer()graphicLayer.LayerOrder = 1graphicLayer.LayerDescription = "First Layer"graphicLayer.LayerName = "LAYER0"graphicLayer.Grayscale = 0graphicLayer.RgbLayerColor(0) = 255dicomDataset.CreateLayer(graphicLayer)Debug.Assert(dicomDataset.GetLayerIndex("LAYER0") = 0)Dim graphicLayer1 As DicomGraphicLayer = dicomDataset.GetLayerInformation(0)Debug.Assert(Not graphicLayer1 Is Nothing)Debug.Assert(graphicLayer1.LayerOrder = 1)graphicLayer.LayerName = "LAYER1"dicomDataset.SetLayerInformation(0, graphicLayer)Debug.Assert(dicomDataset.LayerCount = 1)' We can also call GetLayerElementByName to get the layer elemntDim layer As DicomElement = dicomDataset.GetLayerElementByIndex(0)Debug.Assert(Not layer Is Nothing)dicomDataset.RemoveLayerGraphicObjects(layer)Debug.Assert(dicomDataset.GetLayerGraphicObjectCount(layer) = 0)dicomDataset.RemoveLayerTextObjects(layer)Debug.Assert(dicomDataset.GetLayerTextObjectCount(layer) = 0)dicomDataset.Save(Path.Combine(LEAD_VARS.ImagesDir, "PresentationState.dcm"), DicomDataSetSaveFlags.None)End UsingDicomEngine.Shutdown()End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\LEADTOOLS21\Resources\Images"End Class
GetLayerGraphicObjectCount Method
RemoveLayerGraphicObjects Method
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
