Go to the previous, next section.
AA-Lib also have a driver specialized for image saving. It's name is
save_d
(currently only driver that uses aa_savedata
structure):
struct aa_savedata { char *name; struct aa_format *format; FILE *file; };
Field name
contains a filename (without extension).
If you wish to specify file descriptor, you might want to use field
file
instead. Set name
to NULL
in this cases.
Note that then file will not be closed automatically. In name
you
should use following tags:
_%x_%y
, if pages enabled otherwise none
.html
)
Format
is a pointer to aa_format
structure (format information):
struct aa_format { int width, height; /*default width/height*/ int pagewidth, pageheight;/*in case output is made from pages*/ int flags; /*should be made from: AA_USE_PAGES AA_NORMAL_SPACES */ int supported; /*mask of supported attributes*/ struct aa_font *font; /*font used by hardware device*/ char *formatname; /*name of format*/ char *extension; /*file extension*/ char *head; /*text at the beggining of file*/ char *end; /*text at the end of file*/ char *newline; /*text at the end of line*/ char *prints[AA_NATTRS]; /*printf seqence for printing character*/ char *begin[AA_NATTRS]; /*text printed at the beggining of block of character at gived attribute*/ char *ends[AA_NATTRS]; /*text printed at the end of block*/ char **conversions /*conversion tabe*/ };
Conversions is array of strings in format: character, replacement, terminated
by NULL
.
Following code is an example of HTML
format description:
static char *html_escapes[] = {"<", "<", ">", ">", "&", "&", NULL}; struct aa_format aa_html_format = { 79, 25, 0, 0, 0, AA_NORMAL_MASK | AA_BOLD_MASK | AA_BOLDFONT_MASK, NULL, "Pure html", ".html", "<HTML>\n <HEAD> <TITLE>Ascii arted image done using aalib</TITLE>\n</HEAD>\n<BODY><PRE>\n", "</PRE></BODY>\n</HTML>\n", "\n", /*The order is:normal, dim, bold, boldfont, reverse, special*/ { "%s", "%s", "%s", "%s", "%s", }, {"", "", "<B>", "", "<B>" }, {"", "", "</B>", "", "</B>" }, html_escapes };
Usually you don't need to worry about filling in this large structure since
the formats are already defined: aa_nhtml_format
,
aa_html_format
, aa_html_alt_format
, aa_ansi_format
,
aa_text_format
, aa_more_format
, aa_hp_format
,
aa_hp2_format
, aa_zephyr_format
, aa_irc_format
.
All formats are collected in aa_formats
array. It is array of
pointers to aa_format
terminated by NULL
All additional new formats are welcomed.
Go to the previous, next section.