Guest User

Untitled

a guest
Dec 11th, 2014
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. from PIL import Image
  2.  
  3. #open the raw data file
  4. file = open("data.raw", "rb")
  5. data = file.read()
  6. file.close()
  7.  
  8. #convert to array of integers
  9. data_array = []
  10. for item in data:
  11.     data_array.append(int(item))
  12.  
  13. #create new image
  14. image = Image.new("RGB", (232, 245))
  15.  
  16. #set offset
  17. pixel=23
  18.  
  19. #iterate through each pixel in the image, setting as appropriate based on data_array contents
  20. for y in range(245):
  21.     for x in range(232):
  22.         image.putpixel((x, y), (data_array[pixel], data_array[pixel+1], data_array[pixel+2]))
  23.         pixel += 3
  24.  
  25. #export image as png
  26. image.save("data.png")
Advertisement
Add Comment
Please, Sign In to add comment