public QRVersion(ErrorCorrectionInfo l, ErrorCorrectionInfo m, ErrorCorrectionInfo q, ErrorCorrectionInfo h) { Debug.Assert(l.TotalBytes == m.TotalBytes && l.TotalBytes == q.TotalBytes && l.TotalBytes == h.TotalBytes); L = l; M = m; Q = q; H = h; }
public QRVersion(ErrorCorrectionInfo l, ErrorCorrectionInfo m, ErrorCorrectionInfo q, ErrorCorrectionInfo h) { Debug.Assert(l.TotalBytes == m.TotalBytes && l.TotalBytes == q.TotalBytes && l.TotalBytes == h.TotalBytes); L = l; M = m; Q = q; H = h; }
internal static byte[] GetMessageSequence(byte[] input, ErrorCorrectionLevel desiredLevel, out int qrCodeVersion, out ErrorCorrectionLevel qrErrorCorrectionLevel) { // See ISO/IEC 18004:2006(E), Sec. 6.6 for information on generating the final message sequence ErrorCorrectionInfo correctionInfo = GetErrorCorrectionInfo(input.Length, desiredLevel, out qrCodeVersion, out qrErrorCorrectionLevel); byte[] extendedInput = new byte[correctionInfo.TotalDataBytes]; Buffer.BlockCopy(input, 0, extendedInput, 0, input.Length); // generate data and error blocks int bytesCopiedSoFar = 0; List <byte[]> dataBlocks = new List <byte[]>(); List <byte[]> errorBlocks = new List <byte[]>(); foreach (var blockCountInfo in correctionInfo.BlockCountInfos) { for (int i = 0; i < blockCountInfo.BlockCount; i++) { // create a data block byte[] thisDataBlock = new byte[blockCountInfo.BlockInfo.DataBytes]; Buffer.BlockCopy(extendedInput, bytesCopiedSoFar, thisDataBlock, 0, thisDataBlock.Length); dataBlocks.Add(thisDataBlock); bytesCopiedSoFar += thisDataBlock.Length; // create an error block byte[] thisErrorBlock = QRReedSolomon.GetErrorCorrectionBytes(thisDataBlock, blockCountInfo.BlockInfo.ErrorBytes); errorBlocks.Add(thisErrorBlock); } } // Assemble the final message sequence Debug.Assert(dataBlocks.Count == errorBlocks.Count); MemoryStream ms = new MemoryStream(correctionInfo.TotalDataBytes + correctionInfo.TotalErrorBytes); FlushBlocks(dataBlocks, ms); FlushBlocks(errorBlocks, ms); return(ms.ToArray()); }