I want to be able to set the error correction level of a QR by passing a param to the writer, as it permits. I have no need to know precisely what these values are, so it makes sense to pick a constant to say it for me, and I have seen some code in this repo that does exactly that, for example:
However this no longer works because those constants are protected and thus can't be accessed from outside. The only option available is via the forBits() method – but in order to use that I need to know the bit numbers the levels correspond to, which makes no sense to me! So to get H level, I have to say:
$writer->writeFile('hello', "code.png", Encoder::DEFAULT_BYTE_MODE_ECODING, ErrorCorrectionLevel::forBits(2));
// or
$writer->writeFile('hello', "code.png", Encoder::DEFAULT_BYTE_MODE_ECODING, 0x02);
It's doubly confusing because the levels are not in any guessable order. Is this a mistake, or should I specify the correction level in some other way?
I want to be able to set the error correction level of a QR by passing a param to the writer, as it permits. I have no need to know precisely what these values are, so it makes sense to pick a constant to say it for me, and I have seen some code in this repo that does exactly that, for example:
However this no longer works because those constants are protected and thus can't be accessed from outside. The only option available is via the
forBits()
method – but in order to use that I need to know the bit numbers the levels correspond to, which makes no sense to me! So to getH
level, I have to say:It's doubly confusing because the levels are not in any guessable order. Is this a mistake, or should I specify the correction level in some other way?