clubsandwich.xp_loader
¶
Load the REXPaint file format. If
you’re using this with the rest of clubsandwich and not just by itself, you
probably want to check out clubsandwich.blt.rexpaint_image
instead!
It’s much nicer.
In-memory XP format is as follows:
Returned structure is a dictionary with the keys version
, layers
,
width
, height
, and layer_data
.
version
is stored in case it’s useful for someone, but as mentioned in the format description it probably won’t be unless format changes happen.layers
is a full 32 bit int, though right now REXPaint only exports or manages up to 4 layers.width
andheight
are extracted from the layer with largest width and height - this value will hold true for all layers for now as per the format description.layer_data
is a list of individual layers, which are stored in the following format:- Each layer is a dictionary with keys
width
,height
(see above), andcells
. cells
is a row major 2d array of, again, dictionaries with the valueskeycode
(ascii keycode),fore_r/g/b
, andback_r/g/b
(technically ints but in value 0-255)
- Each layer is a dictionary with keys
-
clubsandwich.xp_loader.
load_xp_file
(path, reverse_endian=True)¶ Load a REXPaint image from the given
.xp
path.Parameters: - path (str) – Path to a
.xp
file - reverse_endian (bool) – Controls whether the slices containing data for
things like layer width, height, number of layers,
etc. is reversed. So far as I can tell Python is
doing int conversions in big-endian, while the
.xp
format stores them in little-endian. I may just not be aware of it being unneeded, but have it there in case.
- path (str) – Path to a
-
clubsandwich.xp_loader.
load_xp_string
(file_string, reverse_endian=True)¶ Parameters: - file_string (str) – String contents of a
.xp
file generated by REXPaint - reverse_endian (bool) – Controls whether the slices containing data for
things like layer width, height, number of layers,
etc. is reversed. So far as I can tell Python is
doing int conversions in big-endian, while the
.xp
format stores them in little-endian. I may just not be aware of it being unneeded, but have it there in case.
- file_string (str) – String contents of a