]>
git.saurik.com Git - wxWidgets.git/blob - src/tiff/test/long_tag.c
4 * Copyright (c) 2004, Andrey Kiselev <dron@ak4719.spb.edu>
6 * Permission to use, copy, modify, distribute, and sell this software and
7 * its documentation for any purpose is hereby granted without fee, provided
8 * that (i) the above copyright notices and this permission notice appear in
9 * all copies of the software and related documentation, and (ii) the names of
10 * Sam Leffler and Silicon Graphics may not be used in any advertising or
11 * publicity relating to the software without the specific, prior written
12 * permission of Sam Leffler and Silicon Graphics.
14 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
16 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
18 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
19 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
20 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
21 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
22 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
29 * Module to test LONG tags read/write functions.
32 #include "tif_config.h"
42 extern int CheckLongField(TIFF
*, ttag_t
, uint32
);
44 const char *filename
= "long_test.tiff";
51 { TIFFTAG_SUBFILETYPE
, 1, FILETYPE_REDUCEDIMAGE
|FILETYPE_PAGE
|FILETYPE_MASK
}
53 #define NTAGS (sizeof (long_tags) / sizeof (long_tags[0]))
55 const uint32 width
= 1;
56 const uint32 length
= 1;
57 const uint32 rows_per_strip
= 1;
60 main(int argc
, char **argv
)
64 unsigned char buf
[3] = { 0, 127, 255 };
66 /* Test whether we can write tags. */
67 tif
= TIFFOpen(filename
, "w");
69 fprintf (stderr
, "Can't create test TIFF file %s.\n", filename
);
73 if (!TIFFSetField(tif
, TIFFTAG_IMAGEWIDTH
, width
)) {
74 fprintf (stderr
, "Can't set ImageWidth tag.\n");
77 if (!TIFFSetField(tif
, TIFFTAG_IMAGELENGTH
, length
)) {
78 fprintf (stderr
, "Can't set ImageLength tag.\n");
81 if (!TIFFSetField(tif
, TIFFTAG_BITSPERSAMPLE
, 8)) {
82 fprintf (stderr
, "Can't set BitsPerSample tag.\n");
85 if (!TIFFSetField(tif
, TIFFTAG_SAMPLESPERPIXEL
, 3)) {
86 fprintf (stderr
, "Can't set SamplesPerPixel tag.\n");
89 if (!TIFFSetField(tif
, TIFFTAG_ROWSPERSTRIP
, rows_per_strip
)) {
90 fprintf (stderr
, "Can't set SamplesPerPixel tag.\n");
93 if (!TIFFSetField(tif
, TIFFTAG_PLANARCONFIG
, PLANARCONFIG_CONTIG
)) {
94 fprintf (stderr
, "Can't set PlanarConfiguration tag.\n");
97 if (!TIFFSetField(tif
, TIFFTAG_PHOTOMETRIC
, PHOTOMETRIC_RGB
)) {
98 fprintf (stderr
, "Can't set PhotometricInterpretation tag.\n");
102 for (i
= 0; i
< NTAGS
; i
++) {
103 if (!TIFFSetField(tif
, long_tags
[i
].tag
,
104 long_tags
[i
].value
)) {
105 fprintf(stderr
, "Can't set tag %d.\n",
106 (int)long_tags
[i
].tag
);
111 /* Write dummy pixel data. */
112 if (!TIFFWriteScanline(tif
, buf
, 0, 0) < 0) {
113 fprintf (stderr
, "Can't write image data.\n");
119 /* Ok, now test whether we can read written values. */
120 tif
= TIFFOpen(filename
, "r");
122 fprintf (stderr
, "Can't open test TIFF file %s.\n", filename
);
126 if (CheckLongField(tif
, TIFFTAG_IMAGEWIDTH
, width
) < 0)
129 if (CheckLongField(tif
, TIFFTAG_IMAGELENGTH
, length
) < 0)
132 if (CheckLongField(tif
, TIFFTAG_ROWSPERSTRIP
, rows_per_strip
) < 0)
135 for (i
= 0; i
< NTAGS
; i
++) {
136 if (CheckLongField(tif
, long_tags
[i
].tag
,
137 long_tags
[i
].value
) < 0)
143 /* All tests passed; delete file and exit with success status. */
148 /* Something goes wrong; close file and return unsuccessful status. */
154 /* vim: set ts=8 sts=8 sw=8 noet: */