shadows/framework/src/main/java/org/robolectric/shadows/ShadowBitmap.java
@Implementation
  protected void getPixels(
      int[] pixels, int offset, int stride, int x, int y, int width, int height) {
    if (x != 0 ||
        y != 0 ||
        width != getWidth() ||
        height != getHeight() ||
        pixels.length != colors.length) {
      for (int y0 = 0; y0 < height; y0++) {
        for (int x0 = 0; x0 < width; x0++) {
          pixels[offset + y0 * stride + x0] = colors[(y0 + y) * getWidth() + x0 + x];
        }
      }
    } else {
      System.arraycopy(colors, 0, pixels, 0, colors.length);
    }
  }
@Implementation
  protected void getPixels(
      int[] pixels, int offset, int stride, int x, int y, int width, int height) {
    if (x != 0 ||
        y != 0 ||
        width != getWidth() ||
        height != getHeight() ||
        pixels.length != colors.length) {
      for (int y0 = 0; y0 < height; y0++) {
        for (int x0 = 0; x0 < width; x0++) {
          pixels[offset + y0 * stride + x0] = colors[(y0 + y) * getWidth() + x0 + x];
        }
      }
    } else {
      System.arraycopy(colors, 0, pixels, 0, colors.length);
    }
  }
Note that this method will return a RuntimeException unless: - {@code pixels} has the same
length as the number of pixels of the bitmap. - {@code x = 0} - {@code y = 0} - {@code width}
and {@code height} height match the current bitmap's dimensions.