Class Bitmap
[Guid("a2296057-ea42-4099-983b-539fb6505426")]
public class Bitmap : Image
- Inheritance
-
Bitmap
- Derived
- Inherited Members
Constructors
Bitmap(RenderTarget, Surface)
Creates an Bitmap whose data is shared with another resource.
public Bitmap(RenderTarget renderTarget, Surface surface)
Parameters
renderTarget
RenderTargetan instance of RenderTarget
surface
SurfaceAn SharpDX.DXGI.Surface that contains the data to share with the new ID2D1Bitmap. For more information, see the Remarks section.
Bitmap(RenderTarget, Surface, BitmapProperties?)
Creates an Bitmap whose data is shared with another resource.
public Bitmap(RenderTarget renderTarget, Surface surface, BitmapProperties? bitmapProperties)
Parameters
renderTarget
RenderTargetan instance of RenderTarget
surface
SurfaceAn SharpDX.DXGI.Surface that contains the data to share with the new ID2D1Bitmap. For more information, see the Remarks section.
bitmapProperties
BitmapProperties?The pixel format and DPI of the bitmap to create . The SharpDX.DXGI.Format portion of the pixel format must match the SharpDX.DXGI.Format of data or the method will fail, but the alpha modes don't have to match. To prevent a mismatch, you can pass NULL or the value obtained from the {{D2D1::PixelFormat}} helper function. The DPI settings do not have to match those of data. If both dpiX and dpiY are 0.0f, the default DPI, 96, is used.
Bitmap(RenderTarget, Bitmap)
Creates an Bitmap whose data is shared with another resource.
public Bitmap(RenderTarget renderTarget, Bitmap bitmap)
Parameters
renderTarget
RenderTargetan instance of RenderTarget
bitmap
BitmapAn Bitmap that contains the data to share with the new ID2D1Bitmap. For more information, see the Remarks section.
Bitmap(RenderTarget, Bitmap, BitmapProperties?)
Creates an Bitmap whose data is shared with another resource.
public Bitmap(RenderTarget renderTarget, Bitmap bitmap, BitmapProperties? bitmapProperties)
Parameters
renderTarget
RenderTargetan instance of RenderTarget
bitmap
BitmapAn Bitmap that contains the data to share with the new ID2D1Bitmap. For more information, see the Remarks section.
bitmapProperties
BitmapProperties?The pixel format and DPI of the bitmap to create . The SharpDX.DXGI.Format portion of the pixel format must match the SharpDX.DXGI.Format of data or the method will fail, but the alpha modes don't have to match. To prevent a mismatch, you can pass NULL or the value obtained from the {{D2D1::PixelFormat}} helper function. The DPI settings do not have to match those of data. If both dpiX and dpiY are 0.0f, the default DPI, 96, is used.
Bitmap(RenderTarget, Size2)
Creates a Direct2D bitmap from a pointer to in-memory source data.
public Bitmap(RenderTarget renderTarget, Size2 size)
Parameters
renderTarget
RenderTargetan instance of RenderTarget
size
Size2The dimension of the bitmap to create in pixels.
Bitmap(RenderTarget, Size2, DataPointer, int)
Creates a Direct2D bitmap from a pointer to in-memory source data.
public Bitmap(RenderTarget renderTarget, Size2 size, DataPointer dataPointer, int pitch)
Parameters
renderTarget
RenderTargetan instance of RenderTarget
size
Size2The dimension of the bitmap to create in pixels.
dataPointer
DataPointerA pointer to the memory location of the image data, or NULL to create an uninitialized bitmap.
pitch
intThe byte count of each scanline, which is equal to (the image width in pixels * the number of bytes per pixel) + memory padding. If srcData is NULL, this value is ignored. (Note that pitch is also sometimes called stride.)
Bitmap(RenderTarget, Size2, DataPointer, int, BitmapProperties)
Creates a Direct2D bitmap from a pointer to in-memory source data.
public Bitmap(RenderTarget renderTarget, Size2 size, DataPointer dataPointer, int pitch, BitmapProperties bitmapProperties)
Parameters
renderTarget
RenderTargetan instance of RenderTarget
size
Size2The dimension of the bitmap to create in pixels.
dataPointer
DataPointerA pointer to the memory location of the image data, or NULL to create an uninitialized bitmap.
pitch
intThe byte count of each scanline, which is equal to (the image width in pixels * the number of bytes per pixel) + memory padding. If srcData is NULL, this value is ignored. (Note that pitch is also sometimes called stride.)
bitmapProperties
BitmapPropertiesThe pixel format and dots per inch (DPI) of the bitmap to create.
Bitmap(RenderTarget, Size2, BitmapProperties)
Creates a Direct2D bitmap from a pointer to in-memory source data.
public Bitmap(RenderTarget renderTarget, Size2 size, BitmapProperties bitmapProperties)
Parameters
renderTarget
RenderTargetan instance of RenderTarget
size
Size2The dimension of the bitmap to create in pixels.
bitmapProperties
BitmapPropertiesThe pixel format and dots per inch (DPI) of the bitmap to create.
Bitmap(RenderTarget, BitmapLock)
Creates an Bitmap that points to the bitmap data already stored in the BitmapLock.
public Bitmap(RenderTarget renderTarget, BitmapLock bitmapLock)
Parameters
renderTarget
RenderTargetAn instance of RenderTarget.
bitmapLock
BitmapLockAn RenderTarget that contains the data to share with the new Bitmap.
Bitmap(RenderTarget, BitmapLock, BitmapProperties?)
Creates an Bitmap that points to the bitmap data already stored in the BitmapLock.
public Bitmap(RenderTarget renderTarget, BitmapLock bitmapLock, BitmapProperties? bitmapProperties)
Parameters
renderTarget
RenderTargetAn instance of RenderTarget.
bitmapLock
BitmapLockAn RenderTarget that contains the data to share with the new Bitmap.
bitmapProperties
BitmapProperties?The pixel format and DPI of the bitmap to create . The SharpDX.DXGI.Format portion of the pixel format must match the SharpDX.DXGI.Format of data or the method will fail, but the alpha modes don't have to match. To prevent a mismatch, you can pass NULL or the value obtained from the {{D2D1::PixelFormat}} helper function. The DPI settings do not have to match those of data. If both dpiX and dpiY are 0.0f, the default DPI, 96, is used.
Bitmap(nint)
public Bitmap(nint nativePtr)
Parameters
nativePtr
nint
Properties
DotsPerInch
Return the dots per inch (DPI) of the bitmap.
public Size2F DotsPerInch { get; }
Property Value
- Size2F
The dots per inch (DPI) of the bitmap.
PixelFormat
Retrieves the pixel format and alpha mode of the bitmap.
public PixelFormat PixelFormat { get; }
Property Value
PixelSize
Returns the size, in device-dependent units (pixels), of the bitmap.
public Size2 PixelSize { get; }
Property Value
- Size2
Size
Returns the size, in device-independent pixels (DIPs), of the bitmap.
public Size2F Size { get; }
Property Value
- Size2F
Remarks
A DIP is 1/96?of an inch. To retrieve the size in device pixels, use the ID2D1Bitmap::GetPixelSize method.
Methods
CopyFromBitmap(Bitmap)
Copies the specified region from the specified bitmap into the current bitmap.
public void CopyFromBitmap(Bitmap sourceBitmap)
Parameters
sourceBitmap
BitmapThe bitmap to copy from.
Remarks
This method does not update the size of the current bitmap. If the contents of the source bitmap do not fit in the current bitmap, this method fails. Also, note that this method does not perform format conversion, and will fail if the bitmap formats do not match. Calling this method may cause the current batch to flush if the bitmap is active in the batch. If the batch that was flushed does not complete successfully, this method fails. However, this method does not clear the error state of the render target on which the batch was flushed. The failing int and tag state will be returned at the next call to {{EndDraw}} or {{Flush}}.
CopyFromBitmap(Bitmap, RawPoint)
Copies the specified region from the specified bitmap into the current bitmap.
public void CopyFromBitmap(Bitmap sourceBitmap, RawPoint destinationPoint)
Parameters
sourceBitmap
BitmapThe bitmap to copy from.
destinationPoint
RawPointIn the current bitmap, the upper-left corner of the area to which the region specified by srcRect is copied.
Remarks
This method does not update the size of the current bitmap. If the contents of the source bitmap do not fit in the current bitmap, this method fails. Also, note that this method does not perform format conversion, and will fail if the bitmap formats do not match. Calling this method may cause the current batch to flush if the bitmap is active in the batch. If the batch that was flushed does not complete successfully, this method fails. However, this method does not clear the error state of the render target on which the batch was flushed. The failing int and tag state will be returned at the next call to {{EndDraw}} or {{Flush}}.
CopyFromBitmap(Bitmap, RawPoint, RawRectangle)
Copies the specified region from the specified bitmap into the current bitmap.
public void CopyFromBitmap(Bitmap sourceBitmap, RawPoint destinationPoint, RawRectangle sourceArea)
Parameters
sourceBitmap
BitmapThe bitmap to copy from.
destinationPoint
RawPointIn the current bitmap, the upper-left corner of the area to which the region specified by srcRect is copied.
sourceArea
RawRectangleThe area of bitmap to copy.
Remarks
This method does not update the size of the current bitmap. If the contents of the source bitmap do not fit in the current bitmap, this method fails. Also, note that this method does not perform format conversion, and will fail if the bitmap formats do not match. Calling this method may cause the current batch to flush if the bitmap is active in the batch. If the batch that was flushed does not complete successfully, this method fails. However, this method does not clear the error state of the render target on which the batch was flushed. The failing int and tag state will be returned at the next call to {{EndDraw}} or {{Flush}}.
CopyFromMemory(byte[], int)
Copies the specified region from memory into the current bitmap.
public void CopyFromMemory(byte[] memory, int pitch)
Parameters
memory
byte[]The data to copy.
pitch
intThe stride, or pitch, of the source bitmap stored in srcData. The stride is the byte count of a scanline (one row of pixels in memory). The stride can be computed from the following formula: pixel width * bytes per pixel + memory padding.
Remarks
This method does not update the size of the current bitmap. If the contents of the source bitmap do not fit in the current bitmap, this method fails. Also, note that this method does not perform format conversion; the two bitmap formats should match. Passing this method invalid input, such as an invalid destination rectangle, can produce unpredictable results, such as a distorted image or device failure. Calling this method may cause the current batch to flush if the bitmap is active in the batch. If the batch that was flushed does not complete successfully, this method fails. However, this method does not clear the error state of the render target on which the batch was flushed. The failing int and tag state will be returned at the next call to {{EndDraw}} or {{Flush}}.
CopyFromMemory(byte[], int, RawRectangle)
Copies the specified region from memory into the current bitmap.
public void CopyFromMemory(byte[] memory, int pitch, RawRectangle destinationArea)
Parameters
memory
byte[]The data to copy.
pitch
intThe stride, or pitch, of the source bitmap stored in srcData. The stride is the byte count of a scanline (one row of pixels in memory). The stride can be computed from the following formula: pixel width * bytes per pixel + memory padding.
destinationArea
RawRectangleIn the current bitmap, the upper-left corner of the area to which the region specified by srcRect is copied.
Remarks
This method does not update the size of the current bitmap. If the contents of the source bitmap do not fit in the current bitmap, this method fails. Also, note that this method does not perform format conversion; the two bitmap formats should match. Passing this method invalid input, such as an invalid destination rectangle, can produce unpredictable results, such as a distorted image or device failure. Calling this method may cause the current batch to flush if the bitmap is active in the batch. If the batch that was flushed does not complete successfully, this method fails. However, this method does not clear the error state of the render target on which the batch was flushed. The failing int and tag state will be returned at the next call to {{EndDraw}} or {{Flush}}.
CopyFromMemory(nint, int)
Copies the specified region from memory into the current bitmap.
public void CopyFromMemory(nint pointer, int pitch)
Parameters
pointer
nintThe data to copy.
pitch
intThe stride, or pitch, of the source bitmap stored in srcData. The stride is the byte count of a scanline (one row of pixels in memory). The stride can be computed from the following formula: pixel width * bytes per pixel + memory padding.
Remarks
This method does not update the size of the current bitmap. If the contents of the source bitmap do not fit in the current bitmap, this method fails. Also, note that this method does not perform format conversion; the two bitmap formats should match. Passing this method invalid input, such as an invalid destination rectangle, can produce unpredictable results, such as a distorted image or device failure. Calling this method may cause the current batch to flush if the bitmap is active in the batch. If the batch that was flushed does not complete successfully, this method fails. However, this method does not clear the error state of the render target on which the batch was flushed. The failing int and tag state will be returned at the next call to {{EndDraw}} or {{Flush}}.
CopyFromMemory(nint, int, RawRectangle)
Copies the specified region from memory into the current bitmap.
public void CopyFromMemory(nint pointer, int pitch, RawRectangle destinationArea)
Parameters
pointer
nintThe data to copy.
pitch
intThe stride, or pitch, of the source bitmap stored in srcData. The stride is the byte count of a scanline (one row of pixels in memory). The stride can be computed from the following formula: pixel width * bytes per pixel + memory padding.
destinationArea
RawRectangleIn the current bitmap, the upper-left corner of the area to which the region specified by srcRect is copied.
Remarks
This method does not update the size of the current bitmap. If the contents of the source bitmap do not fit in the current bitmap, this method fails. Also, note that this method does not perform format conversion; the two bitmap formats should match. Passing this method invalid input, such as an invalid destination rectangle, can produce unpredictable results, such as a distorted image or device failure. Calling this method may cause the current batch to flush if the bitmap is active in the batch. If the batch that was flushed does not complete successfully, this method fails. However, this method does not clear the error state of the render target on which the batch was flushed. The failing int and tag state will be returned at the next call to {{EndDraw}} or {{Flush}}.
CopyFromMemory<T>(T[], int)
Copies the specified region from memory into the current bitmap.
public void CopyFromMemory<T>(T[] memory, int pitch = 0) where T : struct
Parameters
memory
T[]The data to copy.
pitch
intThe stride, or pitch, of the source bitmap stored in srcData. The stride is the byte count of a scanline (one row of pixels in memory). The stride can be computed from the following formula: pixel width * bytes per pixel + memory padding.
Type Parameters
T
Remarks
This method does not update the size of the current bitmap. If the contents of the source bitmap do not fit in the current bitmap, this method fails. Also, note that this method does not perform format conversion; the two bitmap formats should match. Passing this method invalid input, such as an invalid destination rectangle, can produce unpredictable results, such as a distorted image or device failure. Calling this method may cause the current batch to flush if the bitmap is active in the batch. If the batch that was flushed does not complete successfully, this method fails. However, this method does not clear the error state of the render target on which the batch was flushed. The failing int and tag state will be returned at the next call to {{EndDraw}} or {{Flush}}.
CopyFromMemory<T>(T[], int, RawRectangle)
Copies the specified region from memory into the current bitmap.
public void CopyFromMemory<T>(T[] memory, int pitch, RawRectangle destinationArea) where T : struct
Parameters
memory
T[]The data to copy.
pitch
intThe stride, or pitch, of the source bitmap stored in srcData. The stride is the byte count of a scanline (one row of pixels in memory). The stride can be computed from the following formula: pixel width * bytes per pixel + memory padding.
destinationArea
RawRectangleIn the current bitmap, the upper-left corner of the area to which the region specified by srcRect is copied.
Type Parameters
T
Remarks
This method does not update the size of the current bitmap. If the contents of the source bitmap do not fit in the current bitmap, this method fails. Also, note that this method does not perform format conversion; the two bitmap formats should match. Passing this method invalid input, such as an invalid destination rectangle, can produce unpredictable results, such as a distorted image or device failure. Calling this method may cause the current batch to flush if the bitmap is active in the batch. If the batch that was flushed does not complete successfully, this method fails. However, this method does not clear the error state of the render target on which the batch was flushed. The failing int and tag state will be returned at the next call to {{EndDraw}} or {{Flush}}.
CopyFromRenderTarget(RenderTarget)
Copies the specified region from the specified render target into the current bitmap.
public void CopyFromRenderTarget(RenderTarget renderTarget)
Parameters
renderTarget
RenderTargetThe render target that contains the region to copy.
Remarks
This method does not update the size of the current bitmap. If the contents of the source bitmap do not fit in the current bitmap, this method fails. Also, note that this method does not perform format conversion, and will fail if the bitmap formats do not match. Calling this method may cause the current batch to flush if the bitmap is active in the batch. If the batch that was flushed does not complete successfully, this method fails. However, this method does not clear the error state of the render target on which the batch was flushed. The failing int and tag state will be returned at the next call to {{EndDraw}} or {{Flush}}. All clips and layers must be popped off of the render target before calling this method. The method returns {{D2DERR_RENDER_TARGET_HAS_LAYER_OR_CLIPRECT}} if any clips or layers are currently applied to the render target.
CopyFromRenderTarget(RenderTarget, RawPoint)
Copies the specified region from the specified render target into the current bitmap.
public void CopyFromRenderTarget(RenderTarget renderTarget, RawPoint destinationPoint)
Parameters
renderTarget
RenderTargetThe render target that contains the region to copy.
destinationPoint
RawPointIn the current bitmap, the upper-left corner of the area to which the region specified by srcRect is copied.
Remarks
This method does not update the size of the current bitmap. If the contents of the source bitmap do not fit in the current bitmap, this method fails. Also, note that this method does not perform format conversion, and will fail if the bitmap formats do not match. Calling this method may cause the current batch to flush if the bitmap is active in the batch. If the batch that was flushed does not complete successfully, this method fails. However, this method does not clear the error state of the render target on which the batch was flushed. The failing int and tag state will be returned at the next call to {{EndDraw}} or {{Flush}}. All clips and layers must be popped off of the render target before calling this method. The method returns {{D2DERR_RENDER_TARGET_HAS_LAYER_OR_CLIPRECT}} if any clips or layers are currently applied to the render target.
CopyFromRenderTarget(RenderTarget, RawPoint, RawRectangle)
Copies the specified region from the specified render target into the current bitmap.
public void CopyFromRenderTarget(RenderTarget renderTarget, RawPoint destinationPoint, RawRectangle sourceArea)
Parameters
renderTarget
RenderTargetThe render target that contains the region to copy.
destinationPoint
RawPointIn the current bitmap, the upper-left corner of the area to which the region specified by srcRect is copied.
sourceArea
RawRectangleThe area of renderTarget to copy.
Remarks
This method does not update the size of the current bitmap. If the contents of the source bitmap do not fit in the current bitmap, this method fails. Also, note that this method does not perform format conversion, and will fail if the bitmap formats do not match. Calling this method may cause the current batch to flush if the bitmap is active in the batch. If the batch that was flushed does not complete successfully, this method fails. However, this method does not clear the error state of the render target on which the batch was flushed. The failing int and tag state will be returned at the next call to {{EndDraw}} or {{Flush}}. All clips and layers must be popped off of the render target before calling this method. The method returns {{D2DERR_RENDER_TARGET_HAS_LAYER_OR_CLIPRECT}} if any clips or layers are currently applied to the render target.
CopyFromStream(Stream, int, int)
Copies the specified region from a stream into the current bitmap.
public void CopyFromStream(Stream stream, int pitch, int length)
Parameters
stream
StreamThe stream to copy the data from.
pitch
intThe stride, or pitch, of the source bitmap stored in srcData. The stride is the byte count of a scanline (one row of pixels in memory). The stride can be computed from the following formula: pixel width * bytes per pixel + memory padding.
length
intLength in bytes of the data to copy from the stream.
Remarks
This method does not update the size of the current bitmap. If the contents of the source bitmap do not fit in the current bitmap, this method fails. Also, note that this method does not perform format conversion; the two bitmap formats should match. Passing this method invalid input, such as an invalid destination rectangle, can produce unpredictable results, such as a distorted image or device failure. Calling this method may cause the current batch to flush if the bitmap is active in the batch. If the batch that was flushed does not complete successfully, this method fails. However, this method does not clear the error state of the render target on which the batch was flushed. The failing int and tag state will be returned at the next call to {{EndDraw}} or {{Flush}}.
CopyFromStream(Stream, int, int, RawRectangle)
Copies the specified region from a stream into the current bitmap.
public void CopyFromStream(Stream stream, int pitch, int length, RawRectangle destinationArea)
Parameters
stream
StreamThe stream to copy the data from.
pitch
intThe stride, or pitch, of the source bitmap stored in srcData. The stride is the byte count of a scanline (one row of pixels in memory). The stride can be computed from the following formula: pixel width * bytes per pixel + memory padding.
length
intLength in bytes of the data to copy from the stream.
destinationArea
RawRectangleIn the current bitmap, the upper-left corner of the area to which the region specified by srcRect is copied.
Remarks
This method does not update the size of the current bitmap. If the contents of the source bitmap do not fit in the current bitmap, this method fails. Also, note that this method does not perform format conversion; the two bitmap formats should match. Passing this method invalid input, such as an invalid destination rectangle, can produce unpredictable results, such as a distorted image or device failure. Calling this method may cause the current batch to flush if the bitmap is active in the batch. If the batch that was flushed does not complete successfully, this method fails. However, this method does not clear the error state of the render target on which the batch was flushed. The failing int and tag state will be returned at the next call to {{EndDraw}} or {{Flush}}.
FromWicBitmap(RenderTarget, BitmapSource)
Creates a Bitmap from a WIC bitmap.
public static Bitmap FromWicBitmap(RenderTarget renderTarget, BitmapSource wicBitmapSource)
Parameters
renderTarget
RenderTargetThe render target.
wicBitmapSource
BitmapSourceA reference to a BitmapSource WIC bitmap.
Returns
FromWicBitmap(RenderTarget, BitmapSource, BitmapProperties)
Creates a Bitmap from a WIC bitmap.
public static Bitmap FromWicBitmap(RenderTarget renderTarget, BitmapSource wicBitmap, BitmapProperties bitmapProperties)
Parameters
renderTarget
RenderTargetThe render target.
wicBitmap
BitmapSourceThe WIC bitmap.
bitmapProperties
BitmapPropertiesThe bitmap properties.
Returns
New<T>(RenderTarget, Size2, T[], BitmapProperties)
Creates a Direct2D bitmap from a pointer to in-memory source data.
public static Bitmap New<T>(RenderTarget renderTarget, Size2 size, T[] pixelDatas, BitmapProperties bitmapProperties) where T : struct
Parameters
renderTarget
RenderTargetan instance of RenderTarget
size
Size2The dimension of the bitmap to create in pixels.
pixelDatas
T[]A pointer to an array of pixel data. The size of the array must be equal to sizeof(pixel) * Size.Width * Height.
bitmapProperties
BitmapPropertiesThe pixel format and dots per inch (DPI) of the bitmap to create.
Returns
Type Parameters
T
Operators
explicit operator Bitmap(nint)
public static explicit operator Bitmap(nint nativePtr)
Parameters
nativePtr
nint