DicomObjects.NET.8.48 Documentation
DicomObjects Namespace / DicomDataSet Class / GetRawFrame Method
Frame number to extract
Cache result for the extracted frame
Example

In This Topic
    GetRawFrame Method (DicomDataSet)
    In This Topic
    Extract individual frame from the pixel data
    Syntax
    'Declaration
     
    
    Public Function GetRawFrame( _
       ByVal Frame As System.Integer, _
       ByVal cache As System.Boolean _
    ) As System.Byte()
    public System.byte[] GetRawFrame( 
       System.int Frame,
       System.bool cache
    )

    Parameters

    Frame
    Frame number to extract
    cache
    Cache result for the extracted frame

    Return Value

    Raw pixel data of the request frame
    Example
    DicomDataSet ds = new DicomDataSet("Dataset.dcm");
    int frame = 10;
    bool cache = true;
    var pixelBytes = ds.GetRawFrame(frame, cache);
                        
    if (pixelBytes != null)
    {
        int width = Convert.ToInt32(ds[Keyword.Columns].Value);
        int height = Convert.ToInt32(ds[Keyword.Rows].Value);
        
        using (Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format24bppRgb))
        {
            BitmapData bmpData = bitmap.LockBits(new Rectangle(0, 0, width, height),
                ImageLockMode.WriteOnly, bitmap.PixelFormat);
            
            IntPtr ptr = bmpData.Scan0;
            Marshal.Copy(pixelBytes, 0, ptr, pixelBytes.Length);
            bitmap.UnlockBits(bmpData);          
            bitmap.Save(frame10.png", ImageFormat.Png);
        }
    }
    Requirements

    Target Platforms: .NET CLR 4.8 or higher

    See Also