Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. #
  4. # Generate QR code from binary
  5. #
  6.  
  7. import sys, Image
  8.  
  9. bin_list = [
  10. """1111111000001010001111111
  11. 1000001010101111101000001
  12. 1011101000010011001011101
  13. 1011101011111010001011101
  14. 1011101001000100101011101
  15. 1000001011001111001000001
  16. 1111111010101010101111111
  17. 0000000001101010100000000
  18. 1111101111011101110101010
  19. 1011110000110101100001010
  20. 1011001010100011110110001
  21. 0001110000010011111111000
  22. 0001111111100010011000111
  23. 1110100100011010010100011
  24. 1010111111001101101101111
  25. 1001110101010001010011001
  26. 1001011001100011111111100
  27. 0000000011100010100010101
  28. 1111111010100110101010011
  29. 1000001000000011100010011
  30. 1011101010111111111110110
  31. 1011101011011010111101111
  32. 1011101011100000101100001
  33. 1000001010101011111101001
  34. 1111111011000100001010111
  35. """]
  36.  
  37. altered_bin_list = []
  38.  
  39. # Invert inner block
  40. row = 0
  41. col = 0
  42.  
  43. for line in bin_list:
  44. for i in line:
  45. bit = i
  46.  
  47. # Ignore new lines
  48. if i == '\n':
  49. continue
  50.  
  51. if (row >= 7 and row <= 17 and col >= 7 and col <= 17):
  52. bit = "0" if (i == "1") else "1"
  53.  
  54. altered_bin_list.append(bit)
  55.  
  56. col += 1;
  57.  
  58. if col >= 25:
  59. altered_bin_list.append('\n')
  60. row += 1;
  61. col = 0
  62.  
  63.  
  64. # Generate altered image
  65. im = Image.new('RGB', (25, 25))
  66. data = []
  67.  
  68. for line in altered_bin_list:
  69. for i in line:
  70. if i == "0":
  71. data.append((255,255,255))
  72. elif i == "1":
  73. data.append((0,0,0))
  74.  
  75. im.putdata(data)
  76. im.save('qr.png')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement