caca_importexport(3caca)

πŸ’… caca_importexport β€” importers & exporters, the whole glow-up

Okay so bestie, welcome to caca_importexport(3caca) from libcaca β€” this is the page where your canvas learns to talk to the outside world (importing) and to post its whole look (exporting). Slay. πŸ¦‹


✨ NAME ✨

caca_importexport β€” libcaca importers/exporters from/to various formats. That's it, that's the vibe: formats in, formats out. πŸ’«


πŸŽ€ SYNOPSIS πŸŽ€

🌸 Topics

  • libcaca display functions

🫢 Functions

  • __extern ssize_t caca_import_canvas_from_memory (caca_canvas_t *, void const *, size_t, char const *) β€” import a memory buffer into a canvas.
  • __extern ssize_t caca_import_canvas_from_file (caca_canvas_t *, char const *, char const *) β€” import a file into a canvas.
  • __extern 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.
  • __extern ssize_t caca_import_area_from_file (caca_canvas_t *, int, int, char const *, char const *) β€” import a file into a canvas area.
  • __extern char const *const * caca_get_import_list (void) β€” get available import formats.
  • __extern void * caca_export_canvas_to_memory (caca_canvas_t const *, char const *, size_t *) β€” export a canvas into a foreign format.
  • __extern 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.
  • __extern char const *const * caca_get_export_list (void) β€” get available export formats.

πŸ’– DETAILED DESCRIPTION πŸ’–

Literally what it says on the tin, queen: these functions import various file formats into a new canvas, or export the current canvas to various text formats. In and out. That's the whole main character arc. πŸ”₯


πŸ‘‘ FUNCTION DOCUMENTATION πŸ‘‘

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

Imports a memory buffer into the given libcaca canvas's current frame. The current frame gets resized accordingly and its contents are replaced with the imported data. No leftovers, no crumbs β€” full replacement energy. πŸ’…

Valid values for format are, and I need you to note these down:

  • "" β€” attempt to autodetect the file format (she'll figure it out herself).
  • "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 there wasn't enough data, 0 is returned. (Not an error, just an "mmkay bestie, send more" moment.)

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

  • ENOMEM β€” not enough memory to allocate canvas.
  • EOVERFLOW β€” importing data caused a value overflow.
  • EINVAL β€” invalid format requested.

πŸ“ Parameters

  • cv β€” a libcaca canvas in which to import the file.
  • data β€” a memory area containing the data to be loaded into the canvas.
  • len β€” the size in bytes of the memory area.
  • format β€” a 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.

⭐ Referenced by

caca_import_area_from_memory(), and caca_import_canvas_from_file().


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

Imports 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. Same energy as above, except she's reading from disk now. πŸ“‚

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

  • cv β€” a libcaca canvas in which to import the file.
  • filename β€” the name of the file to load.
  • format β€” a 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.

⭐ References

caca_file_close(), caca_file_eof(), caca_file_open(), caca_file_read(), and caca_import_canvas_from_memory().

πŸ‘€ Referenced by

caca_import_area_from_file().


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

Imports a memory buffer into the given libcaca canvas's current frame, at the specified position. It's the canvas version of ✨dropping a sticker exactly where you want it✨. For more info, 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

  • cv β€” a libcaca canvas in which to import the file.
  • x β€” the leftmost coordinate of the area to import to.
  • y β€” the topmost coordinate of the area to import to.
  • data β€” a memory area containing the data to be loaded into the canvas.
  • len β€” the size in bytes of the memory area.
  • format β€” a 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.

⭐ References

caca_blit(), caca_create_canvas(), caca_free_canvas(), and caca_import_canvas_from_memory().


πŸ¦‹ __extern ssize_t caca_import_area_from_file (caca_canvas_t * cv, int x, int y, char const * filename, char const * format)

Imports 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

  • cv β€” a libcaca canvas in which to import the file.
  • x β€” the leftmost coordinate of the area to import to.
  • y β€” the topmost coordinate of the area to import to.
  • filename β€” the name of the file to load.
  • format β€” a 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.

⭐ References

caca_blit(), caca_create_canvas(), caca_free_canvas(), and caca_import_canvas_from_file().


πŸŽ€ __extern char const *const * caca_get_import_list (void )

Returns 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. So it's like: value, pretty name, value, pretty name, …, NULL. Two at a time, always paired. iykyk. πŸ’«

This function never fails. Iconic behaviour honestly. πŸ‘‘

πŸ’œ Returns

An array of strings.


πŸ”₯ __extern void * caca_export_canvas_to_memory (caca_canvas_t const * cv, char const * format, size_t * bytes)

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. Do not forget the free(), bestie, that's a memory leak and we don't do those. 😭

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

  • cv β€” a libcaca canvas.
  • format β€” a string describing the requested output format.
  • bytes β€” a 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.

⭐ Referenced by

caca_export_area_to_memory().


🌟 __extern 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)

This function exports a portion of a libcaca canvas into various formats β€” like cropping your pic before you post it. πŸ’… 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

  • cv β€” a libcaca canvas.
  • x β€” the leftmost coordinate of the area to export.
  • y β€” the topmost coordinate of the area to export.
  • w β€” the width of the area to export.
  • h β€” the height of the area to export.
  • format β€” a string describing the requested output format.
  • bytes β€” a 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.

⭐ References

caca_blit(), caca_create_canvas(), caca_export_canvas_to_memory(), and caca_free_canvas().


🌈 __extern char const *const * caca_get_export_list (void )

Returns 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. Same pairing situation as the import list, just the outgoing direction. 🎁

This function never fails either. Flawless. πŸ’―

πŸ’œ Returns

An array of strings.


🫢 AUTHOR 🫢

Generated automatically by Doxygen for libcaca from the source code. Not a human, just a very diligent robot doing its little doc thing. πŸ€–βœ¨


Okay and that's the whole page, bestie β€” every flag, every errno, every reference, all of it. Now go import something cute and export it somewhere cuter. πŸŽ€πŸ’–

Version 0.99.beta20 Β· Wed May 13 2026 09:45:08 Β· page caca_importexport(3caca) β€” mwah, that's a wrap, periodt. πŸ’…πŸ¦‹

πŸ“¦ where this page comes from