Skip to content

Instantly share code, notes, and snippets.

Created February 27, 2016 13:37
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Convert plain text to XP format used by REXPaint
# translate a plain text file into the REXPaint file format
# NOTE: seems to come out rotated -90 for some reason
# writing order is off? idk
import struct
INFILE = 'plain_text.txt'
OUTFILE = 'fancy_text.xp'
def doit():
fp = open(INFILE)
lines = fp.readlines()
with open(OUTFILE, 'wb') as fp:
fp.write(struct.pack('i', 1))
fp.write(struct.pack('i', 1))
fp.write(struct.pack('i', len(lines[0])))
fp.write(struct.pack('i', len(lines)))
for line in lines:
for ch in line:
fp.write(struct.pack('i', ord(ch)))
fp.write(struct.pack('BBBBBB', 255,255,255,0,0,0))
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment