| 472 | self.modules[self.modules_count - 8][8] = not test |
| 473 | |
| 474 | def map_data(self, data, mask_pattern): |
| 475 | inc = -1 |
| 476 | row = self.modules_count - 1 |
| 477 | bitIndex = 7 |
| 478 | byteIndex = 0 |
| 479 | |
| 480 | mask_func = util.mask_func(mask_pattern) |
| 481 | |
| 482 | data_len = len(data) |
| 483 | |
| 484 | for col in range(self.modules_count - 1, 0, -2): |
| 485 | if col <= 6: |
| 486 | col -= 1 |
| 487 | |
| 488 | col_range = (col, col - 1) |
| 489 | |
| 490 | while True: |
| 491 | for c in col_range: |
| 492 | if self.modules[row][c] is None: |
| 493 | dark = False |
| 494 | |
| 495 | if byteIndex < data_len: |
| 496 | dark = ((data[byteIndex] >> bitIndex) & 1) == 1 |
| 497 | |
| 498 | if mask_func(row, c): |
| 499 | dark = not dark |
| 500 | |
| 501 | self.modules[row][c] = dark |
| 502 | bitIndex -= 1 |
| 503 | |
| 504 | if bitIndex == -1: |
| 505 | byteIndex += 1 |
| 506 | bitIndex = 7 |
| 507 | |
| 508 | row += inc |
| 509 | |
| 510 | if row < 0 or self.modules_count <= row: |
| 511 | row -= inc |
| 512 | inc = -inc |
| 513 | break |
| 514 | |
| 515 | def get_matrix(self): |
| 516 | """ |