From f5553240b8360b2950d8966c00858272f894dded Mon Sep 17 00:00:00 2001 From: Pedro Vicente Nunes Date: Mon, 16 Jun 2008 10:11:44 -0500 Subject: [svn-r15217] added a HDF5 file generator program that reads 2 realistic images from ASCII files, a true color and a gray color image the HDF5 file generated is used by h52jpeg to generate jpeg images tested: windows --- tools/h52jpeg/h52jpegtst.c | 204 +- tools/h52jpeg/image24pixel.txt | 101475 ++++++++++++++++++++++++++++++++ tools/h52jpeg/image8.txt | 120006 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 221662 insertions(+), 23 deletions(-) create mode 100644 tools/h52jpeg/image24pixel.txt create mode 100644 tools/h52jpeg/image8.txt diff --git a/tools/h52jpeg/h52jpegtst.c b/tools/h52jpeg/h52jpegtst.c index f3e13de..3a4b277 100644 --- a/tools/h52jpeg/h52jpegtst.c +++ b/tools/h52jpeg/h52jpegtst.c @@ -1,23 +1,181 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - - -int main( void ) -{ - - return 0; - -} - +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include "hdf5.h" +#include "hdf5_hl.h" +#include +#include + +#define DATA_FILE1 "image8.txt" +#define DATA_FILE2 "image24pixel.txt" +#define IMAGE1_NAME "image8bit" +#define IMAGE2_NAME "image24bitpixel" +#define PAL_NAME "palette" +#define PAL_ENTRIES 256 + +static int read_data(const char* file_name, hsize_t *width, hsize_t *height ); +unsigned char *gbuf = 0; /* global buffer for image data */ + +int main( void ) +{ + hid_t fid; /* HDF5 file identifier */ + hsize_t width; /* width of image */ + hsize_t height; /* height of image */ + unsigned char pal[ PAL_ENTRIES * 3 ]; /* palette array */ + hsize_t pal_dims[2] = {PAL_ENTRIES,3}; /* palette dimensions */ + int i, n; + + /* create a new HDF5 file using default properties. */ + if (( fid = H5Fcreate( "h52jpegtst.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT )) < 0 ) + return 1; + + /* read first data file */ + if ( read_data( DATA_FILE1, &width, &height ) < 0 ) + goto out; + + /* make the image */ + if ( H5IMmake_image_8bit( fid, IMAGE1_NAME, width, height, gbuf ) < 0 ) + goto out; + + /*------------------------------------------------------------------------- + * define a palette, blue to red tones + *------------------------------------------------------------------------- + */ + for ( i=0, n=0; i