Android.Graphics.Bitmap.SetPixels Method

Syntax

[Android.Runtime.Register("setPixels", "([IIIIIII)V", "")]
public void SetPixels (int[] pixels, int offset, int stride, int x, int y, int width, int height)

Parameters

pixels
The colors to write to the bitmap
offset
The index of the first color to read from pixels[]
stride
The number of colors in pixels[] to skip between rows. Normally this value will be the same as the width of the bitmap, but it can be larger (or negative).
x
The x coordinate of the first pixel to write to in the bitmap.
y
The y coordinate of the first pixel to write to in the bitmap.
width
The number of colors to copy from pixels[] per row
height
The number of rows to write to the bitmap

Exceptions

TypeReason
Java.Lang.IllegalStateExceptionif the bitmap is not mutable
Java.Lang.IllegalArgumentExceptionif x, y, width, height are outside of the bitmap's bounds.
Java.Lang.ArrayIndexOutOfBoundsExceptionif the pixels array is too small to receive the specified number of pixels.

Remarks

Replace pixels in the bitmap with the colors in the array. Each element in the array is a packed int prepresenting a non-premultiplied ARGB Android.Graphics._Color.

[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