diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2008-07-02 15:25:26 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2008-07-02 15:25:26 (GMT) |
commit | 7722c4c834891e088666945742fc1a5a3162b947 (patch) | |
tree | a65a093ada474d47fad417d10531850e789b85e0 /hl | |
parent | e662641a45b5d4bc4d8e048cc11ea86e934768bf (diff) | |
download | hdf5-7722c4c834891e088666945742fc1a5a3162b947.zip hdf5-7722c4c834891e088666945742fc1a5a3162b947.tar.gz hdf5-7722c4c834891e088666945742fc1a5a3162b947.tar.bz2 |
[svn-r15311] added removal of more special characters from jpeg file name
added a command line option -c to convert the output image to true or gray color
Diffstat (limited to 'hl')
-rw-r--r-- | hl/tools/h52jpeg/h52jpeg.c | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/hl/tools/h52jpeg/h52jpeg.c b/hl/tools/h52jpeg/h52jpeg.c index 785a078..8c0377d 100644 --- a/hl/tools/h52jpeg/h52jpeg.c +++ b/hl/tools/h52jpeg/h52jpeg.c @@ -40,13 +40,14 @@ const char *progname = "h52jpeg"; int d_status = EXIT_SUCCESS; /* command-line options: The user can specify short or long-named parameters */ -static const char *s_opts = "hVvi:t:"; +static const char *s_opts = "hVvi:t:c:"; static struct long_options l_opts[] = { { "help", no_arg, 'h' }, { "version", no_arg, 'V' }, { "verbose", no_arg, 'v' }, { "image", require_arg, 'i' }, { "type", require_arg, 't' }, + { "convert", require_arg, 'c' }, { NULL, 0, '\0' } }; @@ -58,6 +59,7 @@ typedef struct const char *template_name; const char *image_name; int image_type; + int convert_type; int verbose; } h52jpeg_opt_t; @@ -84,6 +86,7 @@ int main(int argc, const char *argv[]) { h52jpeg_opt_t opt; const char *image_type = NULL; + const char *convert_type = NULL; int op; /* initialze options to 0 */ @@ -125,6 +128,25 @@ int main(int argc, const char *argv[]) } break; + case 'c': + convert_type = opt_arg; + + + if ( HDstrcmp( convert_type, "grey" ) == 0 ) + { + opt.convert_type = 0; + } + else if ( HDstrcmp( convert_type, "true" ) == 0 ) + { + opt.convert_type = 1; + } + else + { + printf("<%s> is an invalid image type\n", image_type); + exit(EXIT_FAILURE); + } + + break; } /* switch */ @@ -172,7 +194,8 @@ static void usage(const char *prog) printf(" -v, --verbose Verbose mode, print object information\n"); printf(" -V, --version Print HDF5 version number and exit\n"); printf(" -i, --image Image name (full path in HDF5 file)\n"); - printf(" -t T, --type=T Type of image (graycolor or truecolor)\n"); + printf(" -t T, --type=T Type of image to read (graycolor or truecolor)\n"); + printf(" -c T, --convert=T Convert image to type T (graycolor or truecolor)\n"); printf("\n"); @@ -296,7 +319,7 @@ out: * * Purpose: read HDF5 image/dataset, save jpeg image * - * Return: int + * Return: 0, all is fine, -1 not all is fine * *------------------------------------------------------------------------- */ @@ -411,7 +434,8 @@ out: * Parameters: template name (IN), image name (IN), jpeg name (IN/OUT) * * Purpose: build a name for the jpeg image file upon a template name - * and the HDF5 image name + * and the HDF5 image name. Replace the special characters + * "%", "@", "$", "/", ":", "&", and "*" with "_" * * Return: void * @@ -431,7 +455,14 @@ void make_jpeg_name( const char* template_name, const char* image_name, char* jp /* HDF5 path names might contain '/', replace with '_' */ for (j = 0; j < len; j++) { - if (jpeg_name[j] == '/') + if ( (jpeg_name[j] == '/') || + (jpeg_name[j] == '%') || + (jpeg_name[j] == '@') || + (jpeg_name[j] == '$') || + (jpeg_name[j] == '/') || + (jpeg_name[j] == ':') || + (jpeg_name[j] == '&') || + (jpeg_name[j] == '*') ) { jpeg_name[j] = '_'; } |