H5IMmake_image_24bit( file_id, IMAGE2_NAME, width, height, "INTERLACE_PIXEL", gbuf );
 
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * 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 COPYING file, which can be found at the root of the source code       *
 * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.  *
 * 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 <stdlib.h>
#include <string.h>
#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 = NULL;  /* global buffer for image data */
int main( void )
 hid_t          file_id;                       /* 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 */
 herr_t         i, n;
 /* create a new HDF5 file using default properties. */
 file_id = H5Fcreate( "ex_image2.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT );
 /* read first data file */
 if (read_data(DATA_FILE1,&width,&height)<0)
  goto out;
 /* make the image */
 H5IMmake_image_8bit( file_id, IMAGE1_NAME, width, height, gbuf );
 if (gbuf) {
    free(gbuf);
    gbuf = NULL;
 }