From 00e796bf5eee7d1161a191d2bc0aa6a1970bef59 Mon Sep 17 00:00:00 2001 From: tTh Date: Mon, 19 Dec 2022 13:54:39 +0100 Subject: [PATCH] shootgun debug session #539 --- Lib/drawing.c | 19 +++++++++++++++++-- Tools/essayage.sh | 16 ++++++++++++++++ Tools/genplot2.c | 24 +++++++++++++++++++----- tthimage.h | 2 +- 4 files changed, 53 insertions(+), 8 deletions(-) create mode 100755 Tools/essayage.sh diff --git a/Lib/drawing.c b/Lib/drawing.c index 3db9c13..096bb56 100644 --- a/Lib/drawing.c +++ b/Lib/drawing.c @@ -62,6 +62,23 @@ for ( x=0; x>> %s ( %d %d %d %p )\n", __func__, xa, xb, ypos, col); +#endif + +if (xa > xb) { ix=xa, xa=xb, xb=ix; } + +for (ix=xa; ixr, col->g, col->b); + } +return FUNC_IS_ALPHA; +} +/*::------------------------------------------------------------------::*/ /* * l'appel a la fonction isign devrait disparaitre pour optimiser * la vitesse du bouzin. @@ -158,7 +175,6 @@ return 0; ### ### THERE IS A OFF-BY-ONE IN THIS FUNCTION ! ### - */ int Image_draw_rect(Image_Desc *img, Image_Rect *rect, int r, int g, int b) { @@ -223,4 +239,3 @@ return FUNC_IS_BETA; /* * kikoo lol a tous les goret-codeurs, et en particulier Mr Spleyt. */ - diff --git a/Tools/essayage.sh b/Tools/essayage.sh new file mode 100755 index 0000000..74a6de6 --- /dev/null +++ b/Tools/essayage.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +make genplot2 + +cat > a.scratch << __EOT__ + 0 0 0 +320 0 2 +320 240 2 + 0 240 2 + 0 0 2 +320 240 7 +__EOT__ + +./genplot2 -v -s 640x480 a.scratch foo.tga \ No newline at end of file diff --git a/Tools/genplot2.c b/Tools/genplot2.c index e63667b..752b76e 100644 --- a/Tools/genplot2.c +++ b/Tools/genplot2.c @@ -20,6 +20,7 @@ static Image_Desc *image; static RGB_map map; static int curX, curY; +static int verbeux; /*::------------------------------------------------------------------::*/ int initgr(int largeur, int hauteur) { @@ -30,7 +31,7 @@ if (NULL==(image=Image_alloc(largeur, hauteur, 3))) { exit(3); } -printf("Genplot2: initgr %d %d\n", largeur, hauteur); +if (verbeux) fprintf(stderr, "Genplot2: initgr %d %d\n", largeur, hauteur); for (foo=0; foo<8; foo++) { #if DEBUG_LEVEL printf("\tPal(%d) = ", foo); @@ -58,7 +59,7 @@ fprintf(stderr, "\tMOVE %5d %5d\n", x, y); curX = x; curY = y; return 0; } - +/*::------------------------------------------------------------------::*/ int draw(int x, int y, int color) { RGBA rgba; @@ -76,7 +77,16 @@ if (idx != color) { rgba.r = map.red[color]; rgba.g = map.green[color]; rgba.b = map.blue[color]; -Image_draw_line(image, curX, curY, x, y, &rgba); + +/* new Mon 19 Dec 2022 12:53:32 PM CET + check for special cases: eg horizontal lines +*/ +if (y == curY) { + Image_H_line(image, curX, x, y, &rgba); + } +else { + Image_draw_line(image, curX, curY, x, y, &rgba); + } curX = x; curY = y; return 0; } @@ -84,7 +94,7 @@ return 0; int endgr(char *filename) { -fprintf(stderr, "genplot2 is saving to '%s'\n", filename); +if (verbeux) fprintf(stderr, "genplot2 is saving to '%s'\n", filename); Image_TGA_save(filename, image, 0); return 0; @@ -125,6 +135,7 @@ while ((opt = getopt(argc, argv, "hs:v")) != -1) { foo = parse_size_param(optarg, &outw, &outh); break; case 'v': + verbeux = 1; break; default: fprintf(stderr, "invalid opt %d\n", opt); @@ -138,8 +149,11 @@ else filename = argv[optind]; if (argc<=optind+1) image = "image.tga"; else image = argv[optind+1]; -fprintf(stderr, "argc %d optind %d file '%s' image '%s'\n", +if (verbeux) { + fprintf(stderr, "argc %d optind %d file '%s' image '%s'\n", argc, optind, filename, image); + fprintf(stderr, " picsize : %d %d\n", outw, outh); + } /*----------- giving to the yuser some useless informations --- */ #if DEBUG_LEVEL fprintf(stderr, "*** Genplot2 v 1.0.9 (dwtfywl) 1995,2010,2022 TontonTh \n"); diff --git a/tthimage.h b/tthimage.h index d963d21..ffc131f 100644 --- a/tthimage.h +++ b/tthimage.h @@ -4,7 +4,7 @@ http:///la.buvette.org/devel/libimage/ */ #ifndef IMAGE_VERSION_STRING - #define IMAGE_VERSION_STRING "0.4.51 pl 41" + #define IMAGE_VERSION_STRING "0.4.51 pl 43" /*::------------------------------------------------------------------::*/ /*