decode method

UJbig2Bitmap decode(
  1. UJbig2ArithmeticDecoder decoder,
  2. Uint8List contexts
)

Implementation

UJbig2Bitmap decode(UJbig2ArithmeticDecoder decoder, Uint8List contexts) {
  final UJbig2Bitmap bitmap = UJbig2Bitmap(width, height);
  int ltp = 0;
  for (int y = 0; y < height; y++) {
    if (tpgdon) {
      final int context = _tpgdonContext();
      if (decoder.decode(contexts, context) == 1) ltp ^= 1;
      if (ltp == 1) {
        if (y > 0) {
          for (int x = 0; x < width; x++) {
            bitmap.set(x, y, bitmap.get(x, y - 1));
          }
        }
        continue;
      }
    }
    for (int x = 0; x < width; x++) {
      final int context = _contextAt(bitmap, x, y);
      bitmap.set(x, y, decoder.decode(contexts, context));
    }
  }
  return bitmap;
}