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", "([IIILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;", "")]
public static Bitmap CreateBitmap (Int32[] colors, Int32 width, Int32 height, Bitmap+Config config)

Parameters

colors
Array of _Color used to initialize the pixels. This array must be at least as large as width * height.
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 as per Bitmap.Density.

[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