Merge branch 'bug2799' into 'master'

fix fax2tiff

See merge request libtiff/libtiff!55
This commit is contained in:
Even Rouault 2019-05-08 08:36:34 +00:00
commit b9b93f661e
6 changed files with 30 additions and 11 deletions

View File

@ -35,6 +35,7 @@ set(TESTSCRIPTS
ppm2tiff_pbm.sh ppm2tiff_pbm.sh
ppm2tiff_pgm.sh ppm2tiff_pgm.sh
ppm2tiff_ppm.sh ppm2tiff_ppm.sh
fax2tiff.sh
tiffcp-g3.sh tiffcp-g3.sh
tiffcp-g3-1d.sh tiffcp-g3-1d.sh
tiffcp-g3-1d-fill.sh tiffcp-g3-1d-fill.sh
@ -151,6 +152,7 @@ set(UNCOMPRESSEDIMAGES
# files which are not currently used by the tests. # files which are not currently used by the tests.
set(IMAGES_EXTRA_DIST set(IMAGES_EXTRA_DIST
images/README.txt images/README.txt
images/miniswhite-1c-1b.g3
${BMPIMAGES} ${BMPIMAGES}
${GIFIMAGES} ${GIFIMAGES}
${PNMIMAGES} ${PNMIMAGES}

View File

@ -71,6 +71,7 @@ TESTSCRIPTS = \
ppm2tiff_pbm.sh \ ppm2tiff_pbm.sh \
ppm2tiff_pgm.sh \ ppm2tiff_pgm.sh \
ppm2tiff_ppm.sh \ ppm2tiff_ppm.sh \
fax2tiff.sh \
tiffcp-g3.sh \ tiffcp-g3.sh \
tiffcp-g3-1d.sh \ tiffcp-g3-1d.sh \
tiffcp-g3-1d-fill.sh \ tiffcp-g3-1d-fill.sh \
@ -181,6 +182,7 @@ PNMIMAGES = \
# files which are not currently used by the tests. # files which are not currently used by the tests.
IMAGES_EXTRA_DIST = \ IMAGES_EXTRA_DIST = \
images/README.txt \ images/README.txt \
images/miniswhite-1c-1b.g3 \
$(PNMIMAGES) \ $(PNMIMAGES) \
$(TIFFIMAGES) $(TIFFIMAGES)

16
test/fax2tiff.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
#
# Basic sanity check for fax2tiff
#
. ${srcdir:-.}/common.sh
infile="${IMAGES}/miniswhite-1c-1b.g3"
outfile="o-fax2tiff.tiff"
echo "$MEMCHECK ${FAX2TIFF} -M -o $outfile $infile"
eval "$MEMCHECK" "${FAX2TIFF}" "-M" "-o" "$outfile" "$infile"
status=$?
if [ $status != 0 ] ; then
echo "Returned failed status $status!"
echo "Output (if any) is in \"${outfile}\"."
exit $status
fi
f_tiffinfo_validate $outfile

View File

@ -27,3 +27,6 @@ PNM files:
minisblack-1c-8b.pgm minisblack-1c-8b.pgm
miniswhite-1c-1b.pbm miniswhite-1c-1b.pbm
rgb-3c-8b.ppm rgb-3c-8b.ppm
G3 Fax files :
miniswhite-1c-1b.g3

Binary file not shown.

View File

@ -74,14 +74,10 @@ static void usage(void);
Struct to carry client data. Note that it does not appear that the client Struct to carry client data. Note that it does not appear that the client
data is actually used in this program. data is actually used in this program.
*/ */
typedef struct _FAX_Client_Data typedef union _FAX_Client_Data
{ {
#if defined(_WIN32) && defined(USE_WIN32_FILEIO) thandle_t fh; /* Operating system file handle */
intptr_t fh; /* Operating system file handle */ int fd; /* Integer file descriptor */
#else
int fd; /* Integer file descriptor */
#endif
} FAX_Client_Data; } FAX_Client_Data;
int int
@ -89,7 +85,7 @@ main(int argc, char* argv[])
{ {
FILE *in; FILE *in;
TIFF *out = NULL; TIFF *out = NULL;
FAX_Client_Data client_data; FAX_Client_Data client_data;
TIFFErrorHandler whandler = NULL; TIFFErrorHandler whandler = NULL;
int compression_in = COMPRESSION_CCITTFAX3; int compression_in = COMPRESSION_CCITTFAX3;
int compression_out = COMPRESSION_CCITTFAX3; int compression_out = COMPRESSION_CCITTFAX3;
@ -280,11 +276,11 @@ main(int argc, char* argv[])
continue; continue;
} }
#if defined(_WIN32) && defined(USE_WIN32_FILEIO) #if defined(_WIN32) && defined(USE_WIN32_FILEIO)
client_data.fh = _get_osfhandle(fileno(in)); client_data.fh = (thandle_t)_get_osfhandle(fileno(in));
#else #else
client_data.fd = fileno(in); client_data.fd = fileno(in);
#endif #endif
TIFFSetClientdata(faxTIFF, (thandle_t) &client_data); TIFFSetClientdata(faxTIFF, client_data.fh);
TIFFSetFileName(faxTIFF, (const char*)argv[optind]); TIFFSetFileName(faxTIFF, (const char*)argv[optind]);
TIFFSetField(out, TIFFTAG_IMAGEWIDTH, xsize); TIFFSetField(out, TIFFTAG_IMAGEWIDTH, xsize);
TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 1); TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 1);