libansilove

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

commit d539e25365dfc3a96519831cd50715c08d6ea066
parent c71865eec0e8516aeda4e873b6e1822f8413ccc3
Author: Frederic Cambus <fred@statdns.com>
Date:   Thu,  3 Oct 2019 22:26:45 +0200

Group gdImageDestroy() calls, makes code easier to read.

Diffstat:
Msrc/output.c | 9+++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/output.c b/src/output.c @@ -27,6 +27,7 @@ output(struct ansilove_ctx *ctx, struct ansilove_options *options, gdImageColorTransparent(im_Source, 0); ctx->png.buffer = gdImagePngPtr(im_Source, &ctx->png.length); + gdImageDestroy(im_Source); } else if (options->dos) { gdImagePtr im_DOS; @@ -42,9 +43,9 @@ output(struct ansilove_ctx *ctx, struct ansilove_options *options, gdImageCopyResampled(im_DOS, im_Source, 0, 0, 0, 0, im_DOS->sx, im_DOS->sy, im_Source->sx, im_Source->sy); - gdImageDestroy(im_Source); - ctx->png.buffer = gdImagePngPtr(im_DOS, &ctx->png.length); + + gdImageDestroy(im_Source); gdImageDestroy(im_DOS); } else { gdImagePtr im_Retina; @@ -61,12 +62,12 @@ output(struct ansilove_ctx *ctx, struct ansilove_options *options, im_Retina->sx, im_Retina->sy, im_Source->sx, im_Source->sy); /* create retina output image */ - gdImageDestroy(im_Source); - if (options->mode == ANSILOVE_MODE_TRANSPARENT) gdImageColorTransparent(im_Retina, 0); ctx->png.buffer = gdImagePngPtr(im_Retina, &ctx->png.length); + + gdImageDestroy(im_Source); gdImageDestroy(im_Retina); }