From 958bb69e011c53af2851b4959b1ef62cfe06347b Mon Sep 17 00:00:00 2001 From: Vincent Loh Date: Sun, 1 Sep 2024 08:34:22 -0400 Subject: [PATCH] fix resize behavior --- fbpdf.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/fbpdf.c b/fbpdf.c index 446d23d..09c55e2 100644 --- a/fbpdf.c +++ b/fbpdf.c @@ -185,8 +185,13 @@ static int rmargin(void) int i, j; for (i = 0; i < prows; i++) { j = pcols - 1; - while (j > ret && pbuf[i * pcols + j] == FB_VAL(255, 255, 255)) - j--; + if(invert){ + while (j > ret && (pbuf[i * pcols + j] ^ 0xffffffff) == FB_VAL(255, 255, 255)) + j--; + }else{ + while (j > ret && pbuf[i * pcols + j] == FB_VAL(255, 255, 255)) + j--; + } if (ret < j) ret = j; } @@ -199,8 +204,13 @@ static int lmargin(void) int i, j; for (i = 0; i < prows; i++) { j = 0; - while (j < ret && pbuf[i * pcols + j] == FB_VAL(255, 255, 255)) - j++; + if(invert){ + while (j < ret && (pbuf[i * pcols + j] ^ 0xffffffff) == FB_VAL(255, 255, 255)) + j++; + }else{ + while (j < ret && pbuf[i * pcols + j] == FB_VAL(255, 255, 255)) + j++; + } if (ret > j) ret = j; } @@ -358,6 +368,7 @@ static char *usage = int main(int argc, char *argv[]) { + invert = 1; int i = 1; if (argc < 2) { puts(usage);