"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "h5topng.c" between
h5utils-1.13.1.tar.gz and h5utils-1.13.2.tar.gz

About: h5utils is a set of utilities for visualization and conversion of scientific data in the free, portable HDF5 format.

h5topng.c  (h5utils-1.13.1):h5topng.c  (h5utils-1.13.2)
/* Copyright (c) 1999-2017 Massachusetts Institute of Technology /* Copyright (c) 1999-2023 Massachusetts Institute of Technology
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including * "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish, * without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to * distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to * permit persons to whom the Software is furnished to do so, subject to
* the following conditions: * the following conditions:
* *
* The above copyright notice and this permission notice shall be * The above copyright notice and this permission notice shall be
skipping to change at line 44 skipping to change at line 44
#include "writepng.h" #include "writepng.h"
#include "h5utils.h" #include "h5utils.h"
#define CHECK(cond, msg) { if (!(cond)) { fprintf(stderr, "h5topng error: %s\n", msg); exit(EXIT_FAILURE); } } #define CHECK(cond, msg) { if (!(cond)) { fprintf(stderr, "h5topng error: %s\n", msg); exit(EXIT_FAILURE); } }
#define CMAP_DEFAULT "gray" #define CMAP_DEFAULT "gray"
#define OVERLAY_CMAP_DEFAULT "yellow" #define OVERLAY_CMAP_DEFAULT "yellow"
#define OVERLAY_OPACITY_DEFAULT 0.2 #define OVERLAY_OPACITY_DEFAULT 0.2
#define CMAP_DIR DATADIR "/" PACKAGE_NAME "/colormaps/" #define CMAP_DIR DATADIR "/" PACKAGE_NAME "/colormaps/"
#if defined(HAVE_WORDEXP) && defined(HAVE_WORDEXP_H)
# include <wordexp.h>
#endif
/* shell expansion on a path, used for CMAP_DIR */
char *shell_expand(const char *path)
{
#if defined(HAVE_WORDEXP) && defined(HAVE_WORDEXP_H)
wordexp_t p;
char *newpath;
wordexp(path, &p, 0);
newpath = my_strdup(p.we_wordc == 1 ? p.we_wordv[0] : path);
wordfree(&p);
return newpath;
#else
return my_strdup(path);
#endif
}
void usage(FILE *f) void usage(FILE *f)
{ {
fprintf(f, "Usage: h5topng [options] [<filenames>]\n" fprintf(f, "Usage: h5topng [options] [<filenames>]\n"
"Options:\n" "Options:\n"
" -h : this help message\n" " -h : this help message\n"
" -V : print version number and copyright\n" " -V : print version number and copyright\n"
" -v : verbose output\n" " -v : verbose output\n"
" -o <file> : output to <file> (first input file only)\n" " -o <file> : output to <file> (first input file only)\n"
" -x <ix> : take x=<ix> slice of data (or <min>:<inc>:<max>)\n" " -x <ix> : take x=<ix> slice of data (or <min>:<inc>:<max>)\n"
" -y <iy> : take y=<iy> slice of data\n" " -y <iy> : take y=<iy> slice of data\n"
skipping to change at line 138 skipping to change at line 157
colormap_t c; colormap_t c;
int i; int i;
c.n = c0.n; c.n = c0.n;
c.rgba = (rgba_t *) malloc(c.n * sizeof(rgba_t)); c.rgba = (rgba_t *) malloc(c.n * sizeof(rgba_t));
CHECK(c.rgba, "out of memory"); CHECK(c.rgba, "out of memory");
for (i = 0; i < c.n; ++i) for (i = 0; i < c.n; ++i)
c.rgba[i] = c0.rgba[i]; c.rgba[i] = c0.rgba[i];
return c; return c;
} }
colormap_t get_cmap(const char *colormap, int invert, double scale_alpha, colormap_t get_cmap(const char *cmap_dir,
int verbose) const char *colormap, int invert, double scale_alpha,
int verbose)
{ {
int i; int i;
colormap_t cmap = {0, NULL}; colormap_t cmap = {0, NULL};
FILE *cmap_f = NULL; FILE *cmap_f = NULL;
char *cmap_fname = (char *) malloc(sizeof(char) * char *cmap_fname = (char *) malloc(sizeof(char) *
(strlen(CMAP_DIR) (strlen(cmap_dir)
+ strlen(colormap) + 1)); + strlen(colormap) + 1));
CHECK(cmap_fname, "out of memory"); CHECK(cmap_fname, "out of memory");
if (colormap[0] == '-') { if (colormap[0] == '-') {
invert = 1; invert = 1;
colormap++; colormap++;
} }
strcpy(cmap_fname, CMAP_DIR); strcat(cmap_fname, colormap); strcpy(cmap_fname, cmap_dir); strcat(cmap_fname, colormap);
if (colormap[0] == '.' || colormap[0] == '/' if (colormap[0] == '.' || colormap[0] == '/'
|| !(cmap_f = fopen(cmap_fname, "r"))) { || !(cmap_f = fopen(cmap_fname, "r"))) {
free(cmap_fname); free(cmap_fname);
cmap_fname = my_strdup(colormap); cmap_fname = my_strdup(colormap);
if (!(cmap_f = fopen(cmap_fname, "r"))) { if (!(cmap_f = fopen(cmap_fname, "r"))) {
if (!strcmp(colormap, "gray")) if (!strcmp(colormap, "gray"))
cmap = gray_cmap; cmap = gray_cmap;
if (!strcmp(colormap, "yellow")) if (!strcmp(colormap, "yellow"))
cmap = yellow_cmap; cmap = yellow_cmap;
else { else {
skipping to change at line 244 skipping to change at line 264
double min = 0, max = 0, allmin = 0, allmax = 0; double min = 0, max = 0, allmin = 0, allmax = 0;
int min_set = 0, max_set = 0, collect_range = 0; int min_set = 0, max_set = 0, collect_range = 0;
extern char *optarg; extern char *optarg;
extern int optind; extern int optind;
int c; int c;
int slicedim[4] = {NO_SLICE_DIM,NO_SLICE_DIM,NO_SLICE_DIM,NO_SLICE_DIM}; int slicedim[4] = {NO_SLICE_DIM,NO_SLICE_DIM,NO_SLICE_DIM,NO_SLICE_DIM};
int islice[4], center_slice[4] = {0,0,0,0}; int islice[4], center_slice[4] = {0,0,0,0};
int islice_min[4] = {0,0,0,0}, islice_max[4] = {0,0,0,0}, islice_step[4] = {1,1,1,1}; int islice_min[4] = {0,0,0,0}, islice_max[4] = {0,0,0,0}, islice_step[4] = {1,1,1,1};
int err; int err;
int nx, ny; int nx, ny;
char *colormap = NULL, *overlay_colormap = NULL; char *colormap = NULL, *overlay_colormap = NULL, *cmap_dir = NULL;
int overlay_invert = 0; int overlay_invert = 0;
colormap_t cmap = { 0, NULL }; colormap_t cmap = { 0, NULL };
colormap_t overlay_cmap = { 0, NULL }; colormap_t overlay_cmap = { 0, NULL };
double overlay_opacity = OVERLAY_OPACITY_DEFAULT; double overlay_opacity = OVERLAY_OPACITY_DEFAULT;
int verbose = 0; int verbose = 0;
int transpose = 0; int transpose = 0;
int zero_center = 0; int zero_center = 0;
double scalex = 1.0, scaley = 1.0; double scalex = 1.0, scaley = 1.0;
int invert = 0; int invert = 0;
double skew = 0.0; double skew = 0.0;
int eight_bit = 0; int eight_bit = 0;
int ifile, num_processed; int ifile, num_processed;
int data_rank, slicedim3; int data_rank, slicedim3;
colormap = my_strdup(CMAP_DEFAULT); colormap = my_strdup(CMAP_DEFAULT);
overlay_colormap = my_strdup(OVERLAY_CMAP_DEFAULT); overlay_colormap = my_strdup(OVERLAY_CMAP_DEFAULT);
/* do tilde and $foo expansion on CMAP_DIR */
cmap_dir = shell_expand(CMAP_DIR);
while ((c = getopt(argc, argv, "ho:x:y:z:t:0c:m:M:RC:b:d:vX:Y:S:TrZs:Va:A:8 ")) != -1) while ((c = getopt(argc, argv, "ho:x:y:z:t:0c:m:M:RC:b:d:vX:Y:S:TrZs:Va:A:8 ")) != -1)
switch (c) { switch (c) {
case 'h': case 'h':
usage(stdout); usage(stdout);
return EXIT_SUCCESS; return EXIT_SUCCESS;
case 'V': case 'V':
printf("h5topng " PACKAGE_VERSION " by Steven G. Johnson\n" printf("h5topng " PACKAGE_VERSION " by Steven G. Johnson\n"
COPYRIGHT); COPYRIGHT);
return EXIT_SUCCESS; return EXIT_SUCCESS;
case 'v': case 'v':
skipping to change at line 375 skipping to change at line 398
break; break;
default: default:
fprintf(stderr, "Invalid argument -%c\n", c); fprintf(stderr, "Invalid argument -%c\n", c);
usage(stderr); usage(stderr);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
CHECK(!overlay_fname || !eight_bit, CHECK(!overlay_fname || !eight_bit,
"-8 option is not currently supported with -A"); "-8 option is not currently supported with -A");
cmap = get_cmap(colormap, invert, 1.0, verbose); cmap = get_cmap(cmap_dir, colormap, invert, 1.0, verbose);
if (overlay_fname) if (overlay_fname)
overlay_cmap = get_cmap(overlay_colormap, overlay_invert, overlay_cmap = get_cmap(cmap_dir, overlay_colormap, overlay_invert,
overlay_opacity, verbose); overlay_opacity, verbose);
if (optind == argc) { /* no parameters left */ if (optind == argc) { /* no parameters left */
usage(stderr); usage(stderr);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
contour_data.data = overlay_data.data = NULL; contour_data.data = overlay_data.data = NULL;
slicedim3 = slicedim[3]; slicedim3 = slicedim[3];
skipping to change at line 595 skipping to change at line 618
goto process_files; goto process_files;
} }
free(contour_fname); free(contour_fname);
free(overlay_fname); free(overlay_fname);
free(data_name); free(data_name);
if (cmap.rgba != gray_colors) if (cmap.rgba != gray_colors)
free(cmap.rgba); free(cmap.rgba);
free(colormap); free(colormap);
free(cmap_dir);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
 End of changes. 10 change blocks. 
9 lines changed or deleted 32 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)