mirror of
https://github.com/HDFGroup/hdf5.git
synced 2024-11-27 02:10:55 +08:00
[svn-r13574]
bug fix check if a palette is to be linked and correct wrong calls in some functions with missing arguments
This commit is contained in:
parent
104e1cd848
commit
5b02211e76
@ -162,7 +162,7 @@ int hdfWriteGIF(FILE *fp, BYTE *pic, int ptype, int w, int h, BYTE *rmap,
|
||||
int colorstyle, int BitsPerPixel);
|
||||
|
||||
/* WRITEHDF.C */
|
||||
int WriteHDF(GIFTOMEM , CHAR *);
|
||||
int WriteHDF(GIFTOMEM , CHAR * , CHAR *);
|
||||
|
||||
/* Function: ReadHDF
|
||||
** Return: 0 on completion without error, -1 on error
|
||||
|
@ -102,7 +102,7 @@ main(int argv , char *argc[])
|
||||
* Call WriteHDF from here. Go ahead and change WriteHDF to write whatever
|
||||
* format you want
|
||||
*/
|
||||
if (WriteHDF(GifMemoryStruct , argc[2]))
|
||||
if (WriteHDF(GifMemoryStruct , argc[2] , argc[1]))
|
||||
printf("HDF Write Error\n\n");
|
||||
|
||||
/* Free all buffers */
|
||||
|
@ -15,7 +15,8 @@
|
||||
#
|
||||
# HDF Utilities Test script
|
||||
|
||||
TESTFILE="$srcdir/../testfiles/h52giftst.h5"
|
||||
TESTFILE1="$srcdir/../testfiles/h52giftst.h5"
|
||||
TESTFILE2="$srcdir/../testfiles/image1.gif"
|
||||
|
||||
# initialize errors variable
|
||||
errors=0
|
||||
@ -25,7 +26,7 @@ TESTING() {
|
||||
echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012'
|
||||
}
|
||||
|
||||
TOOLTEST()
|
||||
TOOLTEST1()
|
||||
{
|
||||
err=0
|
||||
$RUNSERIAL ./h52gif $*
|
||||
@ -38,10 +39,25 @@ else
|
||||
fi
|
||||
}
|
||||
|
||||
TOOLTEST2()
|
||||
{
|
||||
err=0
|
||||
$RUNSERIAL ./gif2h5 $*
|
||||
|
||||
if [ $err -eq 1 ]; then
|
||||
errors="` expr $errors + 1 `";
|
||||
echo "*FAILED*"
|
||||
else
|
||||
echo " PASSED"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
TESTING "h52giftst.h5 image1.gif -i 12345678 -p palette" ;
|
||||
TOOLTEST $TESTFILE image1.gif -i 12345678 -p palette
|
||||
|
||||
TESTING "./h52gif h52giftst.h5 image1.gif -i 12345678 -p palette"
|
||||
TOOLTEST1 $TESTFILE1 image1.gif -i 12345678 -p palette
|
||||
TESTING "./gif2h5 image1.gif image1.h5"
|
||||
TOOLTEST2 $TESTFILE2 image1.h5
|
||||
|
||||
|
||||
exit $errors
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include "gif.h"
|
||||
#include "H5IMpublic.h"
|
||||
|
||||
#define PAL_NAME "global"
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: WriteHDF
|
||||
*
|
||||
@ -35,12 +37,18 @@
|
||||
*/
|
||||
|
||||
int
|
||||
WriteHDF(GIFTOMEM GifMemoryStruct, char *HDFName)
|
||||
WriteHDF(GIFTOMEM GifMemoryStruct, char *HDFName , char *GIFFileName)
|
||||
{
|
||||
GIFHEAD gifHead; /* GIF Header structure */
|
||||
GIFIMAGEDESC *gifImageDesc; /* Logical Image Descriptor struct */
|
||||
int has_pal=0;
|
||||
|
||||
long ImageCount; /* number of images */
|
||||
#ifdef UNUSED
|
||||
long CommentCount, /* number of comments */
|
||||
ApplicationCount, /* number of application extensions */
|
||||
PlainTextCount; /* number of plain text extensions */
|
||||
#endif /* UNUSED */
|
||||
|
||||
char ImageName[256]; /* Image name for the Image */
|
||||
|
||||
@ -55,6 +63,11 @@ WriteHDF(GIFTOMEM GifMemoryStruct, char *HDFName)
|
||||
|
||||
/* get some data from gifHead */
|
||||
ImageCount = gifHead.ImageCount;
|
||||
#ifdef UNUSED
|
||||
CommentCount = (WORD)gifHead.CommentCount;
|
||||
ApplicationCount = (WORD)gifHead.ApplicationCount;
|
||||
PlainTextCount = (WORD)gifHead.PlainTextCount;
|
||||
#endif /* UNUSED */
|
||||
|
||||
if ((file_id = H5Fcreate(HDFName , H5F_ACC_TRUNC , H5P_DEFAULT , H5P_DEFAULT)) < 0) {
|
||||
/* error occured opening the HDF File for write */
|
||||
@ -72,8 +85,10 @@ WriteHDF(GIFTOMEM GifMemoryStruct, char *HDFName)
|
||||
dims[1] = 3;
|
||||
|
||||
/* make a palette */
|
||||
if (H5IMmake_palette(file_id,"Global Palette",dims,(unsigned char *)gifHead.HDFPalette)<0)
|
||||
if (H5IMmake_palette(file_id,PAL_NAME,dims,(unsigned char *)gifHead.HDFPalette)<0)
|
||||
return -1;
|
||||
|
||||
has_pal=1;
|
||||
}
|
||||
|
||||
for(i = 0; i < ImageCount; i++) {
|
||||
@ -93,8 +108,11 @@ WriteHDF(GIFTOMEM GifMemoryStruct, char *HDFName)
|
||||
return -1;
|
||||
|
||||
/* attach the palette to the image dataset */
|
||||
if (H5IMlink_palette(file_id,ImageName,"Global Palette")<0)
|
||||
return -1;
|
||||
if (has_pal)
|
||||
{
|
||||
if (H5IMlink_palette(file_id,ImageName,PAL_NAME)<0)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* close the H5 file */
|
||||
|
Loading…
Reference in New Issue
Block a user