[]
        
(Showing Draft Content)

GrapeCity.Documents.DX.Direct2D.Bitmap

Class Bitmap

Namespace
GrapeCity.Documents.DX.Direct2D
Assembly
GcDocs.DX.Windows.dll

ID2D1Bitmap

[Guid("a2296057-ea42-4099-983b-539fb6505426")]
public class Bitmap : Image, IDisposable, IUnknown
Inheritance
object
Bitmap
Implements
System.IDisposable
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()

Constructors

Bitmap(IntPtr)

Initializes a new instance of the Bitmap class.

public Bitmap(IntPtr nativePtr)

Parameters

nativePtr System.IntPtr

The native pointer.

Properties

DotsPerInch

Return the dots per inch (DPI) of the bitmap.

public Size2F DotsPerInch { get; }

Property Value

Size2F

Methods

CopyFromBitmap(Bitmap, RectL)

HRESULT ID2D1Bitmap::CopyFromBitmap([In, Optional] const D2D_POINT_2U* destPoint,[In] ID2D1Bitmap* bitmap,[In, Optional] const D2D_RECT_U* srcRect)

public void CopyFromBitmap(Bitmap bitmap, RectL srcRect)

Parameters

bitmap Bitmap
srcRect RectL

CopyFromBitmap(Bitmap)

HRESULT ID2D1Bitmap::CopyFromBitmap([In, Optional] const D2D_POINT_2U* destPoint,[In] ID2D1Bitmap* bitmap,[In, Optional] const D2D_RECT_U* srcRect)

public void CopyFromBitmap(Bitmap bitmap)

Parameters

bitmap Bitmap

CopyFromBitmap(Point2L, Bitmap, RectL)

HRESULT ID2D1Bitmap::CopyFromBitmap([In, Optional] const D2D_POINT_2U* destPoint,[In] ID2D1Bitmap* bitmap,[In, Optional] const D2D_RECT_U* srcRect)

public void CopyFromBitmap(Point2L destPoint, Bitmap bitmap, RectL srcRect)

Parameters

destPoint Point2L
bitmap Bitmap
srcRect RectL

CopyFromBitmap(Point2L, Bitmap)

HRESULT ID2D1Bitmap::CopyFromBitmap([In, Optional] const D2D_POINT_2U* destPoint,[In] ID2D1Bitmap* bitmap,[In, Optional] const D2D_RECT_U* srcRect)

public void CopyFromBitmap(Point2L destPoint, Bitmap bitmap)

Parameters

destPoint Point2L
bitmap Bitmap

CopyFromMemory(byte[], int, RectL)

Copies the specified region from memory into the current bitmap.

public void CopyFromMemory(byte[] memory, int pitch, RectL destinationArea)

Parameters

memory byte[]

The data to copy.

pitch int

The 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 RectL

In 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(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 int

The 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(IntPtr, int, RectL)

Copies the specified region from memory into the current bitmap.

public void CopyFromMemory(IntPtr pointer, int pitch, RectL destinationArea)

Parameters

pointer System.IntPtr

The data to copy.

pitch int

The 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 RectL

In 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(IntPtr, int)

Copies the specified region from memory into the current bitmap.

public void CopyFromMemory(IntPtr pointer, int pitch)

Parameters

pointer System.IntPtr

The data to copy.

pitch int

The 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(RectL?, IntPtr, int)

HRESULT ID2D1Bitmap::CopyFromMemory([In, Optional] const D2D_RECT_U* dstRect,[In] const void* srcData,[In] unsigned int pitch)

public void CopyFromMemory(RectL? dstRect, IntPtr srcData, int pitch)

Parameters

dstRect RectL?
srcData System.IntPtr
pitch int

CopyFromMemory<T>(T[], int, RectL)

Copies the specified region from memory into the current bitmap.

public void CopyFromMemory<T>(T[] memory, int pitch, RectL destinationArea) where T : struct

Parameters

memory T[]

The data to copy.

pitch int

The 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 RectL

In 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}}.

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 int

The 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}}.

CopyFromRenderTarget(RenderTarget, Point2L, RectL)

Copies the specified region from the specified render target into the current bitmap.

public void CopyFromRenderTarget(RenderTarget renderTarget, Point2L destinationPoint, RectL sourceArea)

Parameters

renderTarget RenderTarget

The render target that contains the region to copy.

destinationPoint Point2L

In the current bitmap, the upper-left corner of the area to which the region specified by srcRect is copied.

sourceArea RectL

The 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.

CopyFromRenderTarget(RenderTarget, Point2L)

Copies the specified region from the specified render target into the current bitmap.

public void CopyFromRenderTarget(RenderTarget renderTarget, Point2L destinationPoint)

Parameters

renderTarget RenderTarget

The render target that contains the region to copy.

destinationPoint Point2L

In 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)

Copies the specified region from the specified render target into the current bitmap.

public void CopyFromRenderTarget(RenderTarget renderTarget)

Parameters

renderTarget RenderTarget

The 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(Point2L?, RenderTarget, RectL?)

HRESULT ID2D1Bitmap::CopyFromRenderTarget([In, Optional] const D2D_POINT_2U* destPoint,[In] ID2D1RenderTarget* renderTarget,[In, Optional] const D2D_RECT_U* srcRect)

public void CopyFromRenderTarget(Point2L? destPoint, RenderTarget renderTarget, RectL? srcRect)

Parameters

destPoint Point2L?
renderTarget RenderTarget
srcRect RectL?

CopyFromStream(Stream, int, int, RectL)

Copies the specified region from a stream into the current bitmap.

public void CopyFromStream(Stream stream, int pitch, int length, RectL destinationArea)

Parameters

stream System.IO.Stream

The stream to copy the data from.

pitch int

The 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 int

Length in bytes of the data to copy from the stream.

destinationArea RectL

In 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}}.

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 System.IO.Stream

The stream to copy the data from.

pitch int

The 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 int

Length 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}}.

Create(RenderTarget, Bitmap, BitmapProperties?)

Creates an Bitmap whose data is shared with another resource.

public static Bitmap Create(RenderTarget renderTarget, Bitmap bitmap, BitmapProperties? bitmapProperties)

Parameters

renderTarget RenderTarget

an instance of RenderTarget

bitmap Bitmap

An 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 Format portion of the pixel format must match the 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.

Returns

Bitmap

Create(RenderTarget, Bitmap)

Creates an Bitmap whose data is shared with another resource.

public static Bitmap Create(RenderTarget renderTarget, Bitmap bitmap)

Parameters

renderTarget RenderTarget

an instance of RenderTarget

bitmap Bitmap

An Bitmap that contains the data to share with the new ID2D1Bitmap. For more information, see the Remarks section.

Returns

Bitmap

Create(RenderTarget, Surface, BitmapProperties?)

Creates an Bitmap whose data is shared with another resource.

public static Bitmap Create(RenderTarget renderTarget, Surface surface, BitmapProperties? bitmapProperties)

Parameters

renderTarget RenderTarget

an instance of RenderTarget

surface Surface

An 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 Format portion of the pixel format must match the 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.

Returns

Bitmap

Create(RenderTarget, Surface)

Creates an Bitmap whose data is shared with another resource.

public static Bitmap Create(RenderTarget renderTarget, Surface surface)

Parameters

renderTarget RenderTarget

an instance of RenderTarget

surface Surface

An Surface that contains the data to share with the new ID2D1Bitmap. For more information, see the Remarks section.

Returns

Bitmap

Create(RenderTarget, Size2L, DataPointer, int, BitmapProperties)

Creates a Direct2D bitmap from a pointer to in-memory source data.

public static Bitmap Create(RenderTarget renderTarget, Size2L size, DataPointer dataPointer, int pitch, BitmapProperties bitmapProperties)

Parameters

renderTarget RenderTarget

an instance of RenderTarget

size Size2L

The dimension of the bitmap to create in pixels.

dataPointer DataPointer

A pointer to the memory location of the image data, or NULL to create an uninitialized bitmap.

pitch int

The 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 BitmapProperties

The pixel format and dots per inch (DPI) of the bitmap to create.

Returns

Bitmap

Create(RenderTarget, Size2L, DataPointer, int)

Creates a Direct2D bitmap from a pointer to in-memory source data.

public static Bitmap Create(RenderTarget renderTarget, Size2L size, DataPointer dataPointer, int pitch)

Parameters

renderTarget RenderTarget

an instance of RenderTarget

size Size2L

The dimension of the bitmap to create in pixels.

dataPointer DataPointer

A pointer to the memory location of the image data, or NULL to create an uninitialized bitmap.

pitch int

The 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.)

Returns

Bitmap

Create(RenderTarget, Size2L, BitmapProperties)

Creates a Direct2D bitmap from a pointer to in-memory source data.

public static Bitmap Create(RenderTarget renderTarget, Size2L size, BitmapProperties bitmapProperties)

Parameters

renderTarget RenderTarget

an instance of RenderTarget

size Size2L

The dimension of the bitmap to create in pixels.

bitmapProperties BitmapProperties

The pixel format and dots per inch (DPI) of the bitmap to create.

Returns

Bitmap

Create(RenderTarget, Size2L)

Creates a Direct2D bitmap from a pointer to in-memory source data.

public static Bitmap Create(RenderTarget renderTarget, Size2L size)

Parameters

renderTarget RenderTarget

an instance of RenderTarget

size Size2L

The dimension of the bitmap to create in pixels.

Returns

Bitmap

Create(RenderTarget, BitmapLock, BitmapProperties?)

Creates an Bitmap that points to the bitmap data already stored in the BitmapLock.

public static Bitmap Create(RenderTarget renderTarget, BitmapLock bitmapLock, BitmapProperties? bitmapProperties)

Parameters

renderTarget RenderTarget

An instance of RenderTarget.

bitmapLock BitmapLock

An RenderTarget that contains the data to share with the new Bitmap.

bitmapProperties BitmapProperties?

The pixel format and DPI of the bitmap to create . The Format portion of the pixel format must match the 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.

Returns

Bitmap

Create(RenderTarget, BitmapSource, BitmapProperties)

Creates a Bitmap from a wic bitmap.

public static Bitmap Create(RenderTarget renderTarget, BitmapSource wicBitmap, BitmapProperties bitmapProperties)

Parameters

renderTarget RenderTarget

The render target.

wicBitmap BitmapSource

The wic bitmap.

bitmapProperties BitmapProperties

The bitmap properties.

Returns

Bitmap

Create(RenderTarget, BitmapSource)

Creates a Bitmap from a wic bitmap.

public static Bitmap Create(RenderTarget renderTarget, BitmapSource wicBitmapSource)

Parameters

renderTarget RenderTarget

The render target.

wicBitmapSource BitmapSource

A reference to a BitmapSource wic bitmap.

Returns

Bitmap

GetDpi(out float, out float)

void ID2D1Bitmap::GetDpi([Out] float* dpiX,[Out] float* dpiY)

public void GetDpi(out float dpiX, out float dpiY)

Parameters

dpiX float
dpiY float

GetPixelFormat()

D2D1_PIXEL_FORMAT ID2D1Bitmap::GetPixelFormat()

public PixelFormat GetPixelFormat()

Returns

PixelFormat

GetPixelSize()

D2D_SIZE_U ID2D1Bitmap::GetPixelSize()

public Size2L GetPixelSize()

Returns

Size2L

GetSize()

D2D_SIZE_F ID2D1Bitmap::GetSize()

public Size2F GetSize()

Returns

Size2F

New<T>(RenderTarget, Size2L, T[], BitmapProperties)

Creates a Direct2D bitmap from a pointer to in-memory source data.

public static Bitmap New<T>(RenderTarget renderTarget, Size2L size, T[] pixelDatas, BitmapProperties bitmapProperties) where T : struct

Parameters

renderTarget RenderTarget

an instance of RenderTarget

size Size2L

The 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 BitmapProperties

The pixel format and dots per inch (DPI) of the bitmap to create.

Returns

Bitmap

Type Parameters

T

Operators

explicit operator Bitmap(IntPtr)

Performs an explicit conversion from System.IntPtr to Bitmap.

public static explicit operator Bitmap(IntPtr nativePointer)

Parameters

nativePointer System.IntPtr

Returns

Bitmap