libcaca  0.99.beta19
About: libcaca is a graphics library that outputs text instead of pixels, so that it can work on older video cards or text terminals (something like an advanced AAlib library).
  Fossies Dox: libcaca-0.99.beta19.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

libcaca importers/exporters from/to various

formats More...

Functions

ssize_t caca_import_canvas_from_memory (caca_canvas_t *, void const *, size_t, char const *)
 Import a memory buffer into a canvas. More...
 
ssize_t caca_import_canvas_from_file (caca_canvas_t *, char const *, char const *)
 Import a file into a canvas. More...
 
ssize_t caca_import_area_from_memory (caca_canvas_t *, int, int, void const *, size_t, char const *)
 Import a memory buffer into a canvas area. More...
 
ssize_t caca_import_area_from_file (caca_canvas_t *, int, int, char const *, char const *)
 Import a file into a canvas area. More...
 
const char *const * caca_get_import_list (void)
 Get available import formats. More...
 
void * caca_export_canvas_to_memory (caca_canvas_t const *, char const *, size_t *)
 Export a canvas into a foreign format. More...
 
void * caca_export_area_to_memory (caca_canvas_t const *, int, int, int, int, char const *, size_t *)
 Export a canvas portion into a foreign format. More...
 
const char *const * caca_get_export_list (void)
 Get available export formats. More...
 

Detailed Description

formats

These functions import various file formats into a new canvas, or export the current canvas to various text formats.

Function Documentation

◆ caca_export_area_to_memory()

void* caca_export_area_to_memory ( caca_canvas_t const *  cv,
int  x,
int  y,
int  w,
int  h,
char const *  format,
size_t *  bytes 
)

Export a canvas portion into a foreign format.

This function exports a portion of a libcaca canvas into various formats. For more information, see caca_export_canvas_to_memory().

If an error occurs, NULL is returned and errno is set accordingly:

  • EINVAL Unsupported format requested or invalid coordinates.
  • ENOMEM Not enough memory to allocate output buffer.
Parameters
cvA libcaca canvas
xThe leftmost coordinate of the area to export.
yThe topmost coordinate of the area to export.
wThe width of the area to export.
hThe height of the area to export.
formatA string describing the requested output format.
bytesA pointer to a size_t where the number of allocated bytes will be written.
Returns
A pointer to the exported memory area, or NULL in case of error.

Definition at line 145 of file export.c.

References caca_blit(), caca_create_canvas(), caca_export_canvas_to_memory(), caca_free_canvas(), cv, caca_canvas::height, seterrno, caca_canvas::width, x, and y.

Referenced by export_area_to_memory().

◆ caca_export_canvas_to_memory()

void* caca_export_canvas_to_memory ( caca_canvas_t const *  cv,
char const *  format,
size_t *  bytes 
)

Export a canvas into a foreign format.

This function exports a libcaca canvas into various foreign formats such as ANSI art, HTML, IRC colours, etc. The returned pointer should be passed to free() to release the allocated storage when it is no longer needed.

Valid values for format are:

  • "caca": export native libcaca files.
  • "ansi": export ANSI art (CP437 charset with ANSI colour codes).
  • "html": export an HTML page with CSS information.
  • "html3": export an HTML table that should be compatible with most navigators, including textmode ones.
  • "irc": export UTF-8 text with mIRC colour codes.
  • "ps": export a PostScript document.
  • "svg": export an SVG vector image.
  • "tga": export a TGA image.
  • "troff": export a troff source.

If an error occurs, NULL is returned and errno is set accordingly:

  • EINVAL Unsupported format requested.
  • ENOMEM Not enough memory to allocate output buffer.
Parameters
cvA libcaca canvas
formatA string describing the requested output format.
bytesA pointer to a size_t where the number of allocated bytes will be written.
Returns
A pointer to the exported memory area, or NULL in case of error.

Definition at line 83 of file export.c.

References _export_ansi(), _export_irc(), _export_utf8(), cv, export_bbfr(), export_caca(), export_html(), export_html3(), export_ps(), export_svg(), export_tga(), export_troff(), seterrno, and strcasecmp.

Referenced by caca_export_area_to_memory(), cucul_export_canvas(), export_to_memory(), Canvas::exportToMemory(), main(), and raw_display().

◆ caca_get_export_list()

const char* const * caca_get_export_list ( void  )

Get available export formats.

Return a list of available export formats. The list is a NULL-terminated array of strings, interleaving a string containing the internal value for the export format, to be used with caca_export_memory(), and a string containing the natural language description for that export format.

This function never fails.

Returns
An array of strings.

Definition at line 180 of file export.c.

Referenced by Canvas::getExportList(), and usage().

◆ caca_get_import_list()

const char* const * caca_get_import_list ( void  )

Get available import formats.

Return a list of available import formats. The list is a NULL-terminated array of strings, interleaving a string containing the internal value for the import format, to be used with caca_import_canvas(), and a string containing the natural language description for that import format.

This function never fails.

Returns
An array of strings.

Definition at line 276 of file import.c.

Referenced by Canvas::getImportList().

◆ caca_import_area_from_file()

ssize_t caca_import_area_from_file ( caca_canvas_t cv,
int  x,
int  y,
char const *  filename,
char const *  format 
)

Import a file into a canvas area.

Import a file into the given libcaca canvas's current frame, at the specified position. For more information, see caca_import_canvas_from_file().

If an error occurs, -1 is returned and errno is set accordingly:

  • ENOSYS File access is not implemented on this system.
  • ENOMEM Not enough memory to allocate canvas.
  • EINVAL Unsupported format requested or invalid coordinates. caca_import_file() may also fail and set errno for any of the errors specified for the routine fopen().
Parameters
cvA libcaca canvas in which to import the file.
xThe leftmost coordinate of the area to import to.
yThe topmost coordinate of the area to import to.
filenameThe name of the file to load.
formatA string describing the input format.
Returns
The number of bytes read, or 0 if there was not enough data, or -1 if an error occurred.

Definition at line 248 of file import.c.

References caca_blit(), caca_create_canvas(), caca_free_canvas(), caca_import_canvas_from_file(), cv, x, and y.

Referenced by import_area_from_file().

◆ caca_import_area_from_memory()

ssize_t caca_import_area_from_memory ( caca_canvas_t cv,
int  x,
int  y,
void const *  data,
size_t  len,
char const *  format 
)

Import a memory buffer into a canvas area.

Import a memory buffer into the given libcaca canvas's current frame, at the specified position. For more information, see caca_import_canvas_from_memory().

If an error occurs, -1 is returned and errno is set accordingly:

  • EINVAL Unsupported format requested or invalid coordinates.
  • ENOMEM Not enough memory to allocate canvas.
Parameters
cvA libcaca canvas in which to import the file.
xThe leftmost coordinate of the area to import to.
yThe topmost coordinate of the area to import to.
dataA memory area containing the data to be loaded into the canvas.
lenThe size in bytes of the memory area.
formatA string describing the input format.
Returns
The number of bytes read, or 0 if there was not enough data, or -1 if an error occurred.

Definition at line 209 of file import.c.

References caca_blit(), caca_create_canvas(), caca_free_canvas(), caca_import_canvas_from_memory(), cv, x, and y.

Referenced by import_area_from_memory().

◆ caca_import_canvas_from_file()

ssize_t caca_import_canvas_from_file ( caca_canvas_t cv,
char const *  filename,
char const *  format 
)

Import a file into a canvas.

Import a file into the given libcaca canvas's current frame. The current frame is resized accordingly and its contents are replaced with the imported data.

Valid values for format are:

  • "": attempt to autodetect the file format.
  • "caca": import native libcaca files.
  • "text": import ASCII text files.
  • "ansi": import ANSI files.
  • "utf8": import UTF-8 files with ANSI colour codes.
  • "bin": import BIN files.

The number of bytes read is returned. If the file format is valid, but not enough data was available, 0 is returned.

If an error occurs, -1 is returned and errno is set accordingly:

  • ENOSYS File access is not implemented on this system.
  • ENOMEM Not enough memory to allocate canvas.
  • EINVAL Invalid format requested. caca_import_file() may also fail and set errno for any of the errors specified for the routine fopen().
Parameters
cvA libcaca canvas in which to import the file.
filenameThe name of the file to load.
formatA string describing the input format.
Returns
The number of bytes read, or 0 if there was not enough data, or -1 if an error occurred.

Definition at line 152 of file import.c.

References caca_file_close(), caca_file_eof(), caca_file_open(), caca_file_read(), caca_import_canvas_from_memory(), cv, and seterrno.

Referenced by __caca0_load_sprite(), caca_import_area_from_file(), import_from_file(), Canvas::importFromFile(), and main().

◆ caca_import_canvas_from_memory()

ssize_t caca_import_canvas_from_memory ( caca_canvas_t cv,
void const *  data,
size_t  len,
char const *  format 
)

Import a memory buffer into a canvas.

Import a memory buffer into the given libcaca canvas's current frame. The current frame is resized accordingly and its contents are replaced with the imported data.

Valid values for format are:

  • "": attempt to autodetect the file format.
  • "caca": import native libcaca files.
  • "text": import ASCII text files.
  • "ansi": import ANSI files.
  • "utf8": import UTF-8 files with ANSI colour codes.
  • "bin": import BIN files.

The number of bytes read is returned. If the file format is valid, but not enough data was available, 0 is returned.

If an error occurs, -1 is returned and errno is set accordingly:

  • ENOMEM Not enough memory to allocate canvas.
  • EINVAL Invalid format requested.
Parameters
cvA libcaca canvas in which to import the file.
dataA memory area containing the data to be loaded into the canvas.
lenThe size in bytes of the memory area.
formatA string describing the input format.
Returns
The number of bytes read, or 0 if there was not enough data, or -1 if an error occurred.

Definition at line 73 of file import.c.

References _import_ansi(), _import_bin(), _import_text(), cv, import_caca(), seterrno, and strcasecmp.

Referenced by caca_import_area_from_memory(), caca_import_canvas_from_file(), cucul_import_canvas(), import_from_memory(), Canvas::importFromMemory(), main(), and open_charfont().