Issue #1 - resolves error on encoding 14 character binary

Resolves other length issues, caused by generation of double the number
of codewords than expected when a qr version reaches its data capacity
This commit is contained in:
Steven Charles Davis 2014-01-17 12:00:02 -06:00
parent dbde75a3ae
commit b272cb7c5a

View File

@ -87,7 +87,7 @@ generate_ecc(<<>>, [], Acc) ->
generate_ecc0(Bin, Count, TotalLength, BlockLength, Acc) when byte_size(Bin) >= BlockLength, Count > 0 -> generate_ecc0(Bin, Count, TotalLength, BlockLength, Acc) when byte_size(Bin) >= BlockLength, Count > 0 ->
<<Block:BlockLength/binary, Bin0/binary>> = Bin, <<Block:BlockLength/binary, Bin0/binary>> = Bin,
EC = qrcode_reedsolomon:encode(Block, TotalLength - BlockLength), EC = qrcode_reedsolomon:encode(Block, TotalLength - BlockLength),
generate_ecc0(Bin0, Count, TotalLength, BlockLength, [{Block, EC}|Acc]); generate_ecc0(Bin0, Count - 1, TotalLength, BlockLength, [{Block, EC}|Acc]);
generate_ecc0(Bin, Count, TotalLength, BlockLength, Acc) when Count > 0 -> generate_ecc0(Bin, Count, TotalLength, BlockLength, Acc) when Count > 0 ->
Block = pad_block(Bin, BlockLength), Block = pad_block(Bin, BlockLength),
EC = qrcode_reedsolomon:encode(Block, TotalLength - BlockLength), EC = qrcode_reedsolomon:encode(Block, TotalLength - BlockLength),