Giter Club home page Giter Club logo

libansilove's Introduction

libansilove

libansilove is a library to convert ANSi and artscene related file formats into PNG images.

Dependencies

libansilove uses the CMake build system and requires the GD library and header files.

Installing dependencies

  • OpenBSD: pkg_add -r cmake gd
  • NetBSD: pkgin install cmake gd
  • FreeBSD: pkg install cmake gd
  • macOS: brew install cmake gd
  • Alpine Linux: apk add cmake gcc make musl-dev gd-dev
  • Debian / Ubuntu / Mint: apt-get install build-essential cmake libgd-dev
  • Fedora: dnf install cmake gcc make gd-devel
  • Solus: eopkg install -c system.devel and eopkg install gd-devel

Compiling

mkdir build
cd build
cmake ..
make

Installation

make install

Packages

libansilove packages are available for:

Features

The following formats are supported:

  • .ANS - ANSi (ANSI escape sequences: ANSI X3.64 standard)
  • .PCB - PCBoard Bulletin Board System (BBS) own file format
  • .BIN - Binary format (raw memory copy of text mode video memory)
  • .ADF - Artworx format, supporting custom character sets and palettes
  • .IDF - iCE Draw format, supporting custom character sets and palettes
  • .TND - TundraDraw format, supporting 24-bit color mode
  • .XB - The eXtended Binary XBin format, supporting custom character sets and palettes

Documentation

Usage

See the example directory for an example showing how to use the library to convert a file to PNG.

Projects using libansilove

  • Ansilove - ASCII / ANSI art to PNG converter, also supporting several artscene file formats
  • ANSi View (PS3) - ANSi and artscene related file formats viewer for the PlayStation 3

Bindings

Bindings for other programming languages:

License

libansilove is released under the BSD 2-Clause license. See the file LICENSE for details.

Authors

libansilove is developed by Stefan Vogt (@ByteProject), Brian Cassidy (@bricas) and Frederic Cambus (@fcambus).

Resources

Project homepage: https://www.ansilove.org

GitHub: https://github.com/ansilove/libansilove

libansilove's People

Contributors

andyherbert avatar bricas avatar ddeka2910 avatar fcambus avatar jan2642 avatar kirkman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

libansilove's Issues

Support for blinking ANSI art

The recent Fire pack contained a piece by ResetSurvivor which took advantage of blinking text. Libansilove doesn't support blinking text however PNGs support animation, see attached image
348497555-52cbdb00-f5e9-4c0e-86a9-a6cb44bcb9e1

xterm-256color support

It would be nice for libansilove to support these escape codes for the xterm-256color palette.

Examples of ANSI editors that export ANSI to this format include Durdraw, which also does Ansilove exporting. This would allow Durdraw to export PNG and GIF files in 256 color, instead of just 16 color. This would also allow sites like 16colo.rs to view these files correctly.

I am looking at the source code... I think the trick would be something like:

1: In config.h: Add the xterm-256color palette as 8-bit hex values
2: In ansi.c: Add interpreters for the 256 color escape codes, the palette generator, and any other logic to deal with color values larger than 16.
3: ???
4: profit!

If I get some time I will give it a try, or if someone else wants to. This can probably be considered a duplicate of issue ansilove/ansilove#43.

Thanks!

A Segmentation fault

just as pic show

the pic

when the libansilove parser crafted file, it will cause a OOB if the seqTok assignned wrong

as the valgrind detect, there is a "Invalid read"

root@Starry:~/fuzz/ansilove# valgrind ./ansilove -i poc.ans
==30030== Memcheck, a memory error detector
==30030== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==30030== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==30030== Command: ./ansilove -i poc.ans
==30030==
AnsiLove/C 3.0.9 - ANSI / ASCII art to PNG converter
Copyright (c) 2011-2018 Stefan Vogt, Brian Cassidy, and Frederic Cambus.
==30030== Invalid read of size 1
==30030== at 0x50F9570: __strcmp_sse2_unaligned (strcmp-sse2-unaligned.S:24)
==30030== by 0x4023C0: main (main.c:238)
==30030== Address 0x81a82b0 is 0 bytes inside a block of size 144 free'd
==30030== at 0x4C2EDEB: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==30030== by 0x4051E6: sauceReadFile (sauce.c:34)
==30030== by 0x4051E6: sauceReadFileName (sauce.c:22)
==30030== by 0x40236F: main (main.c:230)
==30030== Block was alloc'd at
==30030== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==30030== by 0x405198: sauceReadFile (sauce.c:31)
==30030== by 0x405198: sauceReadFileName (sauce.c:22)
==30030== by 0x40236F: main (main.c:230)
==30030==

Input File: poc.ans
Output File: poc.ans.png
==30030== Conditional jump or move depends on uninitialised value(s)
==30030== at 0x4E3D5B4: ansilove_ansi (in /usr/local/lib/libansilove.so.1.0.0)
==30030== by 0x4038A2: main (main.c:304)
==30030==
==30030== Invalid read of size 1
==30030== at 0x5095454: ____strtol_l_internal (strtol_l.c:293)
==30030== by 0x405D0F: strtonum (strtonum.c:50)
==30030== by 0x4E3D481: ansilove_ansi (in /usr/local/lib/libansilove.so.1.0.0)
==30030== by 0x4038A2: main (main.c:304)
==30030== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==30030==
==30030==
==30030== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==30030== Access not within mapped region at address 0x0
==30030== at 0x5095454: ____strtol_l_internal (strtol_l.c:293)
==30030== by 0x405D0F: strtonum (strtonum.c:50)
==30030== by 0x4E3D481: ansilove_ansi (in /usr/local/lib/libansilove.so.1.0.0)
==30030== by 0x4038A2: main (main.c:304)
==30030== If you believe this happened as a result of a stack
==30030== overflow in your program's main thread (unlikely but
==30030== possible), you can try to increase the size of the
==30030== main thread stack using the --main-stacksize= flag.
==30030== The main thread stack size used in this run was 8388608.
==30030==
==30030== HEAP SUMMARY:
==30030== in use at exit: 3,361 bytes in 4 blocks
==30030== total heap usage: 232 allocs, 228 frees, 285,685 bytes allocated
==30030==
==30030== LEAK SUMMARY:
==30030== definitely lost: 0 bytes in 0 blocks
==30030== indirectly lost: 0 bytes in 0 blocks
==30030== possibly lost: 0 bytes in 0 blocks
==30030== still reachable: 3,361 bytes in 4 blocks
==30030== suppressed: 0 bytes in 0 blocks
==30030== Rerun with --leak-check=full to see details of leaked memory
==30030==
==30030== For counts of detected and suppressed errors, rerun with: -v
==30030== Use --track-origins=yes to see where uninitialised values come from
==30030== ERROR SUMMARY: 169 errors from 3 contexts (suppressed: 0 from 0)
Segmentation fault

poc

How to compile the static library libansilove.a

I have libgd and all of its dependencies statically built and are correctly found and used by cmake when building the default shared library libansilove.so

How can i build the static library libansilove.a in order to build a static standalone ansilove binary?

Mac error: 'ansilove.h' file not found with <angled> include

Trying to build this on a Mac resulted in error output full of this message repeated:

In file included from /Users/kirkman/Sites/libansilove/src/output.h:15:
In file included from /Users/kirkman/Sites/libansilove/src/ansilove.h:16:
/Users/kirkman/Sites/libansilove/src/output.h:15:10: error: 'ansilove.h' file not found with <angled> include; use "quotes" instead
#include <ansilove.h>
         ^~~~~~~~~~~~
         "ansilove.h"

Changing #include <ansilove.h> to #include "../include/ansilove.h" in both output.h and output.c seems to have made it compile successfully. I have no idea why that worked.

Anyway, just wanted to point out that the project is not building on my Mac as it exists in the repo right now.

libansilove ported to PS3

Hello! thanks for your work on libansilove !

not really an issue, but I wanted to let you know that I've forked libansilove and built a wrapper to create ARGB textures (instead of .png files) to use them directly on the PlayStation 3.

Based on the generated ansi textures, I built an ANSi Viewer for the PS3: https://github.com/bucanero/ansiview-ps3

The app supports browsing and viewing local files, and also browse the complete archive from 16colo.rs πŸ˜„

cheers!

Inferring font height for XBins with no font data

Quick question regarding your interpretation on parsing XBins with no font data, should not he font height byte be set to 16 or 0?

This is sort of an academic point, because I believe that PD saves font data for all XBins, but I’d thought I’d ask because ansilove fails when it’s 0, but PD loads it successfully because it infers the 8x16 CP437 font.

Port to Python

Hello,

I have ported your project to Python.

I would like to take this opportunity to thank you for the project. It is fantastic in image creation and remains absolutely faithful to the original.

The port aims to be as faithful as possible to your code. However, the GD library has been replaced with Pillow, and although the speed will never match that of C, it is acceptable.

https://github.com/BakasuraRCE/pyansilove

Regards.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.