diff options
Diffstat (limited to 'hl/tools')
-rw-r--r-- | hl/tools/gif2h5/gif2hdf.c | 4 | ||||
-rw-r--r-- | hl/tools/gif2h5/h52gifgentst.c | 16 | ||||
-rw-r--r-- | hl/tools/gif2h5/hdf2gif.c | 66 | ||||
-rw-r--r-- | hl/tools/gif2h5/writehdf.c | 6 | ||||
-rw-r--r-- | hl/tools/h52jpeg/h52jpeg.c | 282 | ||||
-rw-r--r-- | hl/tools/h52jpeg/h52jpegtst.c | 64 | ||||
-rw-r--r-- | hl/tools/h52jpeg/h52jpegtst.h | 2 |
7 files changed, 220 insertions, 220 deletions
diff --git a/hl/tools/gif2h5/gif2hdf.c b/hl/tools/gif2h5/gif2hdf.c index 24aaf31..c7e4ab6 100644 --- a/hl/tools/gif2h5/gif2hdf.c +++ b/hl/tools/gif2h5/gif2hdf.c @@ -53,7 +53,7 @@ main(int argv , char *argc[]) { print_version("gif2h5"); exit(EXIT_SUCCESS); - + } if (argv < 3) { @@ -120,7 +120,7 @@ main(int argv , char *argc[]) if (gifImageDesc.Image != NULL) free(gifImageDesc.Image); - + if (GifMemoryStruct.GifImageDesc[i] != NULL) { free(GifMemoryStruct.GifImageDesc[i]); diff --git a/hl/tools/gif2h5/h52gifgentst.c b/hl/tools/gif2h5/h52gifgentst.c index e0a50a1..eb83335 100644 --- a/hl/tools/gif2h5/h52gifgentst.c +++ b/hl/tools/gif2h5/h52gifgentst.c @@ -45,7 +45,7 @@ *------------------------------------------------------------------------- */ -int main(void) +int main(void) { hid_t fid; int i, j, n, space; @@ -55,7 +55,7 @@ int main(void) hsize_t width = WIDTH; hsize_t height = HEIGHT; - + /* create a file */ if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT))<0) return 1; @@ -70,7 +70,7 @@ int main(void) n++; j=0; } - + } /* make the image */ @@ -78,7 +78,7 @@ int main(void) return 1; /*------------------------------------------------------------------------- - * define a palette, blue to red tones + * define a palette, blue to red tones *------------------------------------------------------------------------- */ for ( i=0, n=0; i<PAL_ENTRIES*3; i+=3, n++) @@ -87,18 +87,18 @@ int main(void) pal[i+1]=0; /* green */ pal[i+2]=255-n; /* blue */ } - + /* make a palette */ if (H5IMmake_palette( fid, PAL_NAME, pal_dims, pal )<0) return 1; - + /* attach the palette to the image */ if (H5IMlink_palette( fid, IMAGE1_NAME, PAL_NAME )<0) return 1; - + if(H5Fclose(fid)<0) return 1; - + return 0; } diff --git a/hl/tools/gif2h5/hdf2gif.c b/hl/tools/gif2h5/hdf2gif.c index 7def4f0..9c252e1 100644 --- a/hl/tools/gif2h5/hdf2gif.c +++ b/hl/tools/gif2h5/hdf2gif.c @@ -38,7 +38,7 @@ usage(void) fprintf(stdout, " h52gif -V \n"); fprintf(stdout, " Print HDF5 library version and exit\n"); printf("h52gif expects *at least* one h5_image.\n"); - + } FILE *fpGif = NULL; @@ -69,16 +69,16 @@ int main(int argc , char **argv) int bool_is_image = 0; /* 0 = false , 1 = true */ char *image_name = NULL; int idx; - + if ( argv[1] && (strcmp("-V",argv[1])==0) ) { print_version("gif2h5"); exit(EXIT_SUCCESS); - + } - if (argc < 4) + if (argc < 4) { /* they didn't supply at least one image -- bail */ usage(); @@ -89,14 +89,14 @@ int main(int argc , char **argv) GIFName = argv[2]; /* get the options */ - while (arg_index++ < argc - 1) + while (arg_index++ < argc - 1) { if (!strcmp(argv[arg_index] , "-i")) { bool_is_image = 1; continue; } - if (bool_is_image) + if (bool_is_image) { /* allocate space to store the image name */ size_t len = strlen(argv[arg_index]); @@ -118,7 +118,7 @@ int main(int argc , char **argv) b = (BYTE *) &idx; EndianOrder = (b[0] ? 1:0); - if (!(fpGif = fopen(GIFName , "wb"))) + if (!(fpGif = fopen(GIFName , "wb"))) { printf("Error opening gif file for output. Aborting.\n"); goto out; @@ -132,19 +132,19 @@ int main(int argc , char **argv) hssize_t npals; hsize_t pal_dims[2]; unsigned char *pal; - - if ((fid = H5Fopen(HDFName , H5F_ACC_RDONLY , H5P_DEFAULT)) < 0) + + if ((fid = H5Fopen(HDFName , H5F_ACC_RDONLY , H5P_DEFAULT)) < 0) { fprintf(stderr , "Unable to open HDF file for input. Aborting.\n"); goto out; } - + /* read image */ if ( H5IMget_image_info( fid, image_name, &width, &height, &planes, interlace, &npals ) < 0 ) goto out; Image = (BYTE*) malloc( (size_t) width * (size_t) height ); - + if ( H5IMread_image( fid, image_name, Image ) < 0 ) goto out; @@ -154,7 +154,7 @@ int main(int argc , char **argv) goto out; pal = (BYTE*) malloc( (size_t) pal_dims[0] * (size_t) pal_dims[1] ); - + if ( H5IMget_palette( fid, image_name, 0, pal ) < 0 ) goto out; @@ -169,9 +169,9 @@ int main(int argc , char **argv) free(pal); } - + H5Fclose(fid); - + RWidth = (int)width; RHeight = (int)height; @@ -185,17 +185,17 @@ int main(int argc , char **argv) * palette * 2. Check for palettes in any of the other images. */ - if (!npals) + if (!npals) { numcols = 256; - for (i = 0 ; i < numcols ; i++) + for (i = 0 ; i < numcols ; i++) { Red[i] = 255 - i; Green[i] = 255 - i; Blue[i] = 255 - i; } - } - else + } + else { for (i = 0 ; i < numcols ; i++) { @@ -205,7 +205,7 @@ int main(int argc , char **argv) } } - for (i = 0; i < numcols; i++) + for (i = 0; i < numcols; i++) { pc2nc[i] = r1[i] = g1[i] = b1[i] = 0; } @@ -213,16 +213,16 @@ int main(int argc , char **argv) /* compute number of unique colors */ nc = 0; - for (i = 0; i < numcols; i++) + for (i = 0; i < numcols; i++) { /* see if color #i is already used */ - for (j = 0; j < i; j++) + for (j = 0; j < i; j++) { if (Red[i] == Red[j] && Green[i] == Green[j] && Blue[i] == Blue[j]) break; } - - if (j==i) + + if (j==i) { /* wasn't found */ pc2nc[i] = nc; @@ -230,15 +230,15 @@ int main(int argc , char **argv) g1[nc] = Green[i]; b1[nc] = Blue[i]; nc++; - } - else + } + else { pc2nc[i] = pc2nc[j]; } } /* figure out 'BitsPerPixel' */ - for (i = 1; i < 8; i++) + for (i = 1; i < 8; i++) { if ((1<<i) >= nc) break; @@ -252,23 +252,23 @@ int main(int argc , char **argv) else InitCodeSize = BitsPerPixel; - if (!fpGif) + if (!fpGif) { fprintf(stderr, "WriteGIF: file not open for writing\n" ); goto out; } - + fwrite("GIF87a", sizeof( char ), 6, fpGif); /* the GIF magic number */ - + putword(RWidth, fpGif); /* screen descriptor */ putword(RHeight, fpGif); - + i = 0x00; /* No, there is no color map */ i |= (8-1)<<4; /* OR in the color resolution (hardwired 8) */ i |= (BitsPerPixel - 1); /* OR in the # of bits per pixel */ fputc(i,fpGif); - + fputc(Background,fpGif); /* background color */ fputc(0, fpGif); /* future expansion byte */ @@ -286,7 +286,7 @@ int main(int argc , char **argv) /* since we always have a local color palette ... */ fputc((0x80 | (BitsPerPixel - 1)) , fpGif); - for (i = 0; i < ColorMapSize; i++) + for (i = 0; i < ColorMapSize; i++) { /* write out Global colormap */ fputc(r1[i], fpGif); @@ -301,7 +301,7 @@ int main(int argc , char **argv) free(Image); } - if (fputc(';',fpGif) == EOF) + if (fputc(';',fpGif) == EOF) { /* Write GIF file terminator */ fprintf(stderr , "Error!"); diff --git a/hl/tools/gif2h5/writehdf.c b/hl/tools/gif2h5/writehdf.c index 7c2b063..a150b3c 100644 --- a/hl/tools/gif2h5/writehdf.c +++ b/hl/tools/gif2h5/writehdf.c @@ -83,7 +83,7 @@ WriteHDF(GIFTOMEM GifMemoryStruct, char *HDFName , char *GIFFileName) /* size of the palette is tablesize (rows) X 3 (columns) */ dims[0] = gifHead.TableSize; dims[1] = 3; - + /* make a palette */ if (H5IMmake_palette(file_id,PAL_NAME,dims,(unsigned char *)gifHead.HDFPalette)<0) return -1; @@ -102,11 +102,11 @@ WriteHDF(GIFTOMEM GifMemoryStruct, char *HDFName , char *GIFFileName) /* create the image name */ sprintf(ImageName , "Image%d" , i); - + /* write image */ if (H5IMmake_image_8bit(file_id,ImageName,dims[1],dims[0],(gifImageDesc->Image))<0) return -1; - + /* attach the palette to the image dataset */ if (has_pal) { diff --git a/hl/tools/h52jpeg/h52jpeg.c b/hl/tools/h52jpeg/h52jpeg.c index c4dacd1..80269ce 100644 --- a/hl/tools/h52jpeg/h52jpeg.c +++ b/hl/tools/h52jpeg/h52jpeg.c @@ -18,7 +18,7 @@ #include <stdio.h> #include <stdlib.h> -/* +/* * Include file for users of JPEG library. * system headers that define at least the typedefs FILE and size_t are needed before */ @@ -52,7 +52,7 @@ static struct long_options l_opts[] = { /* a structure that contains h52jpeg options */ -typedef struct +typedef struct { const char *file_name; const char *template_name; @@ -69,7 +69,7 @@ static int h52jpeg(h52jpeg_opt_t opt); static void make_jpeg_name( const char* template_name, const char* image_name, char* jpeg_name); static int do_object(hid_t fid, h52jpeg_opt_t opt, const char* image_name); static int do_image(hid_t fid, h52jpeg_opt_t opt, const char* image_name, char* jpeg_name); -static void write_JPEG_file(char *filename, JSAMPLE *image_buffer, int image_height, int image_width, int planes); +static void write_JPEG_file(char *filename, JSAMPLE *image_buffer, int image_height, int image_width, int planes); static void convert_to_true( hsize_t width, hsize_t height, unsigned char* ibuf, unsigned char* pbuf, unsigned char* tbuf); /*------------------------------------------------------------------------- @@ -77,7 +77,7 @@ static void convert_to_true( hsize_t width, hsize_t height, unsigned char* ibuf, * * Purpose: h52jpeg main program * - * main reads command line options and calls h52jpeg + * main reads command line options and calls h52jpeg * * Programmer: Pedro Vicente, pvn@hdfgroup.org * @@ -94,11 +94,11 @@ int main(int argc, const char *argv[]) /* initialze options to 0 */ memset(&opt,0,sizeof(h52jpeg_opt_t)); - + /* parse command line options */ - while ((op = get_option(argc, argv, s_opts, l_opts)) != EOF) + while ((op = get_option(argc, argv, s_opts, l_opts)) != EOF) { - switch ((char)op) + switch ((char)op) { case 'h': @@ -111,32 +111,32 @@ int main(int argc, const char *argv[]) case 'v': opt.verbose = 1; - break; - + break; + case 'i': opt.image_name = opt_arg; break; - + case 'c': opt.convert_true = 1; - + break; case 'p': opt.idx_palette = atoi(opt_arg); break; - + } /* switch */ - - + + } /* while */ - + /* check for file names to be processed */ - if ( argv[ opt_ind ] != NULL && argv[ opt_ind + 1 ] != NULL ) + if ( argv[ opt_ind ] != NULL && argv[ opt_ind + 1 ] != NULL ) { opt.file_name = argv[ opt_ind ]; - opt.template_name = argv[ opt_ind + 1 ]; + opt.template_name = argv[ opt_ind + 1 ]; } - + else { usage(progname); @@ -145,8 +145,8 @@ int main(int argc, const char *argv[]) if ( h52jpeg(opt) < 0 ) return 1; - - + + return 0; } @@ -173,9 +173,9 @@ static void usage(const char *prog) printf(" -i, --image Image name (full path in HDF5 file)\n"); printf(" -c, --convert Convert image from graycolor to truecolor\n"); printf(" -p P, --palette=P Use HDF5 palette index P in conversion -c\n"); - + printf("\n"); - + printf(" P - is an integer, the palette index in the HDF5 image. Default is 0\n"); printf(" template - is a string used to name the jpeg file name; this name is made\n"); printf(" by concatenating this template with the HDF5 image name\n"); @@ -198,8 +198,8 @@ static void usage(const char *prog) printf("\n"); printf(" Exports the HDF5 image named <image> to a true color jpeg image, using\n"); printf(" the palette of index 1 in that image to do the conversion\n"); - - + + } /*------------------------------------------------------------------------- @@ -218,10 +218,10 @@ static int h52jpeg(h52jpeg_opt_t opt) hid_t fid; trav_table_t *travt = NULL; size_t i; - + /* open the HDF5 file */ - if (( fid = h5tools_fopen(opt.file_name, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) + if (( fid = h5tools_fopen(opt.file_name, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) { error_msg(progname, "cannot open file <%s>\n", opt.file_name ); return -1; @@ -231,81 +231,81 @@ static int h52jpeg(h52jpeg_opt_t opt) * object name was specified at command line *------------------------------------------------------------------------- */ - + if ( opt.image_name ) { /* read object, save jpeg image */ do_object(fid, opt, opt.image_name); - + } - + /*------------------------------------------------------------------------- * object name was not specified; traverse the file *------------------------------------------------------------------------- */ - + else - + { - + /* initialize traversal table */ trav_table_init(&travt); - + /* get the list of objects in the file */ if ( h5trav_gettable(fid, travt) < 0 ) goto out; - + /* search for images/datasets in file */ - for ( i = 0; i < travt->nobjs; i++) + for ( i = 0; i < travt->nobjs; i++) { - - switch ( travt->objs[i].type ) + + switch ( travt->objs[i].type ) { default: printf( "unknown object. Exiting ...\n" ); goto out; - + case H5TRAV_TYPE_GROUP: case H5TRAV_TYPE_NAMED_DATATYPE: case H5TRAV_TYPE_LINK: case H5TRAV_TYPE_UDLINK: - + break; - + case H5TRAV_TYPE_DATASET: /* read object, save jpeg image */ do_object(fid, opt, travt->objs[i].name); - break; /* H5TRAV_TYPE_DATASET */ - - } /* switch */ - - } /* i */ - - + break; /* H5TRAV_TYPE_DATASET */ + + } /* switch */ + + } /* i */ + + /* HDfree table */ trav_table_free(travt); - + } /* opt.image_name */ - - + + /* close */ if ( H5Fclose(fid) < 0 ) return -1; - + return 0; - + out: - H5E_BEGIN_TRY + H5E_BEGIN_TRY { H5Fclose(fid); - + } H5E_END_TRY; trav_table_free(travt); - + return -1; } @@ -329,29 +329,29 @@ int do_object(hid_t fid, h52jpeg_opt_t opt, const char* object_name) { int done=0; /* return value from do_image */ char jpeg_name[1024]; - + /* build the jpeg file name */ make_jpeg_name( opt.template_name, object_name, jpeg_name); - + if ( opt.verbose) { printf("%s ...", object_name ); } - + /*------------------------------------------------------------------------- * HDF5 Image *------------------------------------------------------------------------- */ - + if ( H5IMis_image( fid, object_name ) ) { /* read image, save jpeg image */ done = do_image(fid, opt, object_name, jpeg_name); } - - + + if ( opt.verbose) - { + { if ( done ) { printf("saved to %s\n", jpeg_name ); @@ -360,12 +360,12 @@ int do_object(hid_t fid, h52jpeg_opt_t opt, const char* object_name) { printf("\n"); } - + } - + return 0; - + } @@ -394,22 +394,22 @@ int do_image(hid_t fid, h52jpeg_opt_t opt, const char* image_name, char* jpeg_na const char* name; int done; unsigned char* ibuf=NULL; - + name = image_name; - - done = 0; - + + done = 0; + if ( H5IMget_image_info( fid, name, &width, &height, &planes, interlace, &npals ) < 0 ) goto out; - - if (NULL == (ibuf = HDmalloc( (int)width * (int)height * (int)planes ))) + + if (NULL == (ibuf = HDmalloc( (int)width * (int)height * (int)planes ))) goto out; - + if ( H5IMread_image( fid, name, ibuf ) < 0 ) { goto out; } - + /*------------------------------------------------------------------------- * no conversion to true color requested or true color image, just save what we found * this will result either in @@ -422,12 +422,12 @@ int do_image(hid_t fid, h52jpeg_opt_t opt, const char* image_name, char* jpeg_na if ( planes == 3 || !opt.convert_true ) { /* write the jpeg file */ - write_JPEG_file (jpeg_name, - ibuf, - (int) height, - (int) width, - (int) planes); - + write_JPEG_file (jpeg_name, + ibuf, + (int) height, + (int) width, + (int) planes); + done = 1; } /*------------------------------------------------------------------------- @@ -444,12 +444,12 @@ int do_image(hid_t fid, h52jpeg_opt_t opt, const char* image_name, char* jpeg_na unsigned char *pbuf=NULL;/* palette array */ unsigned char *tbuf=NULL;/* true color array */ int ipal; /* palette to use */ - + if ( H5IMget_npalettes( fid, name, &npals ) < 0 ) { goto out; } - + /*------------------------------------------------------------------------- * there are palettes *------------------------------------------------------------------------- @@ -463,68 +463,68 @@ int do_image(hid_t fid, h52jpeg_opt_t opt, const char* image_name, char* jpeg_na if ( opt.idx_palette >= npals ) { ipal = 0; - + if ( opt.verbose ) - { - printf("palette index <%d> does not exist. Using default...", + { + printf("palette index <%d> does not exist. Using default...", opt.idx_palette ); } } - - + + if ( H5IMget_palette_info( fid, name, ipal, pdims ) < 0 ) goto out; - - if (NULL == (pbuf = HDmalloc( (size_t)pdims[0] * (size_t)pdims[1] ))) + + if (NULL == (pbuf = HDmalloc( (size_t)pdims[0] * (size_t)pdims[1] ))) goto out; - - if (NULL == (tbuf = HDmalloc( (int)width * (int)height * 3 ))) + + if (NULL == (tbuf = HDmalloc( (int)width * (int)height * 3 ))) goto out; - + if ( H5IMget_palette( fid, name, ipal, pbuf ) < 0 ) goto out; - + /* convert indexed image to true color image */ convert_to_true(width, height, ibuf, pbuf, tbuf); - + /* write the jpeg file */ - write_JPEG_file (jpeg_name, - tbuf, - (int) height, - (int) width, - 3); - + write_JPEG_file (jpeg_name, + tbuf, + (int) height, + (int) width, + 3); + done = 1; - + HDfree( pbuf ); HDfree( tbuf ); pbuf = NULL; - tbuf = NULL; + tbuf = NULL; } /*------------------------------------------------------------------------- * there are no palettes *------------------------------------------------------------------------- */ else - { + { done = 0; if ( opt.verbose ) - { + { printf("image <%s> has no palette...", name ); } } /* no palettes */ - + } /* conversion to truecolor */ - + HDfree( ibuf ); ibuf = NULL; - + return done; - + out: - + return -1; - + } /*------------------------------------------------------------------------- @@ -533,7 +533,7 @@ 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. Replace the special characters + * and the HDF5 image name. Replace the special characters * '%', '@', '$', '/', ':', '&', ' ', and '*' with '_' * * Return: void @@ -550,7 +550,7 @@ void make_jpeg_name( const char* template_name, const char* image_name, char* jp HDstrcat( jpeg_name, image_name ); HDstrcat( jpeg_name, ".jpeg" ); len = HDstrlen( jpeg_name); - + /* HDF5 path names might contain '/', replace with '_' */ for (j = 0; j < len; j++) { @@ -563,11 +563,11 @@ void make_jpeg_name( const char* template_name, const char* image_name, char* jp (jpeg_name[j] == '&') || (jpeg_name[j] == ' ') || (jpeg_name[j] == '*') ) - { - jpeg_name[j] = '_'; + { + jpeg_name[j] = '_'; } } - + } /*------------------------------------------------------------------------- @@ -589,8 +589,8 @@ static void convert_to_true( hsize_t width, hsize_t height, unsigned char* ibuf, unsigned char* pbuf, unsigned char* tbuf) { hsize_t i, j; - - for ( i = 0, j = 0; i < width * height; i++, j += 3) + + for ( i = 0, j = 0; i < width * height; i++, j += 3) { unsigned char idx; unsigned char r; @@ -609,10 +609,10 @@ void convert_to_true( hsize_t width, hsize_t height, unsigned char* ibuf, unsign tbuf[j] = r; tbuf[j+1] = g; tbuf[j+2] = b; - + } - - + + } @@ -633,12 +633,12 @@ void convert_to_true( hsize_t width, hsize_t height, unsigned char* ibuf, unsign *------------------------------------------------------------------------- */ -static +static void write_JPEG_file(char *filename, /* JPEG file name */ JSAMPLE *image_buffer, /* Points to large array of R,G,B-order data */ int image_height, /* Number of rows in image */ int image_width, /* Number of columns in image */ - int planes) /* # of color components per pixel */ + int planes) /* # of color components per pixel */ { /* This struct contains the JPEG compression parameters and pointers to * working space (which is allocated as needed by the JPEG library). @@ -660,9 +660,9 @@ void write_JPEG_file(char *filename, /* JPEG file name */ FILE * outfile; /* target file */ JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */ int row_stride; /* physical row width in image buffer */ - + /* Step 1: allocate and initialize JPEG compression object */ - + /* We have to set up the error handler first, in case the initialization * step fails. (Unlikely, but it could happen if you are out of memory.) * This routine fills in the contents of struct jerr, and returns jerr's @@ -671,10 +671,10 @@ void write_JPEG_file(char *filename, /* JPEG file name */ cinfo.err = jpeg_std_error(&jerr); /* Now we can initialize the JPEG compression object. */ jpeg_create_compress(&cinfo); - + /* Step 2: specify data destination (eg, a file) */ /* Note: steps 2 and 3 can be done in either order. */ - + /* Here we use the library-supplied code to send compressed data to a * stdio stream. You can also write your own code to do something else. * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that @@ -685,22 +685,22 @@ void write_JPEG_file(char *filename, /* JPEG file name */ exit(1); } jpeg_stdio_dest(&cinfo, outfile); - + /* Step 3: set parameters for compression */ - + /* First we supply a description of the input image. * Four fields of the cinfo struct must be filled in: */ cinfo.image_width = image_width; /* image width and height, in pixels */ cinfo.image_height = image_height; cinfo.input_components = planes; /* # of color components per pixel */ - + /* colorspace of input image */ if (planes == 3) - cinfo.in_color_space = JCS_RGB; + cinfo.in_color_space = JCS_RGB; else if (planes == 1) - cinfo.in_color_space = JCS_GRAYSCALE; - + cinfo.in_color_space = JCS_GRAYSCALE; + /* Now use the library's routine to set default compression parameters. * (You must set at least cinfo.in_color_space before calling this, * since the defaults depend on the source color space.) @@ -710,24 +710,24 @@ void write_JPEG_file(char *filename, /* JPEG file name */ * Here we just illustrate the use of quality (quantization table) scaling: */ jpeg_set_quality(&cinfo, 100, TRUE /* limit to baseline-JPEG values */); - + /* Step 4: Start compressor */ - + /* TRUE ensures that we will write a complete interchange-JPEG file. * Pass TRUE unless you are very sure of what you're doing. */ jpeg_start_compress(&cinfo, TRUE); - + /* Step 5: while (scan lines remain to be written) */ /* jpeg_write_scanlines(...); */ - + /* Here we use the library's state variable cinfo.next_scanline as the * loop counter, so that we don't have to keep track ourselves. * To keep things simple, we pass one scanline per call; you can pass * more if you wish, though. */ row_stride = image_width * planes; /* JSAMPLEs per row in image_buffer */ - + while (cinfo.next_scanline < cinfo.image_height) { /* jpeg_write_scanlines expects an array of pointers to scanlines. * Here the array is only one element long, but you could pass @@ -736,18 +736,18 @@ void write_JPEG_file(char *filename, /* JPEG file name */ row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride]; (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); } - + /* Step 6: Finish compression */ - + jpeg_finish_compress(&cinfo); /* After finish_compress, we can close the output file. */ fclose(outfile); - + /* Step 7: release JPEG compression object */ - + /* This is an important step since it will release a good deal of memory. */ jpeg_destroy_compress(&cinfo); - + /* And we're done! */ } diff --git a/hl/tools/h52jpeg/h52jpegtst.c b/hl/tools/h52jpeg/h52jpegtst.c index 08ad7d4..e043277 100644 --- a/hl/tools/h52jpeg/h52jpegtst.c +++ b/hl/tools/h52jpeg/h52jpegtst.c @@ -45,20 +45,20 @@ unsigned char *gbuf = NULL; /* global buffer for image data */ int main( void ) { hid_t fid; /* HDF5 file identifier */ - + /* create a new HDF5 file using default properties. */ - if (( fid = H5Fcreate( "h52jpegtst.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT )) < 0 ) + if (( fid = H5Fcreate( "h52jpegtst.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT )) < 0 ) return 1; - + /* make images */ if ( make_images( fid ) < 0 ) goto out; - + /* close the file. */ H5Fclose( fid ); - + return 0; - + out: printf("Error on return function...Exiting\n"); H5Fclose( fid ); @@ -68,7 +68,7 @@ out: /*------------------------------------------------------------------------- * Function: make_images * - * Purpose: generate images + * Purpose: generate images * *------------------------------------------------------------------------- */ @@ -81,24 +81,24 @@ static int make_images( hid_t fid ) hsize_t pal_dims[2] = {PAL_ENTRIES,3}; /* palette dimensions */ unsigned char pal[ PAL_ENTRIES * 3 ]; /* palette array */ int i, n; - + /*------------------------------------------------------------------------- - * indexed image with 1 palette + * indexed image with 1 palette *------------------------------------------------------------------------- */ - + /* read first data file */ if ( read_data( "image8.txt", &width, &height ) < 0 ) goto out; - + /* make the image */ if ( H5IMmake_image_8bit( fid, IM_1PAL, width, height, gbuf ) < 0 ) goto out; - + /* make a palette */ if ( H5IMmake_palette( fid, PAL1, pal_dims, pal_rgb ) < 0 ) goto out; - + /* attach the 1st palette to the image */ if ( H5IMlink_palette( fid, IM_1PAL, PAL1 ) < 0 ) { @@ -119,7 +119,7 @@ static int make_images( hid_t fid ) { goto out; } - + /*------------------------------------------------------------------------- * define another palette, green tones *------------------------------------------------------------------------- @@ -134,12 +134,12 @@ static int make_images( hid_t fid ) /* save the palette */ if ( H5IMmake_palette( fid, PAL2, pal_dims, pal ) < 0 ) goto out; - + /* attach the palette to the image */ if ( H5IMlink_palette( fid, IM_2PAL, PAL2 ) < 0 ) { goto out; - } + } /*------------------------------------------------------------------------- * make another image, in a group and no palette @@ -155,23 +155,23 @@ static int make_images( hid_t fid ) H5Gclose(gid); - + /*------------------------------------------------------------------------- * true color image with pixel interlace in RGB type *------------------------------------------------------------------------- */ - + /* read second data file */ if ( read_data( "image24pixel.txt", &width, &height ) < 0 ) goto out; - + /* make dataset */ if ( H5IMmake_image_24bit( fid, "img24", width, height, "INTERLACE_PIXEL", gbuf ) < 0 ) goto out; - + return 0; - -out: + +out: printf("Error on return function...Exiting\n"); return -1; } @@ -208,7 +208,7 @@ static int read_data( const char* fname, /*IN*/ int w, h; char *srcdir = getenv("srcdir"); /* the source directory */ char data_file[512]=""; /* buffer to hold name of existing data file */ - + /*------------------------------------------------------------------------- * compose the name of the file to open, using "srcdir", if appropriate *------------------------------------------------------------------------- @@ -220,46 +220,46 @@ static int read_data( const char* fname, /*IN*/ strcat(data_file, "/"); } strcat(data_file,fname); - + /*------------------------------------------------------------------------- * read *------------------------------------------------------------------------- */ - + f = fopen(data_file, "r"); if ( f == NULL ) { printf( "Could not open file %s. Try set $srcdir \n", data_file ); return -1; } - + fscanf( f, "%s", str ); fscanf( f, "%d", &color_planes ); fscanf( f, "%s", str ); fscanf( f, "%d", &h); fscanf( f, "%s", str ); fscanf( f, "%d", &w); - + *width = (hsize_t)w; *height = (hsize_t)h; - + if ( gbuf ) { free( gbuf ); gbuf=NULL; } - + gbuf = (unsigned char*) malloc (w * h * color_planes * sizeof( unsigned char )); - + for (i = 0; i < h * w * color_planes ; i++) { fscanf( f, "%d",&n ); gbuf[i] = (unsigned char)n; } fclose(f); - + return 1; - + } diff --git a/hl/tools/h52jpeg/h52jpegtst.h b/hl/tools/h52jpeg/h52jpegtst.h index 749e571..6931cb7 100644 --- a/hl/tools/h52jpeg/h52jpegtst.h +++ b/hl/tools/h52jpeg/h52jpegtst.h @@ -276,7 +276,7 @@ const unsigned char pal_rgb[PAL_ENTRIES*3] = {0,0,0, 131,0,0, 127,0,0 }; - + #endif /* _PAL_RGB_H */ |