@@ -150,9 +150,7 @@ public static QRCodeData GenerateQrCode(string plainText, ECCLevel eccLevel, boo
150
150
}
151
151
modeIndicator += DecToBin ( ( int ) encoding , 4 ) ;
152
152
var countIndicator = DecToBin ( dataInputLength , GetCountIndicatorLength ( version , encoding ) ) ;
153
- var bitString = modeIndicator + countIndicator ;
154
-
155
- bitString += codedText ;
153
+ var bitString = modeIndicator + countIndicator + codedText ;
156
154
157
155
return GenerateQrCode ( bitString , eccLevel , version ) ;
158
156
}
@@ -170,9 +168,10 @@ public static QRCodeData GenerateQrCode(byte[] binaryData, ECCLevel eccLevel)
170
168
int version = GetVersion ( binaryData . Length , EncodingMode . Byte , eccLevel ) ;
171
169
172
170
string modeIndicator = DecToBin ( ( int ) EncodingMode . Byte , 4 ) ;
173
- string countIndicator = DecToBin ( binaryData . Length , GetCountIndicatorLength ( version , EncodingMode . Byte ) ) ;
171
+ int countIndicatorLen = GetCountIndicatorLength ( version , EncodingMode . Byte ) ;
172
+ string countIndicator = DecToBin ( binaryData . Length , countIndicatorLen ) ;
174
173
175
- StringBuilder sb = new StringBuilder ( ) ;
174
+ StringBuilder sb = new StringBuilder ( capacity : 4 + countIndicatorLen + ( binaryData . Length * 8 ) ) ;
176
175
sb . Append ( modeIndicator ) . Append ( countIndicator ) ;
177
176
foreach ( byte b in binaryData )
178
177
{
0 commit comments