short.tag.c test case added.

This commit is contained in:
Andrey Kiselev 2004-09-13 10:33:57 +00:00
parent d0318870ba
commit ee0fe81fd0
3 changed files with 272 additions and 20 deletions

View File

@ -29,12 +29,14 @@ LIBTIFF = -L$(top_builddir)/libtiff -ltiff
TESTS = $(check_PROGRAMS) TESTS = $(check_PROGRAMS)
check_PROGRAMS = ascii_tag long_tag check_PROGRAMS = ascii_tag long_tag short_tag
ascii_tag_SOURCES = ascii_tag.c ascii_tag_SOURCES = ascii_tag.c
ascii_tag_LDADD = $(LIBTIFF) ascii_tag_LDADD = $(LIBTIFF)
long_tag_SOURCES = long_tag.c long_tag_SOURCES = long_tag.c
long_tag_LDADD = $(LIBTIFF) long_tag_LDADD = $(LIBTIFF)
short_tag_SOURCES = short_tag.c
short_tag_LDADD = $(LIBTIFF)
INCLUDES = -I$(top_srcdir)/libtiff INCLUDES = -I$(top_srcdir)/libtiff

View File

@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.9a from Makefile.am. # Makefile.in generated by automake 1.8.5 from Makefile.am.
# @configure_input@ # @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@ -38,7 +38,7 @@
# OF THIS SOFTWARE. # OF THIS SOFTWARE.
# Process this file with automake to produce Makefile.in. # Process this file with automake to produce Makefile.in.
SOURCES = $(ascii_tag_SOURCES) $(long_tag_SOURCES) SOURCES = $(ascii_tag_SOURCES) $(long_tag_SOURCES) $(short_tag_SOURCES)
srcdir = @srcdir@ srcdir = @srcdir@
top_srcdir = @top_srcdir@ top_srcdir = @top_srcdir@
@ -60,10 +60,9 @@ POST_INSTALL = :
NORMAL_UNINSTALL = : NORMAL_UNINSTALL = :
PRE_UNINSTALL = : PRE_UNINSTALL = :
POST_UNINSTALL = : POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@ host_triplet = @host@
target_triplet = @target@ check_PROGRAMS = ascii_tag$(EXEEXT) long_tag$(EXEEXT) \
check_PROGRAMS = ascii_tag$(EXEEXT) long_tag$(EXEEXT) short_tag$(EXEEXT)
subdir = test subdir = test
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@ -82,9 +81,14 @@ ascii_tag_DEPENDENCIES = $(am__DEPENDENCIES_1)
am_long_tag_OBJECTS = long_tag.$(OBJEXT) am_long_tag_OBJECTS = long_tag.$(OBJEXT)
long_tag_OBJECTS = $(am_long_tag_OBJECTS) long_tag_OBJECTS = $(am_long_tag_OBJECTS)
long_tag_DEPENDENCIES = $(am__DEPENDENCIES_1) long_tag_DEPENDENCIES = $(am__DEPENDENCIES_1)
am_short_tag_OBJECTS = short_tag.$(OBJEXT)
short_tag_OBJECTS = $(am_short_tag_OBJECTS)
short_tag_DEPENDENCIES = $(am__DEPENDENCIES_1)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/libtiff -I$(top_builddir)/libtiff DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/libtiff -I$(top_builddir)/libtiff
depcomp = $(SHELL) $(top_srcdir)/depcomp depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles am__depfiles_maybe = depfiles
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/ascii_tag.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/long_tag.Po ./$(DEPDIR)/short_tag.Po
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) \ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) \
@ -93,8 +97,10 @@ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) \
CCLD = $(CC) CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@ $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(ascii_tag_SOURCES) $(long_tag_SOURCES) SOURCES = $(ascii_tag_SOURCES) $(long_tag_SOURCES) \
DIST_SOURCES = $(ascii_tag_SOURCES) $(long_tag_SOURCES) $(short_tag_SOURCES)
DIST_SOURCES = $(ascii_tag_SOURCES) $(long_tag_SOURCES) \
$(short_tag_SOURCES)
ETAGS = etags ETAGS = etags
CTAGS = ctags CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@ -133,14 +139,12 @@ GLU_CFLAGS = @GLU_CFLAGS@
GLU_LIBS = @GLU_LIBS@ GLU_LIBS = @GLU_LIBS@
GL_CFLAGS = @GL_CFLAGS@ GL_CFLAGS = @GL_CFLAGS@
GL_LIBS = @GL_LIBS@ GL_LIBS = @GL_LIBS@
GREP = @GREP@
HAVE_OPENGL_FALSE = @HAVE_OPENGL_FALSE@ HAVE_OPENGL_FALSE = @HAVE_OPENGL_FALSE@
HAVE_OPENGL_TRUE = @HAVE_OPENGL_TRUE@ HAVE_OPENGL_TRUE = @HAVE_OPENGL_TRUE@
INSTALL_DATA = @INSTALL_DATA@ INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@ LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@ LIBOBJS = @LIBOBJS@
LIBS = @LIBS@ LIBS = @LIBS@
@ -157,7 +161,6 @@ MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
MAKEINFO = @MAKEINFO@ MAKEINFO = @MAKEINFO@
NM = @NM@
OBJEXT = @OBJEXT@ OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@ PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@ -170,7 +173,6 @@ PTHREAD_CC = @PTHREAD_CC@
PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
PTHREAD_LIBS = @PTHREAD_LIBS@ PTHREAD_LIBS = @PTHREAD_LIBS@
RANLIB = @RANLIB@ RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@ SHELL = @SHELL@
STRIP = @STRIP@ STRIP = @STRIP@
@ -193,8 +195,6 @@ am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@ am__include = @am__include@
am__leading_dot = @am__leading_dot@ am__leading_dot = @am__leading_dot@
am__quote = @am__quote@ am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@ bindir = @bindir@
build = @build@ build = @build@
build_alias = @build_alias@ build_alias = @build_alias@
@ -235,6 +235,8 @@ ascii_tag_SOURCES = ascii_tag.c
ascii_tag_LDADD = $(LIBTIFF) ascii_tag_LDADD = $(LIBTIFF)
long_tag_SOURCES = long_tag.c long_tag_SOURCES = long_tag.c
long_tag_LDADD = $(LIBTIFF) long_tag_LDADD = $(LIBTIFF)
short_tag_SOURCES = short_tag.c
short_tag_LDADD = $(LIBTIFF)
INCLUDES = -I$(top_srcdir)/libtiff INCLUDES = -I$(top_srcdir)/libtiff
all: all-am all: all-am
@ -249,9 +251,9 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi
exit 1;; \ exit 1;; \
esac; \ esac; \
done; \ done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/Makefile'; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign test/Makefile'; \
cd $(top_srcdir) && \ cd $(top_srcdir) && \
$(AUTOMAKE) --gnu test/Makefile $(AUTOMAKE) --foreign test/Makefile
.PRECIOUS: Makefile .PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \ @case '$?' in \
@ -282,6 +284,9 @@ ascii_tag$(EXEEXT): $(ascii_tag_OBJECTS) $(ascii_tag_DEPENDENCIES)
long_tag$(EXEEXT): $(long_tag_OBJECTS) $(long_tag_DEPENDENCIES) long_tag$(EXEEXT): $(long_tag_OBJECTS) $(long_tag_DEPENDENCIES)
@rm -f long_tag$(EXEEXT) @rm -f long_tag$(EXEEXT)
$(LINK) $(long_tag_LDFLAGS) $(long_tag_OBJECTS) $(long_tag_LDADD) $(LIBS) $(LINK) $(long_tag_LDFLAGS) $(long_tag_OBJECTS) $(long_tag_LDADD) $(LIBS)
short_tag$(EXEEXT): $(short_tag_OBJECTS) $(short_tag_DEPENDENCIES)
@rm -f short_tag$(EXEEXT)
$(LINK) $(short_tag_LDFLAGS) $(short_tag_OBJECTS) $(short_tag_LDADD) $(LIBS)
mostlyclean-compile: mostlyclean-compile:
-rm -f *.$(OBJEXT) -rm -f *.$(OBJEXT)
@ -291,26 +296,30 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ascii_tag.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ascii_tag.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/long_tag.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/long_tag.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/short_tag.Po@am__quote@
.c.o: .c.o:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $< @am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj: .c.obj:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo: .c.lo:
@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ @am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
mostlyclean-libtool: mostlyclean-libtool:
@ -496,7 +505,7 @@ mostlyclean-generic:
clean-generic: clean-generic:
distclean-generic: distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic: maintainer-clean-generic:
@echo "This command is intended for maintainers to use" @echo "This command is intended for maintainers to use"

241
test/short_tag.c Normal file
View File

@ -0,0 +1,241 @@
/* $Id: short_tag.c,v 1.1 2004-09-13 10:33:57 dron Exp $ */
/*
* Copyright (c) 2004, Andrey Kiselev <dron@remotesensing.org>
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
* that (i) the above copyright notices and this permission notice appear in
* all copies of the software and related documentation, and (ii) the names of
* Sam Leffler and Silicon Graphics may not be used in any advertising or
* publicity relating to the software without the specific, prior written
* permission of Sam Leffler and Silicon Graphics.
*
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
/*
* TIFF Library
*
* Module to test LONG tags read/write functions.
*/
#include "tif_config.h"
#include <stdio.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include "tiffio.h"
const char *filename = "short_test.tiff";
#define SPP 3 /* Samples per pixel */
const uint16 width = 1;
const uint16 length = 1;
const uint16 bpp = 8;
const uint16 photometric = PHOTOMETRIC_RGB;
const uint16 rows_per_strip = 1;
const uint16 planarconfig = PLANARCONFIG_CONTIG;
static struct SingleTags {
ttag_t tag;
uint16 value;
} short_single_tags[] = {
{ TIFFTAG_COMPRESSION, COMPRESSION_NONE },
{ TIFFTAG_FILLORDER, FILLORDER_MSB2LSB },
{ TIFFTAG_ORIENTATION, ORIENTATION_BOTRIGHT },
/* { TIFFTAG_GRAYRESPONSEUNIT, 3 }, */
{ TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH },
{ TIFFTAG_INKSET, INKSET_MULTIINK },
{ TIFFTAG_MINSAMPLEVALUE, 23 },
{ TIFFTAG_MAXSAMPLEVALUE, 241 },
{ TIFFTAG_NUMBEROFINKS, SPP },
{ TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT },
{ TIFFTAG_IMAGEDEPTH, 1 },
{ TIFFTAG_TILEDEPTH, 1 }
};
#define NSINGLETAGS (sizeof (short_single_tags) / sizeof (short_single_tags[0]))
/*static struct SPPTags {
ttag_t tag;
uint16 value[SPP];
} short_spp_tags[] = {
{ TIFFTAG_MINSAMPLEVALUE, { 23, 41, 77 } },
{ TIFFTAG_MAXSAMPLEVALUE, { 115, 168, 241 } }
{ TIFFTAG_SAMPLEFORMAT,
{ SAMPLEFORMAT_UINT, SAMPLEFORMAT_UINT, SAMPLEFORMAT_UINT } }
};
#define NSPPTAGS (sizeof (short_spp_tags) / sizeof (short_spp_tags[0]))*/
int
main(int argc, char **argv)
{
TIFF *tif;
int i, j;
unsigned char buf[3] = { 0, 127, 255 };
uint16 value;
uint16 *array = NULL;
/* Test whether we can write tags. */
tif = TIFFOpen(filename, "w");
if (!tif) {
fprintf (stderr, "Can't create test TIFF file %s.\n", filename);
return 1;
}
if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width)) {
fprintf (stderr, "Can't set ImageWidth tag.\n");
goto failure;
}
if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length)) {
fprintf (stderr, "Can't set ImageLength tag.\n");
goto failure;
}
if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bpp)) {
fprintf (stderr, "Can't set BitsPerSample tag.\n");
goto failure;
}
if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, SPP)) {
fprintf (stderr, "Can't set SamplesPerPixel tag.\n");
goto failure;
}
if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip)) {
fprintf (stderr, "Can't set SamplesPerPixel tag.\n");
goto failure;
}
if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, planarconfig)) {
fprintf (stderr, "Can't set PlanarConfiguration tag.\n");
goto failure;
}
if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric)) {
fprintf (stderr, "Can't set PhotometricInterpretation tag.\n");
goto failure;
}
for (i = 0; i < NSINGLETAGS; i++) {
if (!TIFFSetField(tif, short_single_tags[i].tag,
short_single_tags[i].value)) {
fprintf(stderr, "Can't set tag %d.\n",
(int)short_single_tags[i].tag);
goto failure;
}
}
/*for (i = 0; i < NSPPTAGS; i++) {
if (!TIFFSetField(tif, short_spp_tags[i].tag,
short_spp_tags[i].value)) {
fprintf(stderr, "Can't set tag %d.\n",
(int)short_spp_tags[i].tag);
goto failure;
}
}*/
/* Write dummy pixel data. */
if (!TIFFWriteScanline(tif, buf, 0, 0) < 0) {
fprintf (stderr, "Can't write image data.\n");
goto failure;
}
TIFFClose(tif);
/* Ok, now test whether we can read written values. */
tif = TIFFOpen(filename, "r");
if (!tif) {
fprintf (stderr, "Can't open test TIFF file %s.\n", filename);
return 1;
}
if (!TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &value)
|| value != width) {
fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_IMAGEWIDTH);
goto failure;
}
if (!TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &value)
|| value != length) {
fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_IMAGELENGTH);
goto failure;
}
if (!TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &value)
|| value != bpp) {
fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_BITSPERSAMPLE);
goto failure;
}
if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &value)
|| value != photometric) {
fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_PHOTOMETRIC);
goto failure;
}
if (!TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &value)
|| value != SPP) {
fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_SAMPLESPERPIXEL);
goto failure;
}
if (!TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &value)
|| value != rows_per_strip) {
fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_ROWSPERSTRIP);
goto failure;
}
if (!TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &value)
|| value != planarconfig) {
fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_PLANARCONFIG);
goto failure;
}
for (i = 0; i < NSINGLETAGS; i++) {
if (!TIFFGetField(tif, short_single_tags[i].tag, &value)
|| value != short_single_tags[i].value) {
fprintf(stderr, "Can't get tag %d.\n",
(int)short_single_tags[i].tag);
goto failure;
}
}
/*for (i = 0; i < NSPPTAGS; i++) {
array = (uint16 *)_TIFFmalloc(SPP * sizeof(uint16));
if (!array) {
fprintf(stderr, "Can't allocate space for "
"tag array when reading tag %d.\n",
(int)short_spp_tags[i].tag);
goto failure;
}
if (!TIFFGetField(tif, short_spp_tags[i].tag, array)) {
fprintf(stderr, "Can't get tag %d.\n",
(int)short_spp_tags[i].tag);
goto failure;
}
for (j = 0; j < SPP; j++){
if (array[j] != short_spp_tags[i].value[j]) {
fprintf(stderr,
"Wrong value read for tag %d.\n",
(int)short_spp_tags[i].tag);
goto failure;
}
}
_TIFFfree(array);
}*/
TIFFClose(tif);
/* All tests passed; delete file and exit with success status. */
unlink(filename);
return 0;
failure:
/* Something goes wrong; close file and return unsuccessful status. */
TIFFClose(tif);
unlink(filename);
return 1;
}
/* vim: set ts=8 sts=8 sw=8 noet: */