you can now set the image size in genplot2
This commit is contained in:
parent
5f80203592
commit
35e5947fdb
@ -34,3 +34,7 @@ RANLIB=wc -c
|
|||||||
|
|
||||||
# modify it 'as you like'
|
# modify it 'as you like'
|
||||||
AR=ar
|
AR=ar
|
||||||
|
|
||||||
|
#
|
||||||
|
# and valgrind is your friend
|
||||||
|
#
|
5
Tests/.gitignore
vendored
Normal file
5
Tests/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
a.scratch
|
||||||
|
|
||||||
|
*.tga
|
||||||
|
|
15
Tests/essai_genplot2.sh
Executable file
15
Tests/essai_genplot2.sh
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
echo "------------------------------------------"
|
||||||
|
echo "GO" | ./mk_dessin.awk > a.scratch
|
||||||
|
wc a.scratch
|
||||||
|
|
||||||
|
echo "------------------------------------------"
|
||||||
|
../Tools/genplot2 -s 640x480
|
||||||
|
errcode=$?
|
||||||
|
echo "code retour genplot2 = " $errcode
|
||||||
|
echo "------------------------------------------"
|
||||||
|
|
||||||
|
echo "------------------------------------------"
|
||||||
|
|
27
Tests/mk_dessin.awk
Executable file
27
Tests/mk_dessin.awk
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/awk -f
|
||||||
|
|
||||||
|
# ce joli programme fabrique un fichier de donnees qui sera
|
||||||
|
# utile au bon deroulement de 'essai_genplot2.sh'
|
||||||
|
|
||||||
|
BEGIN { nbretraits = 20000 }
|
||||||
|
|
||||||
|
END {
|
||||||
|
for (trait=0; trait<nbretraits; trait++)
|
||||||
|
{
|
||||||
|
if (0.498 > rand())
|
||||||
|
{
|
||||||
|
posx += rand()
|
||||||
|
posy += rand()
|
||||||
|
print posx, posy, 1
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
posx -= rand()
|
||||||
|
posy -= rand()
|
||||||
|
print posx, posy, 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# job done
|
||||||
|
|
4
Tools/.gitignore
vendored
Normal file
4
Tools/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
*.tga
|
||||||
|
*.scratch
|
||||||
|
|
@ -13,12 +13,14 @@
|
|||||||
/* non portable but useful function */
|
/* non portable but useful function */
|
||||||
char *strdup(const char *s);
|
char *strdup(const char *s);
|
||||||
|
|
||||||
|
#define DEBUG_LEVEL 1
|
||||||
|
|
||||||
#define IN_FONCTION
|
#define IN_FONCTION
|
||||||
#include "tga_outils.h"
|
#include "tga_outils.h"
|
||||||
|
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
int
|
|
||||||
cherche_mot_clef(char *mot, mot_clef *liste, int *pmode, int *pnbarg)
|
int cherche_mot_clef(char *mot, mot_clef *liste, int *pmode, int *pnbarg)
|
||||||
{
|
{
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
|
|
||||||
@ -48,8 +50,7 @@ fprintf(stderr, "%s : %s not found\n", __func__, mot);
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
int
|
int liste_mots_clefs(mot_clef *liste, int flag)
|
||||||
liste_mots_clefs(mot_clef *liste, int flag)
|
|
||||||
{
|
{
|
||||||
mot_clef *pmc;
|
mot_clef *pmc;
|
||||||
|
|
||||||
@ -79,7 +80,7 @@ return 0;
|
|||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
/*
|
/*
|
||||||
* INPUT str string to scan for an integer
|
* INPUT str string to scan for an integer
|
||||||
* pval pointer to the retrun value
|
* pval pointer to the return value
|
||||||
* k * not used *
|
* k * not used *
|
||||||
*
|
*
|
||||||
* OUTPUT 1 successfuly make a conversion
|
* OUTPUT 1 successfuly make a conversion
|
||||||
@ -104,6 +105,31 @@ fprintf(stderr, "%s: %s: '%s' -> %ld -> %d\n",
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*::------------------------------------------------------------------::*/
|
||||||
|
/* Thu 17 Nov 2022
|
||||||
|
* input str a string like '640x480'
|
||||||
|
* pw, ph pointers to result
|
||||||
|
*
|
||||||
|
* output 0 on ok, INVALID_PARAM on error
|
||||||
|
*/
|
||||||
|
int parse_size_param(char *str, int *pw, int *ph)
|
||||||
|
{
|
||||||
|
int tw, th, foo;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' %p %p )\n", __func__,
|
||||||
|
str, pw, ph);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
foo = sscanf(str, "%dx%d", &tw, &th);
|
||||||
|
if (2 != foo) {
|
||||||
|
fprintf(stderr, "%s: fail %d on '%s'\n", __func__, foo, str);
|
||||||
|
return INVALID_PARAM;
|
||||||
|
}
|
||||||
|
/* fprintf(stderr, " %d %d\n", tw, th); */
|
||||||
|
*pw = tw; *ph = th;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
/* input: str string to scan for four csv int
|
/* input: str string to scan for four csv int
|
||||||
prect rectangle struct who need datas
|
prect rectangle struct who need datas
|
||||||
@ -149,14 +175,15 @@ while (NULL != cptr) {
|
|||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(cptr);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
|
|
||||||
static Param params[NB_PARAMS];
|
static Param params[NB_PARAMS];
|
||||||
|
|
||||||
int
|
int parse_parametres(int argc, char *argv[], char *types, int prem)
|
||||||
parse_parametres(int argc, char *argv[], char *types, int prem)
|
|
||||||
{
|
{
|
||||||
int foo, idxt;
|
int foo, idxt;
|
||||||
int entier;
|
int entier;
|
||||||
@ -363,11 +390,11 @@ return params[rang].p.i;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
int
|
static int verboselevel;
|
||||||
must_be_verbose(void)
|
|
||||||
|
int must_be_verbose(void)
|
||||||
{
|
{
|
||||||
char *envvar;
|
char *envvar;
|
||||||
|
|
||||||
envvar = getenv(NOM_VAR_ENV_VERBOSE);
|
envvar = getenv(NOM_VAR_ENV_VERBOSE);
|
||||||
if ((envvar!=NULL) && !strcmp(envvar, "yes"))
|
if ((envvar!=NULL) && !strcmp(envvar, "yes"))
|
||||||
{
|
{
|
||||||
@ -378,9 +405,24 @@ if ((envvar!=NULL) && !strcmp(envvar, "yes"))
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* new Fri 18 Nov 2022 11:48:06 PM CET */
|
||||||
|
|
||||||
|
int set_verbosity(int level)
|
||||||
|
{
|
||||||
|
int tmplevel;
|
||||||
|
|
||||||
|
tmplevel = verboselevel;
|
||||||
|
verboselevel = level;
|
||||||
|
|
||||||
|
return tmplevel;
|
||||||
|
}
|
||||||
|
int get_verbosity(void)
|
||||||
|
{
|
||||||
|
return verboselevel;
|
||||||
|
}
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
int
|
int dump_command_line(int argc, char *argv[], int force)
|
||||||
dump_command_line(int argc, char *argv[], int force)
|
|
||||||
{
|
{
|
||||||
char *envvar;
|
char *envvar;
|
||||||
int flag=0, foo;
|
int flag=0, foo;
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <getopt.h>
|
||||||
|
|
||||||
#include "tga_outils.h"
|
#include "tga_outils.h"
|
||||||
|
|
||||||
@ -63,7 +65,7 @@ RGBA rgba;
|
|||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, "\tDRAW %5d %5d to %5d %5d\n", curX, curY, x, y);
|
fprintf(stderr, "\tdraw %5d %5d to %5d %5d\n", curX, curY, x, y);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
idx = color % 8;
|
idx = color % 8;
|
||||||
@ -88,28 +90,60 @@ Image_TGA_save(filename, image, 0);
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
|
void help_me(char *proggy)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s build %s %s\n", proggy, __DATE__, __TIME__);
|
||||||
|
|
||||||
|
puts("options:");
|
||||||
|
puts("\t-v\t\tdo some blablage");
|
||||||
|
puts("\t-s WxH\t\tset image size");
|
||||||
|
}
|
||||||
|
/*::------------------------------------------------------------------::*/
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *filename, *image;
|
char *filename, *image;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
int outw, outh; /* size of output pic */
|
||||||
double x, y, xmin, ymin, xmax, ymax;
|
double x, y, xmin, ymin, xmax, ymax;
|
||||||
double fx, fy, f, X, Y;
|
double fx, fy, f, X, Y;
|
||||||
double xC, yC, XC, YC, c1, c2;
|
double xC, yC, XC, YC, c1, c2;
|
||||||
|
int v, nbp, opt, foo;
|
||||||
|
|
||||||
int v, nbp;
|
/* setting some default values */
|
||||||
|
|
||||||
|
outw = XMAX; outh = YMAX;
|
||||||
|
filename = "a.scratch"; image = "image.tga";
|
||||||
|
|
||||||
/*---------- processing command line arguments */
|
/*---------- processing command line arguments */
|
||||||
|
|
||||||
if (argc<=1) filename = "a.scratch";
|
while ((opt = getopt(argc, argv, "hs:v")) != -1) {
|
||||||
else filename = argv[1];
|
switch (opt) {
|
||||||
|
case 'h':
|
||||||
|
help_me(argv[0]);
|
||||||
|
exit(0);
|
||||||
|
case 's': /* size of output pic */
|
||||||
|
foo = parse_size_param(optarg, &outw, &outh);
|
||||||
|
break;
|
||||||
|
case 'v':
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "invalid opt %d\n", opt);
|
||||||
|
exit(1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (argc<=optind) filename = "a.scratch";
|
||||||
|
else filename = argv[optind];
|
||||||
|
|
||||||
if (argc<=2) image = "image.tga";
|
if (argc<=optind+1) image = "image.tga";
|
||||||
else image = argv[2];
|
else image = argv[optind+1];
|
||||||
|
|
||||||
|
fprintf(stderr, "argc %d optind %d file '%s' image '%s'\n",
|
||||||
|
argc, optind, filename, image);
|
||||||
/*----------- 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.8 (dwtfywl) 1995,2010,2022 TontonTh \n");
|
fprintf(stderr, "*** Genplot2 v 1.0.9 (dwtfywl) 1995,2010,2022 TontonTh \n");
|
||||||
fprintf(stderr, "hardcoded picsize : %d %d\n", XMAX, YMAX);
|
fprintf(stderr, " picsize : %d %d\n", outw, outh);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*----------- opening input file and getting MIN and MAX values */
|
/*----------- opening input file and getting MIN and MAX values */
|
||||||
@ -137,20 +171,26 @@ if (nbp == 0)
|
|||||||
fprintf(stderr, "omg, I'v found _ZERO_ points for plotting...\n");
|
fprintf(stderr, "omg, I'v found _ZERO_ points for plotting...\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
if (nbp == 1)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "omg, I can't do any job with only one point.\n");
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fprintf(stderr, "Genplot2: found %d points\n", nbp);
|
fprintf(stderr, "Genplot2: found %d points\n", nbp);
|
||||||
|
|
||||||
/*---------- computing coefficients (temporary hack !-) */
|
/*---------- computing coefficients (temporary hack !-) */
|
||||||
|
|
||||||
fx = (XMAX-XMIN-1)/(xmax-xmin);
|
fx = (outw-XMIN-1)/(xmax-xmin);
|
||||||
fy = (YMAX-YMIN-1)/(ymax-ymin);
|
fy = (outh-YMIN-1)/(ymax-ymin);
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, "fc = %12f fy = %12f\n", fx, fy);
|
fprintf(stderr, "fc = %12f fy = %12f\n", fx, fy);
|
||||||
#endif
|
#endif
|
||||||
f = (fx<fy?fx:fy);
|
f = (fx<fy?fx:fy);
|
||||||
|
|
||||||
xC = 0.5*(xmin+xmax); yC = 0.5*(ymin+ymax);
|
xC = 0.5*(xmin+xmax); yC = 0.5*(ymin+ymax);
|
||||||
XC = 0.5*(XMIN+XMAX); YC = 0.5*(YMIN+YMAX);
|
XC = 0.5*(XMIN+outw); YC = 0.5*(YMIN+outh);
|
||||||
|
|
||||||
c1 = XC-f*xC; c2 = YC-f*yC;
|
c1 = XC-f*xC; c2 = YC-f*yC;
|
||||||
|
|
||||||
@ -159,7 +199,7 @@ fprintf(stderr, "c1 = %12f c2 = %12f\n", c1, c2);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*------------- and now, plotting the image ! */
|
/*------------- and now, plotting the image ! */
|
||||||
initgr(XMAX, YMAX);
|
initgr(outw, outh);
|
||||||
|
|
||||||
fp = fopen(filename, "r");
|
fp = fopen(filename, "r");
|
||||||
puts("");
|
puts("");
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
* 27 Dec 2009: v0.42 prise en compte des champs d'altitude.
|
* 27 Dec 2009: v0.42 prise en compte des champs d'altitude.
|
||||||
* 06 Mar 2010: v0.43 introduction du 'df3 tool'.
|
* 06 Mar 2010: v0.43 introduction du 'df3 tool'.
|
||||||
* 27 Jan 2014: V0.52 added : 'parse_rect_param'.
|
* 27 Jan 2014: V0.52 added : 'parse_rect_param'.
|
||||||
|
* 18 Nov 2022: Vx.xx added parse_size_param
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TGA_OUTILS_COPYLEFT "(dwtfywl) TontonTh 2022"
|
#define TGA_OUTILS_COPYLEFT "(dwtfywl) TontonTh 2022"
|
||||||
@ -74,8 +75,12 @@ int cherche_mot_clef(char *mot, mot_clef *liste, int *pmode, int *pnbarg);
|
|||||||
/* le flag ne sert a rien, mais il faut le mettre a 42 */
|
/* le flag ne sert a rien, mais il faut le mettre a 42 */
|
||||||
int liste_mots_clefs(mot_clef *liste, int flag);
|
int liste_mots_clefs(mot_clef *liste, int flag);
|
||||||
|
|
||||||
|
int get_verbosity(void);
|
||||||
|
int set_verbosity(int level);
|
||||||
|
|
||||||
int parse_int_param(char *str, int *pval, int k);
|
int parse_int_param(char *str, int *pval, int k);
|
||||||
int parse_rect_param(char *str, Image_Rect *prect, int k);
|
int parse_rect_param(char *str, Image_Rect *prect, int k);
|
||||||
|
int parse_size_param(char *str, int *pw, int *ph);
|
||||||
|
|
||||||
int parse_parametres(int ac, char *av[], char *types, int prem);
|
int parse_parametres(int ac, char *av[], char *types, int prem);
|
||||||
void print_parametres(void);
|
void print_parametres(void);
|
||||||
|
@ -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 39"
|
#define IMAGE_VERSION_STRING "0.4.51 pl 41"
|
||||||
|
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user