DicomObjects.NET.8.48 Documentation
DicomObjects Namespace / DicomImage Class / Bitmap Method / Bitmap(Size,PixelFormat,Matrix) Method
The size of the image to generate
The requested format
The Matrix to apply to convert from DICOM coordinates to Bitmap coordinates
Example

In This Topic
    Bitmap(Size,PixelFormat,Matrix) Method
    In This Topic
    Creates a new Bitmap object, in the chosen format representing the appearance of a DicomImage
    Syntax
    'Declaration
     
    
    Public Overloads Function Bitmap( _
       ByVal Size As System.Drawing.Size, _
       ByVal Format As System.Drawing.Imaging.PixelFormat, _
       ByVal Matrix As System.Drawing.Drawing2D.Matrix _
    ) As System.Drawing.Bitmap
    public System.Drawing.Bitmap Bitmap( 
       System.Drawing.Size Size,
       System.Drawing.Imaging.PixelFormat Format,
       System.Drawing.Drawing2D.Matrix Matrix
    )

    Parameters

    Size
    The size of the image to generate
    Format
    The requested format
    Matrix
    The Matrix to apply to convert from DICOM coordinates to Bitmap coordinates

    Return Value

    A Bitmap object
    Remarks
    Only some formats are allowed by Windows - only those supported by System.Drawing.Graphics.FromImage(System.Drawing.Image)
    Example
    DicomImage image = new DicomImage("path_to_your_dicom_image");
                        
    int width = 512;
    int height = 512;
    Size size = new Size(width, height);
     
    Matrix matrix = new Matrix();
    matrix.Scale(1.5f, 1.5f); // Scale 1.5x in both width and height
                        
    // Basic bitmap call with predefined size
    var bitmap = image.Bitmap(size, PixelFormat.Format24bppRgb, new Matrix());
                        
    // A Matrix applied 
    var bitmap = image.Bitmap(size, PixelFormat.Format24bppRgb, matrix);
                        
    var originalWidth = Convert.ToInt16(image.DataSet[Keyword.Columns].Value);
    var originalHeight = Convert.ToInt16(image.DataSet[Keyword.Rows].Value);
    Size originalSize = new Size(originalWidth, originalHeight);
                        
    // Original Image Size
    var bitmap = image.Bitmap(originalSize, PixelFormat.Format24bppRgb, new Matrix());
                        
    bitmap.Save("path_to_save_location_image.bmp");
    Requirements

    Target Platforms: .NET CLR 4.8 or higher

    See Also