commit 76d72fc48dc88fac4faa8b0b3907679eb8555778
Author: Mike Swanson <mikeonthecomputer@gmail.com>
AuthorDate: Thu Jul 27 18:42:28 2017 -0700
Commit: Mike Swanson <mikeonthecomputer@gmail.com>
CommitDate: Thu Jul 27 23:30:21 2017 -0700
Write an aspect-correct PNG only if aspect_ratio_correct is set.
---
src/v_video.c | 43 +++++++++++++++++++++++++++++++++----------
1 file changed, 33 insertions(+), 10 deletions(-)
diff --git a/src/v_video.c b/src/v_video.c
index 7c34fca6..b9a07c77 100644
--- a/src/v_video.c
+++ b/src/v_video.c
@@ -736,9 +736,17 @@ void WritePNGfile(char *filename, byte *data,
int width, height;
byte *rowbuf;
- // scale up to accommodate aspect ratio correction
- width = inwidth * 5;
- height = inheight * 6;
+ if (aspect_ratio_correct)
+ {
+ // scale up to accommodate aspect ratio correction
+ width = inwidth * 5;
+ height = inheight * 6;
+ }
+ else
+ {
+ width = inwidth;
+ height = inheight;
+ }
handle = fopen(filename, "wb");
if (!handle)
@@ -789,17 +797,32 @@ void WritePNGfile(char *filename, byte *data,
if (rowbuf)
{
- for (i = 0; i < SCREENHEIGHT; i++)
+ if (aspect_ratio_correct)
{
- // expand the row 5x
- for (j = 0; j < SCREENWIDTH; j++)
+ for (i = 0; i < SCREENHEIGHT; i++)
{
- memset(rowbuf + j * 5, *(data + i*SCREENWIDTH + j), 5);
+ // expand the row 5x
+ for (j = 0; j < SCREENWIDTH; j++)
+ {
+ memset(rowbuf + j * 5, *(data + i*SCREENWIDTH + j), 5);
+ }
+
+ // write the row 6 times
+ for (j = 0; j < 6; j++)
+ {
+ png_write_row(ppng, rowbuf);
+ }
}
-
- // write the row 6 times
- for (j = 0; j < 6; j++)
+ }
+ else
+ {
+ for (i = 0; i < SCREENHEIGHT; i++)
{
+ for (j = 0; j < SCREENWIDTH; j++)
+ {
+ memset(rowbuf + j, *(data + i*SCREENWIDTH + j), 1);
+ }
+
png_write_row(ppng, rowbuf);
}
}