DicomObjects.NET.8.48 Documentation
DicomObjects Namespace / DicomImage Class / SetPixelData Method
The transfer syntax of the data provided via the GetData function
User defined function to return the correct pixel data stream for the requested frame number
Example

In This Topic
    SetPixelData Method
    In This Topic
    Method to set pixel data directly from a stream
    Syntax
    'Declaration
     
    
    Public Sub SetPixelData( _
       ByVal TransferSyntax As System.String, _
       ByVal GetData As System.Func(Of Integer,Stream) _
    ) 
    public void SetPixelData( 
       System.string TransferSyntax,
       System.Func<int,Stream> GetData
    )

    Parameters

    TransferSyntax
    The transfer syntax of the data provided via the GetData function
    GetData
    User defined function to return the correct pixel data stream for the requested frame number
    Example
    DicomImage image = new DicomImage();
    image.DataSet.Add(Keyword.SamplesPerPixel, 1);
    image.DataSet.Add(Keyword.PhotometricInterpretation, "MONOCHROME2");
    image.DataSet.Add(Keyword.Rows, 512);
    image.DataSet.Add(Keyword.Columns, 512);
    image.DataSet.Add(Keyword.PixelSpacing, new float[] { 0.684f, 0.684f });
    image.DataSet.Add(Keyword.BitsAllocated, 16);
    image.DataSet.Add(Keyword.BitsStored, 12);
    image.DataSet.Add(Keyword.HighBit, 11);
    image.DataSet.Add(Keyword.PixelRepresentation, 0);
    image.DataSet.Add(Keyword.WindowCenter, new int[] { 35, 50 });
    image.DataSet.Add(Keyword.WindowWidth, new int[] { 350, 150 });
    image.DataSet.Add(Keyword.RescaleIntercept, -1200);
    image.DataSet.Add(Keyword.RescaleSlope, 1);
    image.SetPixelData(TransferSyntaxes.ExplicitVRLittleEndian, getData);
    Viewer.Images.Add(image); // Assumes an existing DicomViewer obj
                        
    private Stream getData(int arg)
    {
        return new FileStream("your_non_dicom_image", FileMode.Open);
    }
    Requirements

    Target Platforms: .NET CLR 4.8 or higher

    See Also