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