libansilove

Library for converting ANSI, ASCII, and other formats to PNG
Log | Files | Refs | README | LICENSE

ansilove.h (3415B)


      1 /*
      2  * ansilove.h
      3  * libansilove 1.2.7
      4  * https://www.ansilove.org
      5  *
      6  * Copyright (c) 2011-2020 Stefan Vogt, Brian Cassidy, and Frederic Cambus
      7  * All rights reserved.
      8  *
      9  * libansilove is licensed under the BSD 2-Clause License.
     10  * See LICENSE file for details.
     11  */
     12 
     13 #ifndef ANSILOVE_H
     14 #define ANSILOVE_H
     15 
     16 #include <stdbool.h>
     17 #include <stddef.h>
     18 #include <stdint.h>
     19 
     20 #define ANSILOVE_EXTERN __attribute__((visibility("default")))
     21 
     22 /* Version number */
     23 #define ANSILOVE_VERSION "1.2.7"
     24 
     25 #define ANSILOVE_VERSION_MAJOR		1
     26 #define ANSILOVE_VERSION_MINOR		2
     27 #define ANSILOVE_VERSION_PATCH		7
     28 
     29 /* Error codes */
     30 #define ANSILOVE_INVALID_PARAM		1
     31 #define ANSILOVE_FORMAT_ERROR		2
     32 #define ANSILOVE_MEMORY_ERROR		3
     33 #define ANSILOVE_RANGE_ERROR		4
     34 #define ANSILOVE_FILE_READ_ERROR	5
     35 #define ANSILOVE_FILE_WRITE_ERROR	6
     36 #define ANSILOVE_GD_ERROR		7
     37 
     38 /* PC Fonts */
     39 #define ANSILOVE_FONT_CP437		1	/* IBM PC 80x25 */
     40 #define ANSILOVE_FONT_CP437_80x50	2	/* IBM PC 80x50 */
     41 #define ANSILOVE_FONT_CP737		3	/* Greek */
     42 #define ANSILOVE_FONT_CP775		4	/* Baltic */
     43 #define ANSILOVE_FONT_CP850		5	/* Latin 1 */
     44 #define ANSILOVE_FONT_CP852		6	/* Latin 2 */
     45 #define ANSILOVE_FONT_CP855		7	/* Cyrillic */
     46 #define ANSILOVE_FONT_CP857		8	/* Turkish */
     47 #define ANSILOVE_FONT_CP860		9	/* Portuguese */
     48 #define ANSILOVE_FONT_CP861		10	/* Icelandic */
     49 #define ANSILOVE_FONT_CP862		11	/* Hebrew */
     50 #define ANSILOVE_FONT_CP863		12	/* French-canadian */
     51 #define ANSILOVE_FONT_CP865		13	/* Nordic */
     52 #define ANSILOVE_FONT_CP866		14	/* Russian */
     53 #define ANSILOVE_FONT_CP869		15	/* Greek */
     54 #define ANSILOVE_FONT_TERMINUS		20
     55 
     56 /* Amiga fonts */
     57 #define ANSILOVE_FONT_MICROKNIGHT	30
     58 #define ANSILOVE_FONT_MICROKNIGHT_PLUS	31
     59 #define ANSILOVE_FONT_MOSOUL		32
     60 #define ANSILOVE_FONT_POT_NOODLE	33
     61 #define ANSILOVE_FONT_TOPAZ		34
     62 #define ANSILOVE_FONT_TOPAZ_PLUS	35
     63 #define ANSILOVE_FONT_TOPAZ500		36
     64 #define ANSILOVE_FONT_TOPAZ500_PLUS	37
     65 
     66 /* Rendering modes */
     67 #define ANSILOVE_MODE_CED		1
     68 #define ANSILOVE_MODE_TRANSPARENT	2
     69 #define ANSILOVE_MODE_WORKBENCH		3
     70 
     71 struct ansilove_png {
     72 	uint8_t *buffer;
     73 	int length; /* Match the parameter type of gdImagePngPtr() */
     74 };
     75 
     76 struct ansilove_ctx {
     77 	uint8_t *buffer;
     78 	size_t maplen;
     79 	size_t length;
     80 	struct ansilove_png png;
     81 	uint8_t error;
     82 };
     83 
     84 struct ansilove_options {
     85 	bool diz;
     86 	bool dos;
     87 	bool icecolors;
     88 	bool truecolor;
     89 	int16_t columns;
     90 	uint8_t font;
     91 	uint8_t bits;
     92 	uint8_t mode;
     93 	uint8_t scale_factor;
     94 };
     95 
     96 ANSILOVE_EXTERN int	 ansilove_init(struct ansilove_ctx *, struct ansilove_options *);
     97 ANSILOVE_EXTERN char	*ansilove_error(struct ansilove_ctx *);
     98 ANSILOVE_EXTERN int	 ansilove_loadfile(struct ansilove_ctx *, char *);
     99 ANSILOVE_EXTERN int	 ansilove_savefile(struct ansilove_ctx *, char *);
    100 ANSILOVE_EXTERN int	 ansilove_clean(struct ansilove_ctx *);
    101 
    102 ANSILOVE_EXTERN int	 ansilove_ansi(struct ansilove_ctx *, struct ansilove_options *);
    103 ANSILOVE_EXTERN int	 ansilove_artworx(struct ansilove_ctx *, struct ansilove_options *);
    104 ANSILOVE_EXTERN int	 ansilove_binary(struct ansilove_ctx *, struct ansilove_options *);
    105 ANSILOVE_EXTERN int	 ansilove_icedraw(struct ansilove_ctx *, struct ansilove_options *);
    106 ANSILOVE_EXTERN int	 ansilove_pcboard(struct ansilove_ctx *, struct ansilove_options *);
    107 ANSILOVE_EXTERN int	 ansilove_tundra(struct ansilove_ctx *, struct ansilove_options *);
    108 ANSILOVE_EXTERN int	 ansilove_xbin(struct ansilove_ctx *, struct ansilove_options *);
    109 
    110 #endif /* ANSILOVE_H */