Export (0) Print
Expand All

Bitmap Constructor (Int32, Int32, Int32, PixelFormat, IntPtr)

Initializes a new instance of the Bitmap class with the specified size, pixel format, and pixel data.

Namespace:  System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)

new : 
        width:int * 
        height:int * 
        stride:int * 
        format:PixelFormat * 
        scan0:IntPtr -> Bitmap


Type: System.Int32

The width, in pixels, of the new Bitmap.

Type: System.Int32

The height, in pixels, of the new Bitmap.

Type: System.Int32

Integer that specifies the byte offset between the beginning of one scan line and the next. This is usually (but not necessarily) the number of bytes in the pixel format (for example, 2 for 16 bits per pixel) multiplied by the width of the bitmap. The value passed to this parameter must be a multiple of four..

Type: System.Drawing.Imaging.PixelFormat

The pixel format for the new Bitmap. This must specify a value that begins with Format.

Type: System.IntPtr

Pointer to an array of bytes that contains the pixel data.


A PixelFormat value is specified whose name does not start with Format. For example, specifying Gdi will cause an ArgumentException, but Format48bppRgb will not.

The caller is responsible for allocating and freeing the block of memory specified by the scan0 parameter. However, the memory should not be released until the related Bitmap is released.

The following code example shows how to use the Bitmap(Int32, Int32, Int32, PixelFormat, IntPtr) constructor. This example is designed to be used with Windows Forms and requires a PaintEventArgs parameter, which is a parameter of the Paint event.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

© 2015 Microsoft