public void Write(QRBitBuffer buffer) { for (var i = 0; i < _data.Length; ++i) { //item buffer.Put(_data[i], 8); } ///buffer = Data; }
private DataCache CreateData(int typeNumber, QRErrorCorrectLevel errorCorrectLevel, List <QR8bitByte> dataList) { var rsBlocks = QRRSBlock.GetRSBlocks(typeNumber, errorCorrectLevel); var buffer = new QRBitBuffer(); for (var i = 0; i < dataList.Count; i++) { QR8bitByte data = dataList[i]; buffer.Put((int)data.Mode, 4); buffer.Put(data.Length, QRUtil.GetLengthInBits(data.Mode, typeNumber)); data.Write(buffer); } // calc num max data. int totalDataCount = 0; for (var i = 0; i < rsBlocks.Count; i++) { totalDataCount += rsBlocks[i].DataCount; } if (buffer.GetLengthInBits() > totalDataCount * 8) { throw new ErrorException(string.Format( "code length overflow ({0} > {1})", buffer.GetLengthInBits(), totalDataCount * 8), ErrorCode.CodeLengthOverflow); } // end code if (buffer.GetLengthInBits() + 4 <= totalDataCount * 8) { buffer.Put(0, 4); } // padding while (buffer.GetLengthInBits() % 8 != 0) { buffer.PutBit(false); } // padding while (true) { if (buffer.GetLengthInBits() >= totalDataCount * 8) { break; } buffer.Put(QRCode.PAD0, 8); if (buffer.GetLengthInBits() >= totalDataCount * 8) { break; } buffer.Put(QRCode.PAD1, 8); } return(CreateBytes(buffer, rsBlocks)); }