libansilove

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

ansilove.h (3540B)


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