Browse Source

fixed bug with reminder bits in some qr versions

Florian Sundermann 12 năm trước cách đây
mục cha
commit
4c758a440a
1 tập tin đã thay đổi với 9 bổ sung5 xóa
  1. 9 5
      qr/encoder.go

+ 9 - 5
qr/encoder.go

@@ -109,13 +109,17 @@ func render(data []byte, vi *versionInfo) *qrcode {
 	var curBitNo int = 0
 
 	for pos := range itterateModules(occupied) {
+		var curBit bool
 		if curBitNo < len(data)*8 {
-			curBit := ((data[curBitNo/8] >> uint(7-(curBitNo%8))) & 1) == 1
-			for i := 0; i < 8; i++ {
-				setMasked(pos.X, pos.Y, curBit, i, results[i].Set)
-			}
-			curBitNo += 1
+			curBit = ((data[curBitNo/8] >> uint(7-(curBitNo%8))) & 1) == 1
+		} else {
+			curBit = false
+		}
+
+		for i := 0; i < 8; i++ {
+			setMasked(pos.X, pos.Y, curBit, i, results[i].Set)
 		}
+		curBitNo += 1
 	}
 
 	lowestPenalty := ^uint(0)