Class BitmapSource
[Guid("00000120-a8f2-4877-ba0a-fd2b6645fb94")]
public class BitmapSource : ComObject
- Inheritance
-
BitmapSource
- Derived
Constructors
BitmapSource(nint)
public BitmapSource(nint nativePtr)
Parameters
nativePtr
nint
Properties
PixelFormat
Retrieves the pixel format of the bitmap source..
public Guid PixelFormat { get; }
Property Value
Remarks
The pixel format returned by this method is not necessarily the pixel format the image is stored as. The codec may perform a format conversion from the storage pixel format to an output pixel format.
Size
Retrieves the pixel width and height of the bitmap.
public Size2 Size { get; }
Property Value
- Size2
Methods
CopyPalette(Palette)
Retrieves the color table for indexed pixel formats.
public void CopyPalette(Palette paletteRef)
Parameters
Remarks
If the BitmapSource is an BitmapFrameDecode, the function may return the image's global palette if a frame-level palette is not available. The global palette may also be retrieved using the CopyPalette method.
CopyPixels(RawBox, int, DataPointer)
Instructs the object to produce pixels.
public void CopyPixels(RawBox rectangle, int stride, DataPointer dataPointer)
Parameters
rectangle
RawBoxThe rectangle to copy. A
null
value specifies the entire bitmap.stride
intThe stride of the bitmap
dataPointer
DataPointerA reference to the buffer.
Remarks
CopyPixels is one of the two main image processing routines (the other being Lock) triggering the actual processing. It instructs the object to produce pixels according to its algorithm - this may involve decoding a portion of a JPEG stored on disk, copying a block of memory, or even analytically computing a complex gradient. The algorithm is completely dependent on the object implementing the interface.
The caller can restrict the operation to a rectangle of interest (ROI) using the prc parameter. The ROI sub-rectangle must be fully contained in the bounds of the bitmap. Specifying a null
ROI implies that the whole bitmap should be returned.
The caller controls the memory management and must provide an output buffer (pbBuffer) for the results of the copy along with the buffer's bounds (cbBufferSize). The cbStride parameter defines the count of bytes between two vertically adjacent pixels in the output buffer. The caller must ensure that there is sufficient buffer to complete the call based on the width, height and pixel format of the bitmap and the sub-rectangle provided to the copy method.
If the caller needs to perform numerous copies of an expensive BitmapSource such as a JPEG, it is recommended to create an in-memory Bitmap first.
Codec Developer RemarksThe callee must only write to the first (prc->Width*bitsperpixel+7)/8 bytes of each line of the output buffer (in this case, a line is a consecutive string of cbStride bytes).
CopyPixels(RawRectangle, byte[], int)
Instructs the object to produce pixels.
public void CopyPixels(RawRectangle rectangle, byte[] output, int stride)
Parameters
rectangle
RawRectangleoutput
byte[]The destination array. The size of the array must be sizeof(pixel) * Width * Height
stride
intThe stride (number of bytes per row).
Remarks
CopyPixels is one of the two main image processing routines (the other being Lock) triggering the actual processing. It instructs the object to produce pixels according to its algorithm - this may involve decoding a portion of a JPEG stored on disk, copying a block of memory, or even analytically computing a complex gradient. The algorithm is completely dependent on the object implementing the interface.
The caller can restrict the operation to a rectangle of interest (ROI) using the prc parameter. The ROI sub-rectangle must be fully contained in the bounds of the bitmap. Specifying a null
ROI implies that the whole bitmap should be returned.
The caller controls the memory management and must provide an output buffer (pbBuffer) for the results of the copy along with the buffer's bounds (cbBufferSize). The cbStride parameter defines the count of bytes between two vertically adjacent pixels in the output buffer. The caller must ensure that there is sufficient buffer to complete the call based on the width, height and pixel format of the bitmap and the sub-rectangle provided to the copy method.
If the caller needs to perform numerous copies of an expensive BitmapSource such as a JPEG, it is recommended to create an in-memory Bitmap first.
Codec Developer RemarksThe callee must only write to the first (prc->Width*bitsperpixel+7)/8 bytes of each line of the output buffer (in this case, a line is a consecutive string of cbStride bytes).
Exceptions
- ArgumentException
output.Length must be equal to Width * Height
CopyPixels(byte[], int)
Instructs the object to produce pixels.
public void CopyPixels(byte[] output, int stride)
Parameters
output
byte[]The destination array. The size of the array must be sizeof(pixel) * Width * Height
stride
intThe stride (number of bytes per row).
Remarks
CopyPixels is one of the two main image processing routines (the other being Lock) triggering the actual processing. It instructs the object to produce pixels according to its algorithm - this may involve decoding a portion of a JPEG stored on disk, copying a block of memory, or even analytically computing a complex gradient. The algorithm is completely dependent on the object implementing the interface.
The caller can restrict the operation to a rectangle of interest (ROI) using the prc parameter. The ROI sub-rectangle must be fully contained in the bounds of the bitmap. Specifying a null
ROI implies that the whole bitmap should be returned.
The caller controls the memory management and must provide an output buffer (pbBuffer) for the results of the copy along with the buffer's bounds (cbBufferSize). The cbStride parameter defines the count of bytes between two vertically adjacent pixels in the output buffer. The caller must ensure that there is sufficient buffer to complete the call based on the width, height and pixel format of the bitmap and the sub-rectangle provided to the copy method.
If the caller needs to perform numerous copies of an expensive BitmapSource such as a JPEG, it is recommended to create an in-memory Bitmap first.
Codec Developer RemarksThe callee must only write to the first (prc->Width*bitsperpixel+7)/8 bytes of each line of the output buffer (in this case, a line is a consecutive string of cbStride bytes).
Exceptions
- ArgumentException
output.Length must be equal to Width * Height
CopyPixels(int, DataPointer)
Instructs the object to produce pixels.
public void CopyPixels(int stride, DataPointer dataPointer)
Parameters
stride
intThe stride of the bitmap
dataPointer
DataPointerA reference to the buffer.
Remarks
CopyPixels is one of the two main image processing routines (the other being Lock) triggering the actual processing. It instructs the object to produce pixels according to its algorithm - this may involve decoding a portion of a JPEG stored on disk, copying a block of memory, or even analytically computing a complex gradient. The algorithm is completely dependent on the object implementing the interface.
The caller can restrict the operation to a rectangle of interest (ROI) using the prc parameter. The ROI sub-rectangle must be fully contained in the bounds of the bitmap. Specifying a null
ROI implies that the whole bitmap should be returned.
The caller controls the memory management and must provide an output buffer (pbBuffer) for the results of the copy along with the buffer's bounds (cbBufferSize). The cbStride parameter defines the count of bytes between two vertically adjacent pixels in the output buffer. The caller must ensure that there is sufficient buffer to complete the call based on the width, height and pixel format of the bitmap and the sub-rectangle provided to the copy method.
If the caller needs to perform numerous copies of an expensive BitmapSource such as a JPEG, it is recommended to create an in-memory Bitmap first.
Codec Developer RemarksThe callee must only write to the first (prc->Width*bitsperpixel+7)/8 bytes of each line of the output buffer (in this case, a line is a consecutive string of cbStride bytes).
CopyPixels(int, nint, int)
Instructs the object to produce pixels.
public void CopyPixels(int stride, nint dataPointer, int size)
Parameters
stride
intThe stride of the bitmap
dataPointer
nintA reference to the buffer.
size
intSize of the buffer in bytes.
Remarks
CopyPixels is one of the two main image processing routines (the other being Lock) triggering the actual processing. It instructs the object to produce pixels according to its algorithm - this may involve decoding a portion of a JPEG stored on disk, copying a block of memory, or even analytically computing a complex gradient. The algorithm is completely dependent on the object implementing the interface.
The caller can restrict the operation to a rectangle of interest (ROI) using the prc parameter. The ROI sub-rectangle must be fully contained in the bounds of the bitmap. Specifying a null
ROI implies that the whole bitmap should be returned.
The caller controls the memory management and must provide an output buffer (pbBuffer) for the results of the copy along with the buffer's bounds (cbBufferSize). The cbStride parameter defines the count of bytes between two vertically adjacent pixels in the output buffer. The caller must ensure that there is sufficient buffer to complete the call based on the width, height and pixel format of the bitmap and the sub-rectangle provided to the copy method.
If the caller needs to perform numerous copies of an expensive BitmapSource such as a JPEG, it is recommended to create an in-memory Bitmap first.
Codec Developer RemarksThe callee must only write to the first (prc->Width*bitsperpixel+7)/8 bytes of each line of the output buffer (in this case, a line is a consecutive string of cbStride bytes).
CopyPixels<T>(RawBox, T[])
Instructs the object to produce pixels.
public void CopyPixels<T>(RawBox rectangle, T[] output) where T : struct
Parameters
rectangle
RawBoxThe rectangle to copy. A
null
value specifies the entire bitmap.output
T[]The destination array. The size of the array must be sizeof(pixel) * rectangle.Width * rectangle.Height
Type Parameters
T
Type of a pixel. This parameter must exactly match a pixel like using
for a 32bit RGBA color or SharpDX.Mathematics.Interop.RawVector4 for a 64bits for a RGBA 4 floats color.
Remarks
CopyPixels is one of the two main image processing routines (the other being Lock) triggering the actual processing. It instructs the object to produce pixels according to its algorithm - this may involve decoding a portion of a JPEG stored on disk, copying a block of memory, or even analytically computing a complex gradient. The algorithm is completely dependent on the object implementing the interface.
The caller can restrict the operation to a rectangle of interest (ROI) using the prc parameter. The ROI sub-rectangle must be fully contained in the bounds of the bitmap. Specifying a null
ROI implies that the whole bitmap should be returned.
The caller controls the memory management and must provide an output buffer (pbBuffer) for the results of the copy along with the buffer's bounds (cbBufferSize). The cbStride parameter defines the count of bytes between two vertically adjacent pixels in the output buffer. The caller must ensure that there is sufficient buffer to complete the call based on the width, height and pixel format of the bitmap and the sub-rectangle provided to the copy method.
If the caller needs to perform numerous copies of an expensive BitmapSource such as a JPEG, it is recommended to create an in-memory Bitmap first.
Codec Developer RemarksThe callee must only write to the first (prc->Width*bitsperpixel+7)/8 bytes of each line of the output buffer (in this case, a line is a consecutive string of cbStride bytes).
Exceptions
- ArgumentException
output.Length must be equal to Width * Height
CopyPixels<T>(T[])
Instructs the object to produce pixels.
public void CopyPixels<T>(T[] output) where T : struct
Parameters
output
T[]The destination array. The size of the array must be sizeof(pixel) * Width * Height
Type Parameters
T
Type of a pixel. This parameter must exactly match a pixel like using
for a 32bit RGBA color or SharpDX.Mathematics.Interop.RawVector4 for a 64bits for a RGBA 4 floats color.
Remarks
CopyPixels is one of the two main image processing routines (the other being Lock) triggering the actual processing. It instructs the object to produce pixels according to its algorithm - this may involve decoding a portion of a JPEG stored on disk, copying a block of memory, or even analytically computing a complex gradient. The algorithm is completely dependent on the object implementing the interface.
The caller can restrict the operation to a rectangle of interest (ROI) using the prc parameter. The ROI sub-rectangle must be fully contained in the bounds of the bitmap. Specifying a null
ROI implies that the whole bitmap should be returned.
The caller controls the memory management and must provide an output buffer (pbBuffer) for the results of the copy along with the buffer's bounds (cbBufferSize). The cbStride parameter defines the count of bytes between two vertically adjacent pixels in the output buffer. The caller must ensure that there is sufficient buffer to complete the call based on the width, height and pixel format of the bitmap and the sub-rectangle provided to the copy method.
If the caller needs to perform numerous copies of an expensive BitmapSource such as a JPEG, it is recommended to create an in-memory Bitmap first.
Codec Developer RemarksThe callee must only write to the first (prc->Width*bitsperpixel+7)/8 bytes of each line of the output buffer (in this case, a line is a consecutive string of cbStride bytes).
GetResolution(out double, out double)
Retrieves the sampling rate between pixels and physical world measurements.
public void GetResolution(out double dpiXRef, out double dpiYRef)
Parameters
dpiXRef
doubleA reference that receives the x-axis dpi resolution.
dpiYRef
doubleA reference that receives the y-axis dpi resolution.
Remarks
Some formats, such as GIF and ICO, do not have full DPI support. For GIF, this method calculates the DPI values from the aspect ratio, using a base DPI of (96.0, 96.0). The ICO format does not support DPI at all, and the method always returns (96.0,96.0) for ICO images.
Additionally, WIC itself does not transform images based on the DPI values in an image. It is up to the caller to transform an image based on the resolution returned.
Operators
explicit operator BitmapSource(nint)
public static explicit operator BitmapSource(nint nativePtr)
Parameters
nativePtr
nint