Table of Contents

Class Bitmap

Namespace
SharpDX.WIC
Assembly
SharpDX.Direct2D1.dll
[Guid("00000121-a8f2-4877-ba0a-fd2b6645fb94")]
public class Bitmap : BitmapSource
Inheritance
Bitmap
Inherited Members

Constructors

Bitmap(ImagingFactory, BitmapSource, RawBox)

Initializes a new instance of the Bitmap class from a BitmapSource.

public Bitmap(ImagingFactory factory, BitmapSource bitmapSource, RawBox rectangle)

Parameters

factory ImagingFactory

The factory.

bitmapSource BitmapSource

The bitmap source.

rectangle RawBox

The rectangle.

Bitmap(ImagingFactory, BitmapSource, BitmapCreateCacheOption)

Initializes a new instance of the Bitmap class from a BitmapSource

public Bitmap(ImagingFactory factory, BitmapSource bitmapSource, BitmapCreateCacheOption option)

Parameters

factory ImagingFactory

The factory.

bitmapSource BitmapSource

The bitmap source ref.

option BitmapCreateCacheOption

The option.

Bitmap(ImagingFactory, int, int, Guid, DataRectangle, int)

Initializes a new instance of the Bitmap class from a memory location using SharpDX.DataRectangle.

public Bitmap(ImagingFactory factory, int width, int height, Guid pixelFormat, DataRectangle dataRectangle, int totalSizeInBytes = 0)

Parameters

factory ImagingFactory

The factory.

width int

The width.

height int

The height.

pixelFormat Guid

The pixel format.

dataRectangle DataRectangle

The data rectangle.

totalSizeInBytes int

Size of the buffer in . If == 0, calculate the size automatically based on the height and row pitch.

Bitmap(ImagingFactory, int, int, Guid, BitmapCreateCacheOption)

Initializes a new instance of the Bitmap class.

public Bitmap(ImagingFactory factory, int width, int height, Guid pixelFormat, BitmapCreateCacheOption option)

Parameters

factory ImagingFactory

The factory.

width int

The width.

height int

The height.

pixelFormat Guid

The pixel format. PixelFormat for a list of valid formats.

option BitmapCreateCacheOption

The option.

Bitmap(nint)

public Bitmap(nint nativePtr)

Parameters

nativePtr nint

Properties

Palette

Provides access for palette modifications.

public Palette Palette { set; }

Property Value

Palette

Methods

Lock(RawBox, BitmapLockFlags)

Provides access to a rectangular area of the bitmap.

public BitmapLock Lock(RawBox rcLockRef, BitmapLockFlags flags)

Parameters

rcLockRef RawBox

The rectangle to be accessed.

flags BitmapLockFlags

The access mode you wish to obtain for the lock. This is a bitwise combination of BitmapLockFlags for read, write, or read and write access.

ValueMeaning
Read

The read access lock.

Write

The write access lock.

?

Returns

BitmapLock

A reference that receives the locked memory location.

Remarks

Locks are exclusive for writing but can be shared for reading. You cannot call CopyPixels while the Bitmap is locked for writing. Doing so will return an error, since locks are exclusive.

Lock(BitmapLockFlags)

Provides access to a rectangular area of the bitmap.

public BitmapLock Lock(BitmapLockFlags flags)

Parameters

flags BitmapLockFlags

The access mode you wish to obtain for the lock. This is a bitwise combination of BitmapLockFlags for read, write, or read and write access.

ValueMeaning
Read

The read access lock.

Write

The write access lock.

?

Returns

BitmapLock

A reference that receives the locked memory location.

Remarks

Locks are exclusive for writing but can be shared for reading. You cannot call CopyPixels while the Bitmap is locked for writing. Doing so will return an error, since locks are exclusive.

New<T>(ImagingFactory, int, int, Guid, T[], int)

Initializes a new instance of the Bitmap class from an array of pixel data.

public static Bitmap New<T>(ImagingFactory factory, int width, int height, Guid pixelFormat, T[] pixelDatas, int stride = 0) where T : struct

Parameters

factory ImagingFactory

The factory.

width int

The width.

height int

The height.

pixelFormat Guid

The pixel format.

pixelDatas T[]

The pixel data.

stride int

Stride of a row of pixels (number of bytes per row). By default the stride is == 0, and calculated by taking the sizeof(T) * width.

Returns

Bitmap

Type Parameters

T

SetResolution(double, double)

Changes the physical resolution of the image.

public void SetResolution(double dpiX, double dpiY)

Parameters

dpiX double

The horizontal resolution.

dpiY double

The vertical resolution.

Remarks

This method has no effect on the actual pixels or samples stored in the bitmap. Instead the interpretation of the sampling rate is modified. This means that a 96 DPI image which is 96 pixels wide is one inch. If the physical resolution is modified to 48 DPI, then the bitmap is considered to be 2 inches wide but has the same number of pixels. If the resolution is less than REAL_EPSILON (1.192092896e-07F) the error code is returned.

Operators

explicit operator Bitmap(nint)

public static explicit operator Bitmap(nint nativePtr)

Parameters

nativePtr nint

Returns

Bitmap