getRecommendedMinimumErrorCorrectionLevel static method

int getRecommendedMinimumErrorCorrectionLevel(
  1. int n
)

Returns the recommended minimum error correction level as described in annex E of ISO/IEC 15438:2001(E).

@param n the number of data codewords @return the recommended minimum error correction level

Implementation

static int getRecommendedMinimumErrorCorrectionLevel(int n) {
  if (n <= 0) {
    throw ArgumentError('n must be > 0');
  }
  if (n <= 40) {
    return 2;
  }
  if (n <= 160) {
    return 3;
  }
  if (n <= 320) {
    return 4;
  }
  if (n <= 863) {
    return 5;
  }
  throw WriterException('No recommendation possible');
}