libansilove

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

commit 462cae36f7eec9f295e0a11877fc39e1731b7fb3
parent 94addea5baef3eaf816afe0ff3cbb76829b54cff
Author: Frederic Cambus <fred@statdns.com>
Date:   Thu, 18 Oct 2018 15:32:12 +0200

Add an example showing how to use the library

Diffstat:
MREADME.md | 5+++++
Aexample/CMakeLists.txt | 15+++++++++++++++
Aexample/example.c | 17+++++++++++++++++
3 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/README.md b/README.md @@ -41,6 +41,11 @@ The following formats are supported: # Documentation +# Usage + +See the `example` directory for an example showing how to use the library to +convert a file to PNG. + # Who pulls the strings libansilove is developed by Stefan Vogt ([@ByteProject](https://github.com/ByteProject)), Brian Cassidy ([@bricas](https://github.com/bricas)) and Frederic Cambus ([@fcambus](https://github.com/fcambus)). diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required (VERSION 2.6) + +project (example C) + +# Ansilove library +find_path(ANSILOVE_INCLUDE_DIRS ansilove.h) +find_library(ANSILOVE_LIBRARIES NAMES ansilove REQUIRED) +include_directories(${ANSILOVE_INCLUDE_DIRS}) + +set(SRC example.c) + +add_definitions(-Wall -Wextra -std=c99 -pedantic) +add_executable(example ${SRC}) + +target_link_libraries(example ${ANSILOVE_LIBRARIES}) diff --git a/example/example.c b/example/example.c @@ -0,0 +1,17 @@ +#include <ansilove.h> +#include <string.h> + +int main() { + struct ansilove_ctx ctx; + struct ansilove_options options; + + ansilove_init(&ctx, &options); + + ansilove_loadfile(&ctx, "example.c"); + + ansilove_ansi(&ctx, &options); + + ansilove_savefile(&ctx, "example.png"); + + return 0; +}