SoftwareBitmap SoftwareBitmap SoftwareBitmap SoftwareBitmap Class

Definition

Represents an uncompressed bitmap.

public : sealed class SoftwareBitmap : IClosable, ISoftwareBitmappublic sealed class SoftwareBitmap : IDisposable, ISoftwareBitmapPublic NotInheritable Class SoftwareBitmap Implements IDisposable, ISoftwareBitmap// You can use this class in JavaScript.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

This class provides a representation of a bitmap that makes it easy to use with different imaging APIs. Use GetSoftwareBitmapAsync to create a SoftwareBitmap from a stream resource such as an image file. Use CopyToBuffer and CopyFromBuffer to copy pixel data back and forth between a SoftwareBitmap and the PixelBuffer of a WriteableBitmap. Use CreateCopyFromSurfaceAsync to create a SoftwareBitmap from a Direct3DSurface object.

Constructors

SoftwareBitmap(BitmapPixelFormat, Int32, Int32) SoftwareBitmap(BitmapPixelFormat, Int32, Int32) SoftwareBitmap(BitmapPixelFormat, Int32, Int32) SoftwareBitmap(BitmapPixelFormat, Int32, Int32)

Initializes a new instance of the SoftwareBitmap class.

public : SoftwareBitmap(BitmapPixelFormat format, int width, int height)public SoftwareBitmap(BitmapPixelFormat format, Int32 width, Int32 height)Public Sub New(format As BitmapPixelFormat, width As Int32, height As Int32)// You can use this method in JavaScript.
Parameters
format
BitmapPixelFormat BitmapPixelFormat BitmapPixelFormat BitmapPixelFormat

The pixel format of the new software bitmap.

width
int Int32 Int32 Int32

The width of the new software bitmap, in pixels.

height
int Int32 Int32 Int32

The height of the new software bitmap, in pixels.

See Also

SoftwareBitmap(BitmapPixelFormat, Int32, Int32, BitmapAlphaMode) SoftwareBitmap(BitmapPixelFormat, Int32, Int32, BitmapAlphaMode) SoftwareBitmap(BitmapPixelFormat, Int32, Int32, BitmapAlphaMode) SoftwareBitmap(BitmapPixelFormat, Int32, Int32, BitmapAlphaMode)

Initializes a new instance of the SoftwareBitmap class.

public : SoftwareBitmap(BitmapPixelFormat format, int width, int height, BitmapAlphaMode alpha)public SoftwareBitmap(BitmapPixelFormat format, Int32 width, Int32 height, BitmapAlphaMode alpha)Public Sub New(format As BitmapPixelFormat, width As Int32, height As Int32, alpha As BitmapAlphaMode)// You can use this method in JavaScript.
Parameters
format
BitmapPixelFormat BitmapPixelFormat BitmapPixelFormat BitmapPixelFormat

The pixel format of the new software bitmap.

width
int Int32 Int32 Int32

The width of the new software bitmap, in pixels.

height
int Int32 Int32 Int32

The height of the new software bitmap, in pixels.

alpha
BitmapAlphaMode BitmapAlphaMode BitmapAlphaMode BitmapAlphaMode

The alpha mode of the new software bitmap.

See Also

Properties

BitmapAlphaMode BitmapAlphaMode BitmapAlphaMode BitmapAlphaMode

Gets the alpha mode of the software bitmap.

public : BitmapAlphaMode BitmapAlphaMode { get; }public BitmapAlphaMode BitmapAlphaMode { get; }Public ReadOnly Property BitmapAlphaMode As BitmapAlphaMode// You can use this property in JavaScript.
Value
BitmapAlphaMode BitmapAlphaMode BitmapAlphaMode BitmapAlphaMode

The alpha mode of the software bitmap.

BitmapPixelFormat BitmapPixelFormat BitmapPixelFormat BitmapPixelFormat

Gets the pixel format of the software bitmap.

public : BitmapPixelFormat BitmapPixelFormat { get; }public BitmapPixelFormat BitmapPixelFormat { get; }Public ReadOnly Property BitmapPixelFormat As BitmapPixelFormat// You can use this property in JavaScript.
Value
BitmapPixelFormat BitmapPixelFormat BitmapPixelFormat BitmapPixelFormat

The pixel format of the software bitmap.

DpiX DpiX DpiX DpiX

Gets or sets the dots per inch of the software bitmap in the X direction.

public : double DpiX { get; set; }public double DpiX { get; set; }Public ReadWrite Property DpiX As double// You can use this property in JavaScript.
Value
double double double double

The dots per inch of the software bitmap in the X direction.

Remarks

DpiX and DpiY are metadata about the bitmap. Modifying these values does not scale the image.

DpiY DpiY DpiY DpiY

Gets or sets the dots per inch of the software bitmap in the Y direction.

public : double DpiY { get; set; }public double DpiY { get; set; }Public ReadWrite Property DpiY As double// You can use this property in JavaScript.
Value
double double double double

The dots per inch of the software bitmap in the Y direction.

IsReadOnly IsReadOnly IsReadOnly IsReadOnly

Gets a value indicating whether the software bitmap can be modified.

public : PlatForm::Boolean IsReadOnly { get; }public bool IsReadOnly { get; }Public ReadOnly Property IsReadOnly As bool// You can use this property in JavaScript.
Value
PlatForm::Boolean bool bool bool

True if the software bitmap is read-only; otherwise, false.

PixelHeight PixelHeight PixelHeight PixelHeight

Gets the height of the software bitmap, in pixels.

public : int PixelHeight { get; }public int PixelHeight { get; }Public ReadOnly Property PixelHeight As int// You can use this property in JavaScript.
Value
int int int int

The height of the software bitmap, in pixels.

PixelWidth PixelWidth PixelWidth PixelWidth

Gets the width of the software bitmap, in pixels.

public : int PixelWidth { get; }public int PixelWidth { get; }Public ReadOnly Property PixelWidth As int// You can use this property in JavaScript.
Value
int int int int

The width of the software bitmap, in pixels.

Methods

Close() Close() Close() Close()

Disposes of the object and associated resources.

public : void Close()This member is not implemented in C#This member is not implemented in VB.Net// You can use this method in JavaScript.

Convert(SoftwareBitmap, BitmapPixelFormat) Convert(SoftwareBitmap, BitmapPixelFormat) Convert(SoftwareBitmap, BitmapPixelFormat) Convert(SoftwareBitmap, BitmapPixelFormat)

Converts an existing SoftwareBitmap to a SoftwareBitmap with a different pixel format.

public : static SoftwareBitmap Convert(SoftwareBitmap source, BitmapPixelFormat format)public static SoftwareBitmap Convert(SoftwareBitmap source, BitmapPixelFormat format)Public Static Function Convert(source As SoftwareBitmap, format As BitmapPixelFormat) As SoftwareBitmap// You can use this method in JavaScript.
Parameters
source
SoftwareBitmap SoftwareBitmap SoftwareBitmap SoftwareBitmap

The software bitmap to convert.

format
BitmapPixelFormat BitmapPixelFormat BitmapPixelFormat BitmapPixelFormat

The pixel format of the new software bitmap.

Returns
See Also

Convert(SoftwareBitmap, BitmapPixelFormat, BitmapAlphaMode) Convert(SoftwareBitmap, BitmapPixelFormat, BitmapAlphaMode) Convert(SoftwareBitmap, BitmapPixelFormat, BitmapAlphaMode) Convert(SoftwareBitmap, BitmapPixelFormat, BitmapAlphaMode)

Converts an existing SoftwareBitmap to a SoftwareBitmap with a different pixel format or alpha mode.

public : static SoftwareBitmap Convert(SoftwareBitmap source, BitmapPixelFormat format, BitmapAlphaMode alpha)public static SoftwareBitmap Convert(SoftwareBitmap source, BitmapPixelFormat format, BitmapAlphaMode alpha)Public Static Function Convert(source As SoftwareBitmap, format As BitmapPixelFormat, alpha As BitmapAlphaMode) As SoftwareBitmap// You can use this method in JavaScript.
Parameters
source
SoftwareBitmap SoftwareBitmap SoftwareBitmap SoftwareBitmap

The software bitmap to convert.

format
BitmapPixelFormat BitmapPixelFormat BitmapPixelFormat BitmapPixelFormat

The pixel format of the new software bitmap.

alpha
BitmapAlphaMode BitmapAlphaMode BitmapAlphaMode BitmapAlphaMode

The alpha mode of the new software bitmap.

Returns
See Also

Copy(SoftwareBitmap) Copy(SoftwareBitmap) Copy(SoftwareBitmap) Copy(SoftwareBitmap)

Creates a copy of the provided SoftwareBitmap object.

public : static SoftwareBitmap Copy(SoftwareBitmap source)public static SoftwareBitmap Copy(SoftwareBitmap source)Public Static Function Copy(source As SoftwareBitmap) As SoftwareBitmap// You can use this method in JavaScript.
Parameters
source
SoftwareBitmap SoftwareBitmap SoftwareBitmap SoftwareBitmap

The software bitmap to copy.

Returns

The newly created copy of the software bitmap.

CopyFromBuffer(IBuffer) CopyFromBuffer(IBuffer) CopyFromBuffer(IBuffer) CopyFromBuffer(IBuffer)

Copies the pixel data from an IBuffer into the SoftwareBitmap.

public : void CopyFromBuffer(IBuffer buffer)public void CopyFromBuffer(IBuffer buffer)Public Function CopyFromBuffer(buffer As IBuffer) As void// You can use this method in JavaScript.
Parameters
buffer
IBuffer IBuffer IBuffer IBuffer

The buffer containing the pixel data to be copied.

Remarks

Use this method to copy data from the PixelBuffer of a WriteableBitmap into an existing SoftwareBitmap.

This method assumes that the input buffer has the same pixel format, width, height, color space, alpha mode, and DPI. It also assumes that the data in the buffer is contiguous, meaning that no IBuffer implicitly has the same format/width/height/color-space/alpha-mode/dpi. In other words, it expects that the stride of the image is equal to the width, with no additional padding.

CopyTo(SoftwareBitmap) CopyTo(SoftwareBitmap) CopyTo(SoftwareBitmap) CopyTo(SoftwareBitmap)

Copies the current SoftwareBitmap into the provided SoftwareBitmap object.

public : void CopyTo(SoftwareBitmap bitmap)public void CopyTo(SoftwareBitmap bitmap)Public Function CopyTo(bitmap As SoftwareBitmap) As void// You can use this method in JavaScript.
Parameters
bitmap
SoftwareBitmap SoftwareBitmap SoftwareBitmap SoftwareBitmap

The target software bitmap into which the data will be copied.

CopyToBuffer(IBuffer) CopyToBuffer(IBuffer) CopyToBuffer(IBuffer) CopyToBuffer(IBuffer)

Copies the software bitmap pixel data into the specified IBuffer.

public : void CopyToBuffer(IBuffer buffer)public void CopyToBuffer(IBuffer buffer)Public Function CopyToBuffer(buffer As IBuffer) As void// You can use this method in JavaScript.
Parameters
buffer
IBuffer IBuffer IBuffer IBuffer

The target buffer to which the pixel data will be copied.

Remarks

Use this method to copy pixel data from a SoftwareBitmap into the PixelBuffer of a WriteableBitmap.

CreateCopyFromBuffer(IBuffer, BitmapPixelFormat, Int32, Int32) CreateCopyFromBuffer(IBuffer, BitmapPixelFormat, Int32, Int32) CreateCopyFromBuffer(IBuffer, BitmapPixelFormat, Int32, Int32) CreateCopyFromBuffer(IBuffer, BitmapPixelFormat, Int32, Int32)

Creates a new SoftwareBitmap by performing a deep copy of the provided buffer. Modifications to the data in the new SoftwareBitmap will not effect the buffer from which it was created.

public : static SoftwareBitmap CreateCopyFromBuffer(IBuffer source, BitmapPixelFormat format, int width, int height)public static SoftwareBitmap CreateCopyFromBuffer(IBuffer source, BitmapPixelFormat format, Int32 width, Int32 height)Public Static Function CreateCopyFromBuffer(source As IBuffer, format As BitmapPixelFormat, width As Int32, height As Int32) As SoftwareBitmap// You can use this method in JavaScript.
Parameters
source
IBuffer IBuffer IBuffer IBuffer

The source buffer from which the copy will be created.

format
BitmapPixelFormat BitmapPixelFormat BitmapPixelFormat BitmapPixelFormat

The pixel format of the software bitmap.

width
int Int32 Int32 Int32

The width of the software bitmap, in pixels.

height
int Int32 Int32 Int32

The height of the software bitmap, in pixels.

Returns

Remarks

Use this method and its overloads to copy data from the PixelBuffer of a WriteableBitmap into an existing SoftwareBitmap.

See Also

CreateCopyFromBuffer(IBuffer, BitmapPixelFormat, Int32, Int32, BitmapAlphaMode) CreateCopyFromBuffer(IBuffer, BitmapPixelFormat, Int32, Int32, BitmapAlphaMode) CreateCopyFromBuffer(IBuffer, BitmapPixelFormat, Int32, Int32, BitmapAlphaMode) CreateCopyFromBuffer(IBuffer, BitmapPixelFormat, Int32, Int32, BitmapAlphaMode)

Creates a new SoftwareBitmap by performing a deep copy of the provided buffer. Modifications to the data in the new SoftwareBitmap will not effect the buffer from which it was created.

public : static SoftwareBitmap CreateCopyFromBuffer(IBuffer source, BitmapPixelFormat format, int width, int height, BitmapAlphaMode alpha)public static SoftwareBitmap CreateCopyFromBuffer(IBuffer source, BitmapPixelFormat format, Int32 width, Int32 height, BitmapAlphaMode alpha)Public Static Function CreateCopyFromBuffer(source As IBuffer, format As BitmapPixelFormat, width As Int32, height As Int32, alpha As BitmapAlphaMode) As SoftwareBitmap// You can use this method in JavaScript.
Parameters
source
IBuffer IBuffer IBuffer IBuffer

The source buffer from which the copy will be created.

format
BitmapPixelFormat BitmapPixelFormat BitmapPixelFormat BitmapPixelFormat

The pixel format of the software bitmap.

width
int Int32 Int32 Int32

The width of the software bitmap, in pixels.

height
int Int32 Int32 Int32

The height of the software bitmap, in pixels.

alpha
BitmapAlphaMode BitmapAlphaMode BitmapAlphaMode BitmapAlphaMode

The alpha mode of the software bitmap.

Returns
See Also

CreateCopyFromSurfaceAsync(IDirect3DSurface) CreateCopyFromSurfaceAsync(IDirect3DSurface) CreateCopyFromSurfaceAsync(IDirect3DSurface) CreateCopyFromSurfaceAsync(IDirect3DSurface)

Asynchronously creates a new SoftwareBitmap by performing a deep copy of the provided IDirect3DSurface. Modifications to the data in the new SoftwareBitmap will not effect the surface from which it was created.

public : static IAsyncOperation<SoftwareBitmap> CreateCopyFromSurfaceAsync(IDirect3DSurface surface)public static IAsyncOperation<SoftwareBitmap> CreateCopyFromSurfaceAsync(IDirect3DSurface surface)Public Static Function CreateCopyFromSurfaceAsync(surface As IDirect3DSurface) As IAsyncOperation( Of SoftwareBitmap )// You can use this method in JavaScript.
Parameters
surface
IDirect3DSurface IDirect3DSurface IDirect3DSurface IDirect3DSurface

The source surface from which the copy will be created.

Returns
See Also

CreateCopyFromSurfaceAsync(IDirect3DSurface, BitmapAlphaMode) CreateCopyFromSurfaceAsync(IDirect3DSurface, BitmapAlphaMode) CreateCopyFromSurfaceAsync(IDirect3DSurface, BitmapAlphaMode) CreateCopyFromSurfaceAsync(IDirect3DSurface, BitmapAlphaMode)

Asynchronously creates a new SoftwareBitmap by performing a deep copy of the provided IDirect3DSurface . Modifications to the data in the new SoftwareBitmap will not effect the surface from which it was created.

public : static IAsyncOperation<SoftwareBitmap> CreateCopyFromSurfaceAsync(IDirect3DSurface surface, BitmapAlphaMode alpha)public static IAsyncOperation<SoftwareBitmap> CreateCopyFromSurfaceAsync(IDirect3DSurface surface, BitmapAlphaMode alpha)Public Static Function CreateCopyFromSurfaceAsync(surface As IDirect3DSurface, alpha As BitmapAlphaMode) As IAsyncOperation( Of SoftwareBitmap )// You can use this method in JavaScript.
Parameters
surface
IDirect3DSurface IDirect3DSurface IDirect3DSurface IDirect3DSurface

The source surface from which the copy will be created.

alpha
BitmapAlphaMode BitmapAlphaMode BitmapAlphaMode BitmapAlphaMode

The alpha mode of the software bitmap.

Returns
See Also

Dispose() Dispose() Dispose() Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

This member is not implemented in C++void Dispose()Sub Disposevoid Dispose()

GetReadOnlyView() GetReadOnlyView() GetReadOnlyView() GetReadOnlyView()

Gets a read-only representation of the SoftwareBitmap object.

public : SoftwareBitmap GetReadOnlyView()public SoftwareBitmap GetReadOnlyView()Public Function GetReadOnlyView() As SoftwareBitmap// You can use this method in JavaScript.
Returns

A read-only representation of the SoftwareBitmap object.

Remarks

Determine if a software bitmap can be modified by checking the IsReadOnly property.

LockBuffer(BitmapBufferAccessMode) LockBuffer(BitmapBufferAccessMode) LockBuffer(BitmapBufferAccessMode) LockBuffer(BitmapBufferAccessMode)

Gets a BitmapBuffer object that allows you to operate directly on the software bitmap's pixel data.

public : BitmapBuffer LockBuffer(BitmapBufferAccessMode mode)public BitmapBuffer LockBuffer(BitmapBufferAccessMode mode)Public Function LockBuffer(mode As BitmapBufferAccessMode) As BitmapBuffer// You can use this method in JavaScript.
Parameters
mode
BitmapBufferAccessMode BitmapBufferAccessMode BitmapBufferAccessMode BitmapBufferAccessMode

A value indicating the access mode of the returned buffer.

Returns

The buffer containing pixel data.