REXPaint Files¶
These functions allow the saving and loading of REXPaint files.
Keep in mind that REXPaint files are typically encoded as Code Page 437 which will need to be converted into Unicode to be understood by libtcod.
C++ API¶
-
inline std::vector<tcod::ConsolePtr> tcod::load_xp(const std::filesystem::path &path)¶
Load an array of consoles from a REXPaint file.
New in version 1.18.
- Parameters
path – The path to the REXPaint file to load.
- Returns
Returns a vector of consoles.
-
inline void tcod::save_xp(const std::vector<const TCOD_Console*> &consoles, const std::filesystem::path &path, int compress_level = 9)¶
Save an array of consoles to a REXPaint file.
New in version 1.18.
- Parameters
consoles – A vector of consoles to save.
path – The path to write the REXPaint file to.
compress_level – A compression level for the zlib library.
C API¶
-
int TCOD_load_xp(const char *path, int n, TCOD_Console **out)¶
Load an array of consoles from a REXPaint file.
New in version 1.18.
- Parameters
path – The path to the REXPaint file, can not be NULL.
n – The size of the
out
array. Can be zero.out – The array to fill with loaded consoles.
- Returns
Returns the number of consoles held by the file. Returns a negative error code on error.
-
TCOD_Error TCOD_save_xp(int n, const TCOD_Console *const *consoles, const char *path, int compress_level)¶
Save an array of consoles to a REXPaint file.
Partially initialized consoles are released on failures.
New in version 1.18.
- Parameters
n – The number of consoles in the
consoles
array.consoles – An array of consoles.
path – The path write the REXPaint file, can not be NULL.
compress_level – A compression level for the zlib library.
- Returns
Returns an error code on failure.
-
int TCOD_load_xp_from_memory(int n_data, const unsigned char *data, int n_out, TCOD_Console **out)¶
Load an array of consoles from a REXPaint file in memory.
You can call this function with
n_out=0
andout=NULL
to get the number of consoles in the file.New in version 1.18.
- Parameters
n_data – The length of the input
data
buffer.data – The buffer where the REXPaint file is held.
n_out – The length of the output console
out
array. Can be zero.out – The array to fill with loaded consoles.
- Returns
Returns the number of consoles held by the file. Returns a negative error code on error.
-
int TCOD_save_xp_to_memory(int n_consoles, const TCOD_Console *const *consoles, int n_out, unsigned char *out, int compression_level)¶
Save an array of consoles to a REXPaint file in memory.
Partially initialized consoles are released on failures.
New in version 1.18.
- Parameters
n_consoles – The length of the input
consoles
array.consoles – An array of tcod consoles, can not be NULL.
n_out – The size of the
out
buffer, if this is zero then upper bound to be returned.out – A pointer to an output buffer, can be NULL.
compression_level – A compression level for the zlib library.
- Returns
If
out=NULL
then returns the upper bound of the buffer size needed. Otherwise this returns the number of bytes actually filled. On an error a negative error code is returned.