Android Guides | Samples

Android.Graphics.Bitmap.CreateBitmap Method

Returns a immutable bitmap with the specified width and height, with each pixel value set to the corresponding value in the colors array.

Syntax

[Android.Runtime.Register("createBitmap", "(Landroid/util/DisplayMetrics;[IIIIILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;", "")]
public static Bitmap CreateBitmap (DisplayMetrics display, Int32[] colors, Int32 offset, Int32 stride, Int32 width, Int32 height, Bitmap+Config config)

Parameters

display
Display metrics for the display this bitmap will be drawn on.
colors
Array of _Color used to initialize the pixels.
offset
Number of values to skip before the first color in the array of colors.
stride
Number of colors in the array between rows (must be >= width or <= -width).
width
The width of the bitmap
height
The height of the bitmap
config
The bitmap config to create. If the config does not support per-pixel alpha (e.g. RGB_565), then the alpha bytes in the colors[] will be ignored (assumed to be FF)

Exceptions

TypeReason
IllegalArgumentExceptionif the width or height are <= 0, or if the color array's length is less than the number of pixels.

Remarks

Returns a immutable bitmap with the specified width and height, with each pixel value set to the corresponding value in the colors array. Its initial density is determined from the given DisplayMetrics.

[Android Documentation]

Requirements

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