libansilove

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

ansilove.h (3383B)


      1 /*
      2  * ansilove.h
      3  * libansilove 1.2.4
      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.4"
     24 
     25 #define ANSILOVE_VERSION_MAJOR		1
     26 #define ANSILOVE_VERSION_MINOR		2
     27 #define ANSILOVE_VERSION_PATCH		4
     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_FILE_READ_ERROR	4
     34 #define ANSILOVE_FILE_WRITE_ERROR	5
     35 #define ANSILOVE_GD_ERROR		6
     36 
     37 /* PC Fonts */
     38 #define ANSILOVE_FONT_CP437		1	/* IBM PC 80x25 */
     39 #define ANSILOVE_FONT_CP437_80x50	2	/* IBM PC 80x50 */
     40 #define ANSILOVE_FONT_CP737		3	/* Greek */
     41 #define ANSILOVE_FONT_CP775		4	/* Baltic */
     42 #define ANSILOVE_FONT_CP850		5	/* Latin 1 */
     43 #define ANSILOVE_FONT_CP852		6	/* Latin 2 */
     44 #define ANSILOVE_FONT_CP855		7	/* Cyrillic */
     45 #define ANSILOVE_FONT_CP857		8	/* Turkish */
     46 #define ANSILOVE_FONT_CP860		9	/* Portuguese */
     47 #define ANSILOVE_FONT_CP861		10	/* Icelandic */
     48 #define ANSILOVE_FONT_CP862		11	/* Hebrew */
     49 #define ANSILOVE_FONT_CP863		12	/* French-canadian */
     50 #define ANSILOVE_FONT_CP865		13	/* Nordic */
     51 #define ANSILOVE_FONT_CP866		14	/* Russian */
     52 #define ANSILOVE_FONT_CP869		15	/* Greek */
     53 #define ANSILOVE_FONT_TERMINUS		20
     54 
     55 /* Amiga fonts */
     56 #define ANSILOVE_FONT_MICROKNIGHT	30
     57 #define ANSILOVE_FONT_MICROKNIGHT_PLUS	31
     58 #define ANSILOVE_FONT_MOSOUL		32
     59 #define ANSILOVE_FONT_POT_NOODLE	33
     60 #define ANSILOVE_FONT_TOPAZ		34
     61 #define ANSILOVE_FONT_TOPAZ_PLUS	35
     62 #define ANSILOVE_FONT_TOPAZ500		36
     63 #define ANSILOVE_FONT_TOPAZ500_PLUS	37
     64 
     65 /* Rendering modes */
     66 #define ANSILOVE_MODE_CED		1
     67 #define ANSILOVE_MODE_TRANSPARENT	2
     68 #define ANSILOVE_MODE_WORKBENCH		3
     69 
     70 struct ansilove_png {
     71 	uint8_t *buffer;
     72 	int length; /* Match the parameter type of gdImagePngPtr() */
     73 };
     74 
     75 struct ansilove_ctx {
     76 	uint8_t *buffer;
     77 	size_t maplen;
     78 	size_t length;
     79 	struct ansilove_png png;
     80 	uint8_t error;
     81 };
     82 
     83 struct ansilove_options {
     84 	bool diz;
     85 	bool dos;
     86 	bool icecolors;
     87 	bool truecolor;
     88 	int16_t columns;
     89 	uint8_t font;
     90 	uint8_t bits;
     91 	uint8_t mode;
     92 	uint8_t scale_factor;
     93 };
     94 
     95 ANSILOVE_EXTERN int	 ansilove_init(struct ansilove_ctx *, struct ansilove_options *);
     96 ANSILOVE_EXTERN char	*ansilove_error(struct ansilove_ctx *);
     97 ANSILOVE_EXTERN int	 ansilove_loadfile(struct ansilove_ctx *, char *);
     98 ANSILOVE_EXTERN int	 ansilove_savefile(struct ansilove_ctx *, char *);
     99 ANSILOVE_EXTERN int	 ansilove_clean(struct ansilove_ctx *);
    100 
    101 ANSILOVE_EXTERN int	 ansilove_ansi(struct ansilove_ctx *, struct ansilove_options *);
    102 ANSILOVE_EXTERN int	 ansilove_artworx(struct ansilove_ctx *, struct ansilove_options *);
    103 ANSILOVE_EXTERN int	 ansilove_binary(struct ansilove_ctx *, struct ansilove_options *);
    104 ANSILOVE_EXTERN int	 ansilove_icedraw(struct ansilove_ctx *, struct ansilove_options *);
    105 ANSILOVE_EXTERN int	 ansilove_pcboard(struct ansilove_ctx *, struct ansilove_options *);
    106 ANSILOVE_EXTERN int	 ansilove_tundra(struct ansilove_ctx *, struct ansilove_options *);
    107 ANSILOVE_EXTERN int	 ansilove_xbin(struct ansilove_ctx *, struct ansilove_options *);
    108 
    109 #endif /* ANSILOVE_H */