< index
< 5. Image toolkit
|
=====================================
5.3 Creating an image from a console
=====================================
|
|
You can create an image from any console (either the root console or an offscreen console).
The image size will depend on the console size and the font characters size.
You can then save the image to a file with the save function.
C++ : TCODImage::TCODImage(const TCODConsole *console)
C : TCOD_image_t TCOD_image_from_console(TCOD_console_t console)
Py : image_from_console(console)
Parameter | Description |
console | The console to convert. In the C version, use NULL for the root console. |
Example :
C++ : TCODImage *pix = new TCODImage(TCODConsole::root);
C : TCOD_image_t pix = TCOD_image_from_console(NULL);
Py : pix = libtcod.image_from_console(0)
If you need to refresh the image with the console's new content, you don't have to delete it and create another one. Instead, use this function :
C++ : void TCODImage::refreshConsole(const TCODConsole *console)
C : void TCOD_image_refresh_console(TCOD_image_t image, TCOD_console_t console)
Py : image_refresh_console(image, console)
Note that you must use the same console that was used in the TCOD_image_from_console call (or at least a console with the same size).
Parameter | Description |
image | In the C version, the image created with TCOD_image_from_console. |
console | The console to capture. In the C version, use NULL for the root console. |
Example :
C++ : TCODImage *pix = new TCODImage(TCODConsole::root); // create an image from the root console
// ... modify the console
pix->refreshConsole(TCODConsole::root); // update the image with the console's new content
C : TCOD_image_t pix = TCOD_image_from_console(NULL);
/* ... modify the console .. */
TCOD_image_refresh_console(pix,NULL);
Py : pix = libtcod.image_from_console(0)
# ... modify the console ..
libtcod.image_refresh_console(pix,0)