DicomObjects.NET.8.48 Documentation
DicomObjects Namespace / DicomImage Class / RenderToArray Method / RenderToArray(Array,Boolean,Int32) Method

Array to write the image presentation data to

Set Colour to True if you want the color output.

Bit depth of final data.

Example

In This Topic
    RenderToArray(Array,Boolean,Int32) Method
    In This Topic
    Render the DicomImage to array. The data returned will be exactly the same as the "presentation data" if the Image gets displayed on screen.
    Syntax
    'Declaration
     
    
    Public Overloads Sub RenderToArray( _
       ByVal destination As System.Array, _
       ByVal Colour As System.Boolean, _
       ByVal BitsPerSample As System.Integer _
    ) 
    public void RenderToArray( 
       System.Array destination,
       System.bool Colour,
       System.int BitsPerSample
    )

    Parameters

    destination

    Array to write the image presentation data to

    Colour

    Set Colour to True if you want the color output.

    BitsPerSample

    Bit depth of final data.

    Example
    DicomImage image = new DicomImage("your_dicom_image.dcm");
                        
    int width = Convert.ToUInt16(image.DataSet[Keyword.Columns].Value);
    int height = Convert.ToUInt16(image.DataSet[Keyword.Rows].Value);
                        
    bool useColour = false;
    int bitsPerSample = 8; // 8-bit grayscale output
                        
    int channels = useColour ? 3 : 1;
    Array destinationArray = useColour ? new byte[width * height * channels] : new byte[width * height];
    image.RenderToArray(destinationArray, useColour, bitsPerSample);
    Requirements

    Target Platforms: .NET CLR 4.8 or higher

    See Also