summaryrefslogtreecommitdiffstats
path: root/hl/src/H5IM.c
diff options
context:
space:
mode:
Diffstat (limited to 'hl/src/H5IM.c')
-rw-r--r--hl/src/H5IM.c416
1 files changed, 3 insertions, 413 deletions
diff --git a/hl/src/H5IM.c b/hl/src/H5IM.c
index a6709c0..71841a9 100644
--- a/hl/src/H5IM.c
+++ b/hl/src/H5IM.c
@@ -11,7 +11,6 @@
****************************************************************************/
#include "H5IM.h"
-#include "../../fortran/src/H5f90i_gen.h"
#include <string.h>
@@ -21,13 +20,11 @@
* private functions
*-------------------------------------------------------------------------
*/
-static
herr_t H5IM_get_palette( hid_t loc_id,
const char *image_name,
int pal_number,
hid_t tid,
- int_f *pal_data);
-
+ void *pal_data);
/*-------------------------------------------------------------------------
* Function: H5IMmake_image_8bit
@@ -1268,412 +1265,6 @@ out:
}
-
-/*-------------------------------------------------------------------------
- * Function: H5IMmake_image_8bitf
- *
- * Purpose: Creates and writes an image an 8 bit image
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
- *
- * Date: May 10, 2005
- *
- * Comments:
- * This function allows the creation and writing of an 8bit image on disk.
- * The memory datatype is H5T_NATIVE_INT. It is supposed to be called from
- * the FORTRAN interface where the image buffer is defined as type "integer"
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-
-herr_t H5IMmake_image_8bitf( hid_t loc_id,
- const char *dset_name,
- hsize_t width,
- hsize_t height,
- int_f *buf )
-{
- hid_t did; /* dataset ID */
- hid_t sid; /* space ID */
- hsize_t dims[IMAGE8_RANK]; /* dimensions */
-
- /* initialize the image dimensions */
- dims[0] = height;
- dims[1] = width;
- dims[2] = 1;
-
-/*-------------------------------------------------------------------------
- * create and write the dataset
- *-------------------------------------------------------------------------
- */
-
- /* create the data space for the dataset. */
- if ((sid=H5Screate_simple(IMAGE8_RANK,dims,NULL))<0)
- return -1;
-
- /* create the dataset as H5T_NATIVE_UCHAR */
- if ((did=H5Dcreate(loc_id,dset_name,H5T_NATIVE_UINT8,sid,H5P_DEFAULT))<0)
- return -1;
-
- /* write with memory type H5T_NATIVE_INT */
- /* Use long type if Fortran integer is 8 bytes and C long long is also 8 bytes*/
- /* Fail if otherwise */
- if (buf)
- {
- if (sizeof(int_f) == sizeof(int)) {
- if (H5Dwrite(did,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0)
- return -1;}
- else if (sizeof(int_f) == sizeof(long)) {
- if (H5Dwrite(did,H5T_NATIVE_LONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0)
- return -1;}
- else if (sizeof(int_f) == sizeof(long long)) {
- if (H5Dwrite(did,H5T_NATIVE_LLONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0)
- return -1;}
- else
- return -1;
- }
-
- /* close */
- if (H5Dclose(did)<0)
- return -1;
- if (H5Sclose(sid)<0)
- return -1;
-
-/*-------------------------------------------------------------------------
- * attach the specification attributes
- *-------------------------------------------------------------------------
- */
-
- /* attach the CLASS attribute */
- if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0 )
- return -1;
-
- /* attach the VERSION attribute */
- if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION ) < 0 )
- return -1;
-
- /* attach the IMAGE_SUBCLASS attribute */
- if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_INDEXED" ) < 0 )
- return -1;
-
- return 0;
-}
-
-
-
-/*-------------------------------------------------------------------------
- * Function: H5IMmake_image_24bitf
- *
- * Purpose:
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
- *
- * Date: May 10, 2005
- *
- * Comments:
- * This function allows the creation and writing of an 8bit image on disk.
- * The memory datatype is H5T_NATIVE_INT. It is supposed to be called from
- * the FORTRAN interface where the image buffer is defined as type "integer"
- *
- * Interlace Mode Dimensions in the Dataspace
- * INTERLACE_PIXEL [height][width][pixel components]
- * INTERLACE_PLANE [pixel components][height][width]
- *
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-
-herr_t H5IMmake_image_24bitf( hid_t loc_id,
- const char *dset_name,
- hsize_t width,
- hsize_t height,
- const char *interlace,
- int_f *buf)
-{
- hid_t did; /* dataset ID */
- hid_t sid; /* space ID */
- hsize_t dims[IMAGE24_RANK]; /* dimensions */
-
-/*-------------------------------------------------------------------------
- * attach the image dimensions according to the interlace mode
- *-------------------------------------------------------------------------
- */
- if ( strcmp( interlace, "INTERLACE_PIXEL" ) == 0 )
- {
- /* Number of color planes is defined as the third dimension */
- dims[0] = height;
- dims[1] = width;
- dims[2] = IMAGE24_RANK;
- }
- else
- if ( strcmp( interlace, "INTERLACE_PLANE" ) == 0 )
- {
- /* Number of color planes is defined as the first dimension */
- dims[0] = IMAGE24_RANK;
- dims[1] = height;
- dims[2] = width;
- }
- else return -1;
-
-/*-------------------------------------------------------------------------
- * create and write the dataset
- *-------------------------------------------------------------------------
- */
-
- /* create the data space for the dataset. */
- if ((sid=H5Screate_simple(IMAGE24_RANK,dims,NULL))<0)
- return -1;
-
- /* create the dataset as H5T_NATIVE_UCHAR */
- if ((did=H5Dcreate(loc_id,dset_name,H5T_NATIVE_UCHAR,sid,H5P_DEFAULT))<0)
- return -1;
-
- /* write with memory type H5T_NATIVE_INT */
- if (buf)
- {
- if (sizeof(int_f) == sizeof(int)) {
- if (H5Dwrite(did,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0)
- return -1;}
- else if (sizeof(int_f) == sizeof(long)) {
- if (H5Dwrite(did,H5T_NATIVE_LONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0)
- return -1;}
- else if (sizeof(int_f) == sizeof(long long)) {
- if (H5Dwrite(did,H5T_NATIVE_LLONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0)
- return -1;}
- else
- return -1;
- }
-
- /* close */
- if (H5Dclose(did)<0)
- return -1;
- if (H5Sclose(sid)<0)
- return -1;
-
-/*-------------------------------------------------------------------------
- * attach the specification attributes
- *-------------------------------------------------------------------------
- */
-
- /* Attach the CLASS attribute */
- if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0 )
- return -1;
-
- /* Attach the VERSION attribute */
- if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION ) < 0 )
- return -1;
-
- /* Attach the IMAGE_SUBCLASS attribute */
- if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_TRUECOLOR" ) < 0 )
- return -1;
-
- /* Attach the INTERLACE_MODE attribute. This attributes is only for true color images */
- if ( H5LTset_attribute_string( loc_id, dset_name, "INTERLACE_MODE", interlace ) < 0 )
- return -1;
-
- return 0;
-
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: H5IMread_imagef
- *
- * Purpose: Reads image data from disk.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
- *
- * Date: May 10, 2005
- *
- * Comments:
- * This function allows reading of an 8bit image on disk.
- * The memory datatype is H5T_NATIVE_INT. It is supposed to be called from
- * the FORTRAN interface where the image buffer is defined as type "integer"
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-
-herr_t H5IMread_imagef( hid_t loc_id,
- const char *dset_name,
- int_f *buf )
-{
- hid_t did;
-
- /* open the dataset */
- if ( (did = H5Dopen( loc_id, dset_name )) < 0 )
- return -1;
-
- /* read to memory type H5T_NATIVE_INT */
- if (sizeof(int_f) == sizeof(int)){
- if ( H5Dread( did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf ) < 0 )
- goto out;}
- else if (sizeof(int_f) == sizeof(long)) {
- if ( H5Dread( did, H5T_NATIVE_LONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf ) < 0 )
- goto out;}
- else if (sizeof(int_f) == sizeof(long long)) {
- if ( H5Dread( did, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf ) < 0 )
- goto out;}
- else
- goto out;
-
- /* close */
- if ( H5Dclose( did ) )
- return -1;
- return 0;
-
-out:
- H5Dclose( did );
- return -1;
-
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: H5IMmake_palettef
- *
- * Purpose: Creates and writes a palette.
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
- *
- * Date: May 10, 2005
- *
- * Comments:
- * This function allows writing of an 8bit palette to disk.
- * The memory datatype is H5T_NATIVE_INT. It is supposed to be called from
- * the FORTRAN interface where the image buffer is defined as type "integer"
- *
- * based on HDF5 Image and Palette Specification
- * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-
-herr_t H5IMmake_palettef( hid_t loc_id,
- const char *pal_name,
- const hsize_t *pal_dims,
- int_f *pal_data )
-
-{
-
- hid_t did; /* dataset ID */
- hid_t sid; /* space ID */
- int has_pal;
-
- /* Check if the dataset already exists */
- has_pal = H5LTfind_dataset( loc_id, pal_name );
-
- /* It exists. Return */
- if ( has_pal == 1 )
- return 0;
-
-/*-------------------------------------------------------------------------
- * create and write the dataset
- *-------------------------------------------------------------------------
- */
-
- /* create the data space for the dataset. */
- if ((sid=H5Screate_simple(2,pal_dims,NULL))<0)
- return -1;
-
- /* create the dataset as H5T_NATIVE_UCHAR */
- if ((did=H5Dcreate(loc_id,pal_name,H5T_NATIVE_UCHAR,sid,H5P_DEFAULT))<0)
- return -1;
-
- /* write with memory type H5T_NATIVE_INT */
- if (pal_data)
- {
- if (sizeof(int_f) == sizeof(int)) {
- if (H5Dwrite(did,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,pal_data)<0)
- return -1;}
- else if (sizeof(int_f) == sizeof(long)) {
- if (H5Dwrite(did,H5T_NATIVE_LONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,pal_data)<0)
- return -1;}
- else if (sizeof(int_f) == sizeof(long long)) {
- if (H5Dwrite(did,H5T_NATIVE_LLONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,pal_data)<0)
- return -1;}
- else
- return -1;
- }
-
- /* close */
- if (H5Dclose(did)<0)
- return -1;
- if (H5Sclose(sid)<0)
- return -1;
-
-/*-------------------------------------------------------------------------
- * attach the specification attributes
- *-------------------------------------------------------------------------
- */
-
- /* Attach the attribute "CLASS" to the >>palette<< dataset*/
- if ( H5LTset_attribute_string( loc_id, pal_name, "CLASS", PALETTE_CLASS ) < 0 )
- return -1;
-
- /* Attach the attribute "PAL_VERSION" to the >>palette<< dataset*/
- if ( H5LTset_attribute_string( loc_id, pal_name, "PAL_VERSION", "1.2" ) < 0 )
- return -1;
-
- return 0;
-
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: H5IMget_palettef
- *
- * Purpose: Read palette
- *
- * Return: Success: 0, Failure: -1
- *
- * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
- *
- * Date: May 10, 2005
- *
- * Comments:
- * This function allows reading of an 8bit palette from disk.
- * The memory datatype is H5T_NATIVE_INT. It is supposed to be called from
- * the FORTRAN interface where the image buffer is defined as type "integer"
- *
- * based on HDF5 Image and Palette Specification
- * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-
-herr_t H5IMget_palettef( hid_t loc_id,
- const char *image_name,
- int pal_number,
- int_f *pal_data )
-{
- if(sizeof(int_f) == sizeof(int))
- return H5IM_get_palette(loc_id,image_name,pal_number,H5T_NATIVE_INT,pal_data);
- else if (sizeof(int_f) == sizeof(long))
- return H5IM_get_palette(loc_id,image_name,pal_number,H5T_NATIVE_LONG,pal_data);
- else if (sizeof(int_f) == sizeof(long long))
- return H5IM_get_palette(loc_id,image_name,pal_number,H5T_NATIVE_LLONG,pal_data);
- else
- return -1;
-
-}
-
/*-------------------------------------------------------------------------
* Function: H5IM_get_palette
*
@@ -1700,13 +1291,11 @@ herr_t H5IMget_palettef( hid_t loc_id,
*
*-------------------------------------------------------------------------
*/
-
-static
herr_t H5IM_get_palette( hid_t loc_id,
const char *image_name,
int pal_number,
hid_t tid,
- int_f *pal_data)
+ void *pal_data)
{
hid_t image_id;
int has_pal;
@@ -1793,4 +1382,5 @@ out:
H5Dclose( image_id );
return -1;
+
}