Bitmap中setPiexls的解释:
public void setPixels (int[] pixels, int offset, int stride, int x, int y, int width, int height)
Since:
API Level 1
Replace pixels in the bitmap with the colors in the array. Each element in the array is a packed int prepresenting a Color
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 |
Throws
IllegalStateException | if the bitmap is not mutable |
---|---|
IllegalArgumentException | if x, y, width, height are outside of the bitmap's bounds. |
ArrayIndexOutOfBoundsException | if the pixels array is too small to receive the specified number of pixels. |
生成颜色值数组的函数: