Create a gist now

Instantly share code, notes, and snippets.

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()
fp.close()
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__':
doit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment