libansilove

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

commit 1e7a7d41b4b80cc46b2be3f8a5800e6e1657917c
parent 8a9349ad65dabe1dec7ee7c345781ec3c6bc3b26
Author: Frederic Cambus <fred@statdns.com>
Date:   Wed, 26 Sep 2018 18:55:50 +0200

Modify the output function to allow creating output using DOS aspect ratio. Thanks to Nail/Fire for the suggestions and tips!

Diffstat:
Msrc/output.c | 24+++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/output.c b/src/output.c @@ -15,9 +15,31 @@ int output(struct ansilove_ctx *ctx, struct ansilove_options *options, gdImagePtr im_Source) { // XXX Error handling // XXX The caller must invoke gdFree() + // XXX Allow combining DOS aspect ratio and Retina - if (!options->retinaScaleFactor) { + if (!options->retinaScaleFactor && !options->dos) { ctx->png.buffer = gdImagePngPtr(im_Source, &ctx->png.length); + } else if (options->dos) { + gdImagePtr im_Resize; + gdImagePtr im_DOS; + + im_Resize = gdImageCreate(im_Source->sx, + im_Source->sy * 27); + + gdImageCopyResized(im_Resize, im_Source, 0, 0, 0, 0, + im_Resize->sx, im_Resize->sy, im_Source->sx, im_Source->sy); + + gdImageDestroy(im_Source); + + im_DOS = gdImageCreateTrueColor(im_Resize->sx, + im_Resize->sy / 20); + + gdImageCopyResampled(im_DOS, im_Resize, 0, 0, 0, 0, + im_DOS->sx, im_DOS->sy, im_Resize->sx, im_Resize->sy); + + gdImageDestroy(im_Resize); + + ctx->png.buffer = gdImagePngPtr(im_DOS, &ctx->png.length); } else { gdImagePtr im_Retina;