1/*
2 * maketif.c -- creates a little TIFF file, with
3 *   the XTIFF extended tiff example tags.
4 */
5
6#include <stdlib.h>
7#include "xtiffio.h"
8
9
10void SetUpTIFFDirectory(TIFF *tif);
11void WriteImage(TIFF *tif);
12
13#define WIDTH 20
14#define HEIGHT 20
15
16void main()
17{
18	TIFF *tif=(TIFF*)0;  /* TIFF-level descriptor */
19
20	tif=XTIFFOpen("newtif.tif","w");
21	if (!tif) goto failure;
22
23	SetUpTIFFDirectory(tif);
24	WriteImage(tif);
25
26	XTIFFClose(tif);
27	exit (0);
28
29failure:
30	printf("failure in maketif\n");
31	if (tif) XTIFFClose(tif);
32	exit (-1);
33}
34
35
36void SetUpTIFFDirectory(TIFF *tif)
37{
38	double mymulti[6]={0.0,1.0,2.0,  3.1415926, 5.0,1.0};
39	uint32 mysingle=3456;
40	char *ascii="This file was produced by Steven Spielberg. NOT";
41
42	TIFFSetField(tif,TIFFTAG_IMAGEWIDTH,WIDTH);
43	TIFFSetField(tif,TIFFTAG_IMAGELENGTH,HEIGHT);
44	TIFFSetField(tif,TIFFTAG_COMPRESSION,COMPRESSION_NONE);
45	TIFFSetField(tif,TIFFTAG_PHOTOMETRIC,PHOTOMETRIC_MINISBLACK);
46	TIFFSetField(tif,TIFFTAG_PLANARCONFIG,PLANARCONFIG_CONTIG);
47	TIFFSetField(tif,TIFFTAG_BITSPERSAMPLE,8);
48	TIFFSetField(tif,TIFFTAG_ROWSPERSTRIP,20);
49
50	/* Install the extended TIFF tag examples */
51	TIFFSetField(tif,TIFFTAG_EXAMPLE_MULTI,6,mymulti);
52	TIFFSetField(tif,TIFFTAG_EXAMPLE_SINGLE,mysingle);
53	TIFFSetField(tif,TIFFTAG_EXAMPLE_ASCII,ascii);
54}
55
56
57void WriteImage(TIFF *tif)
58{
59	int i;
60	char buffer[WIDTH];
61
62	memset(buffer,0,sizeof(buffer));
63	for (i=0;i<HEIGHT;i++)
64		if (!TIFFWriteScanline(tif, buffer, i, 0))
65			TIFFErrorExt(tif->tif_clientdata, "WriteImage","failure in WriteScanline\n");
66}
67
68
69
70
71/*
72 * Local Variables:
73 * mode: c
74 * c-basic-offset: 8
75 * fill-column: 78
76 * End:
77 */
78