combine method

void combine(
  1. UJbig2Bitmap other,
  2. int x0,
  3. int y0,
  4. int operation,
)

Implementation

void combine(UJbig2Bitmap other, int x0, int y0, int operation) {
  for (int y = 0; y < other.height; y++) {
    final int targetY = y0 + y;
    if (targetY < 0 || targetY >= height) continue;
    for (int x = 0; x < other.width; x++) {
      final int targetX = x0 + x;
      if (targetX < 0 || targetX >= width) continue;
      final int source = other.data[y * other.width + x];
      final int index = targetY * width + targetX;
      switch (operation) {
        case 0:
          data[index] |= source;
          break;
        case 1:
          data[index] &= source;
          break;
        case 2:
          data[index] ^= source;
          break;
        case 3:
          data[index] = (~(data[index] ^ source)) & 1;
          break;
        default:
          data[index] = source;
          break;
      }
    }
  }
}