commit 9bd2b0166f5cdfb524aaba856bbe36f3afe46600
parent 3b35c5e424b083d44f4fd88a3323a696d5e2941d
Author: Frederic Cambus <fred@statdns.com>
Date: Wed, 24 Oct 2018 14:52:31 +0200
Create DOS aspect ratio in a single pass, this makes things faster, uses less RAM, and output is similar
Diffstat:
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/src/output.c b/src/output.c
@@ -20,25 +20,16 @@ int output(struct ansilove_ctx *ctx, struct ansilove_options *options, gdImagePt
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);
+ im_DOS = gdImageCreateTrueColor(im_Source->sx,
+ im_Source->sy * 1.35);
- gdImageCopyResized(im_Resize, im_Source, 0, 0, 0, 0,
- im_Resize->sx, im_Resize->sy, im_Source->sx, im_Source->sy);
+ gdImageCopyResampled(im_DOS, im_Source, 0, 0, 0, 0,
+ im_DOS->sx, im_DOS->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;