Android Guides | Samples

Android.Graphics.Bitmap.CreateBitmap Method

Returns an immutable bitmap from subset of the source bitmap, transformed by the optional matrix.

Syntax

[Android.Runtime.Register("createBitmap", "(Landroid/graphics/Bitmap;IIIILandroid/graphics/Matrix;Z)Landroid/graphics/Bitmap;", "")]
public static Bitmap CreateBitmap (Bitmap source, Int32 x, Int32 y, Int32 width, Int32 height, Matrix m, Boolean filter)

Parameters

source
The bitmap we are subsetting
x
The x coordinate of the first pixel in source
y
The y coordinate of the first pixel in source
width
The number of pixels in each row
height
The number of rows
m
Optional matrix to be applied to the pixels
filter
true if the source should be filtered. Only applies if the matrix contains more than just translation.

Exceptions

TypeReason
IllegalArgumentExceptionif the x, y, width, height values are outside of the dimensions of the source bitmap, or width is <= 0, or height is <= 0

Remarks

Returns an immutable bitmap from subset of the source bitmap, transformed by the optional matrix. The new bitmap may be the same object as source, or a copy may have been made. It is initialized with the same density as the original bitmap. If the source bitmap is immutable and the requested subset is the same as the source bitmap itself, then the source bitmap is returned and no new bitmap is created.

[Android Documentation]

Requirements

Namespace: Android.Graphics
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1