Advertisement
Guest User

Untitled

a guest
Feb 27th, 2016
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #
  2. # translate a plain text file into the REXPaint file format
  3. #
  4. # NOTE: seems to come out rotated -90 for some reason
  5. # writing order is off? idk
  6. import struct
  7.  
  8. INFILE = 'plain_text.txt'
  9. OUTFILE = 'fancy_text.xp'
  10.  
  11. def doit():
  12. fp = open(INFILE)
  13. lines = fp.readlines()
  14. fp.close()
  15.  
  16. with open(OUTFILE, 'wb') as fp:
  17. fp.write(struct.pack('i', 1))
  18. fp.write(struct.pack('i', 1))
  19. fp.write(struct.pack('i', len(lines[0])))
  20. fp.write(struct.pack('i', len(lines)))
  21. for line in lines:
  22. for ch in line:
  23. fp.write(struct.pack('i', ord(ch)))
  24. fp.write(struct.pack('BBBBBB', 255,255,255,0,0,0))
  25.  
  26.  
  27.  
  28. if __name__ == '__main__':
  29. doit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement