1
/* $Id: ascii_tag.c,v 1.5.2.1 2010-06-08 18:50:43 bfriesen Exp $ */
1
/* $Id: ascii_tag.c,v 1.7 2008-04-15 13:32:12 dron Exp $ */
4
4
* Copyright (c) 2004, Andrey Kiselev <dron@ak4719.spb.edu>
56
56
{ TIFFTAG_ARTIST, "Andrey V. Kiselev" },
57
57
{ TIFFTAG_HOSTCOMPUTER, "Debian GNU/Linux (Sarge)" },
58
58
{ TIFFTAG_TARGETPRINTER, "No printer" },
59
{ TIFFTAG_PIXAR_TEXTUREFORMAT, "No texture" },
60
{ TIFFTAG_PIXAR_WRAPMODES, "No wrap" },
61
{ TIFFTAG_COPYRIGHT, "Copyright (c) 2004, Andrey Kiselev" }
59
{ TIFFTAG_COPYRIGHT, "Copyright (c) 2004, Andrey Kiselev" },
60
{ TIFFTAG_FAXSUBADDRESS, "Fax subaddress" },
62
{ TIFFTAG_UNIQUECAMERAMODEL, "No camera" },
63
{ TIFFTAG_CAMERASERIALNUMBER, "1234567890" }
63
65
#define NTAGS (sizeof (ascii_tags) / sizeof (ascii_tags[0]))
65
const char *ink_names = "Red\0Green\0Blue";
67
static const char ink_names[] = "Red\0Green\0Blue";
66
68
const int ink_names_size = 15;
69
main(int argc, char **argv)
73
unsigned char buf[3] = { 0, 127, 255 };
75
unsigned char buf[] = { 0, 127, 255 };
76
78
/* Test whether we can write tags. */
92
94
fprintf (stderr, "Can't set BitsPerSample tag.\n");
95
if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3)) {
97
if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, sizeof(buf))) {
96
98
fprintf (stderr, "Can't set SamplesPerPixel tag.\n");
108
110
for (i = 0; i < NTAGS; i++) {
109
111
if (!TIFFSetField(tif, ascii_tags[i].tag,
110
112
ascii_tags[i].value)) {
111
fprintf(stderr, "Can't set tag %d.\n",
112
(int)ascii_tags[i].tag);
113
fprintf(stderr, "Can't set tag %lu.\n",
114
(unsigned long)ascii_tags[i].tag);
117
119
/* InkNames tag has special form, so we handle it separately. */
118
120
if (!TIFFSetField(tif, TIFFTAG_NUMBEROFINKS, 3)) {
119
fprintf (stderr, "Can't set tag %d.\n", TIFFTAG_NUMBEROFINKS);
121
fprintf (stderr, "Can't set tag %d (NUMBEROFINKS).\n",
122
TIFFTAG_NUMBEROFINKS);
122
125
if (!TIFFSetField(tif, TIFFTAG_INKNAMES, ink_names_size, ink_names)) {
123
fprintf (stderr, "Can't set tag %d.\n", TIFFTAG_INKNAMES);
126
fprintf (stderr, "Can't set tag %d (INKNAMES).\n",
142
146
for (i = 0; i < NTAGS; i++) {
143
147
if (!TIFFGetField(tif, ascii_tags[i].tag, &value)
144
148
|| strcmp(value, ascii_tags[i].value)) {
145
fprintf(stderr, "Can't get tag %d.\n",
146
(int)ascii_tags[i].tag);
149
fprintf(stderr, "Can't get tag %lu.\n",
150
(unsigned long)ascii_tags[i].tag);
151
155
if (!TIFFGetField(tif, TIFFTAG_INKNAMES, &value)
152
156
|| memcmp(value, ink_names, ink_names_size)) {
153
fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_INKNAMES);
157
fprintf (stderr, "Can't get tag %d (INKNAMES).\n",
164
/* Something goes wrong; close file and return unsuccessful status. */
170
* Something goes wrong; close file and return unsuccessful status.
171
* Do not remove the file for further manual investigation.
170
177
/* vim: set ts=8 sts=8 sw=8 noet: */