shootgun debug session #539

This commit is contained in:
tTh 2022-12-19 13:54:39 +01:00
parent c1c954100e
commit 00e796bf5e
4 changed files with 53 additions and 8 deletions

View File

@ -62,6 +62,23 @@ for ( x=0; x<y; ) {
return FUNC_NOT_FINISH; return FUNC_NOT_FINISH;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* New Mon 19 Dec 2022 12:56:44 PM CET */
int Image_H_line(Image_Desc *i, int xa, int xb, int ypos, RGBA *col)
{
int ix;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %d %d %d %p )\n", __func__, xa, xb, ypos, col);
#endif
if (xa > xb) { ix=xa, xa=xb, xb=ix; }
for (ix=xa; ix<xb; ix++) {
Image_plotRGB(i, ix, ypos, col->r, col->g, col->b);
}
return FUNC_IS_ALPHA;
}
/*::------------------------------------------------------------------::*/
/* /*
* l'appel a la fonction isign devrait disparaitre pour optimiser * l'appel a la fonction isign devrait disparaitre pour optimiser
* la vitesse du bouzin. * la vitesse du bouzin.
@ -158,7 +175,6 @@ return 0;
### ###
### THERE IS A OFF-BY-ONE IN THIS FUNCTION ! ### 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) 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. * kikoo lol a tous les goret-codeurs, et en particulier Mr Spleyt.
*/ */

16
Tools/essayage.sh Executable file
View File

@ -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

View File

@ -20,6 +20,7 @@
static Image_Desc *image; static Image_Desc *image;
static RGB_map map; static RGB_map map;
static int curX, curY; static int curX, curY;
static int verbeux;
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int initgr(int largeur, int hauteur) int initgr(int largeur, int hauteur)
{ {
@ -30,7 +31,7 @@ if (NULL==(image=Image_alloc(largeur, hauteur, 3))) {
exit(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++) { for (foo=0; foo<8; foo++) {
#if DEBUG_LEVEL #if DEBUG_LEVEL
printf("\tPal(%d) = ", foo); printf("\tPal(%d) = ", foo);
@ -58,7 +59,7 @@ fprintf(stderr, "\tMOVE %5d %5d\n", x, y);
curX = x; curY = y; curX = x; curY = y;
return 0; return 0;
} }
/*::------------------------------------------------------------------::*/
int draw(int x, int y, int color) int draw(int x, int y, int color)
{ {
RGBA rgba; RGBA rgba;
@ -76,7 +77,16 @@ if (idx != color) {
rgba.r = map.red[color]; rgba.r = map.red[color];
rgba.g = map.green[color]; rgba.g = map.green[color];
rgba.b = map.blue[color]; rgba.b = map.blue[color];
/* 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); Image_draw_line(image, curX, curY, x, y, &rgba);
}
curX = x; curY = y; curX = x; curY = y;
return 0; return 0;
} }
@ -84,7 +94,7 @@ return 0;
int endgr(char *filename) 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); Image_TGA_save(filename, image, 0);
return 0; return 0;
@ -125,6 +135,7 @@ while ((opt = getopt(argc, argv, "hs:v")) != -1) {
foo = parse_size_param(optarg, &outw, &outh); foo = parse_size_param(optarg, &outw, &outh);
break; break;
case 'v': case 'v':
verbeux = 1;
break; break;
default: default:
fprintf(stderr, "invalid opt %d\n", opt); fprintf(stderr, "invalid opt %d\n", opt);
@ -138,8 +149,11 @@ else filename = argv[optind];
if (argc<=optind+1) image = "image.tga"; if (argc<=optind+1) image = "image.tga";
else image = argv[optind+1]; else image = argv[optind+1];
if (verbeux) {
fprintf(stderr, "argc %d optind %d file '%s' image '%s'\n", fprintf(stderr, "argc %d optind %d file '%s' image '%s'\n",
argc, optind, filename, image); argc, optind, filename, image);
fprintf(stderr, " picsize : %d %d\n", outw, outh);
}
/*----------- giving to the yuser some useless informations --- */ /*----------- giving to the yuser some useless informations --- */
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "*** Genplot2 v 1.0.9 (dwtfywl) 1995,2010,2022 TontonTh \n"); fprintf(stderr, "*** Genplot2 v 1.0.9 (dwtfywl) 1995,2010,2022 TontonTh \n");

View File

@ -4,7 +4,7 @@
http:///la.buvette.org/devel/libimage/ http:///la.buvette.org/devel/libimage/
*/ */
#ifndef IMAGE_VERSION_STRING #ifndef IMAGE_VERSION_STRING
#define IMAGE_VERSION_STRING "0.4.51 pl 41" #define IMAGE_VERSION_STRING "0.4.51 pl 43"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*