Пример #1
0
 public BitmapFilm(Bitmap bitmap, int width, int height) {
   this.bitmap = bitmap;
   int cols = bitmap.getWidth() / width;
   int rows = bitmap.getHeight() / height;
   for (int i = 0; i < rows; i++) {
     for (int j = 0; j < cols; j++) {
       Rect rect = new Rect(j * width, i * height, (j + 1) * width, (i + 1) * height);
       add(i * cols + j, rect);
     }
   }
 }
Пример #2
0
  public static int pick(int index, int x, int y) {
    Bitmap bmp = TextureCache.get(Assets.ITEMS).bitmap;
    int rows = bmp.getWidth() / SIZE;
    int row = index / rows;
    int col = index % rows;

    // FIXME: I'm assuming this is super slow?
    final TextureData td = bmp.getTextureData();
    if (!td.isPrepared()) {
      td.prepare();
    }
    final Pixmap pixmap = td.consumePixmap();
    int pixel = pixmap.getPixel(col * SIZE + x, row * SIZE + y);
    pixmap.dispose();
    return pixel;
  }
Пример #3
0
 public BitmapFilm(Bitmap bitmap, int width) {
   this(bitmap, width, bitmap.getHeight());
 }
Пример #4
0
 public BitmapFilm(Bitmap bitmap) {
   this.bitmap = bitmap;
   add(null, new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()));
 }