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.
Added 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.
Added 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.
Added in version 1.18.
- Parameters:
path – The path to the REXPaint file, can not be NULL.
n – The size of the
outarray. 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.
Added in version 1.18.
- Parameters:
n – The number of consoles in the
consolesarray.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=0andout=NULLto get the number of consoles in the file.Added in version 1.18.
- Parameters:
n_data – The length of the input
databuffer.data – The buffer where the REXPaint file is held.
n_out – The length of the output console
outarray. 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.
Added in version 1.18.
- Parameters:
n_consoles – The length of the input
consolesarray.consoles – An array of tcod consoles, can not be NULL.
n_out – The size of the
outbuffer, 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=NULLthen 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.