]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/tiff/contrib/dbs/tiff-bi.c
xti changes
[wxWidgets.git] / src / tiff / contrib / dbs / tiff-bi.c
... / ...
CommitLineData
1/* $Id$ */
2
3/*
4 * tiff-bi.c -- create a Class B (bilevel) TIFF file
5 *
6 * Copyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
7 *
8 * All Rights Reserved
9 *
10 * Permission to use, copy, modify, and distribute this software and its
11 * documentation for any purpose and without fee is hereby granted,
12 * provided that the above copyright notice appear in all copies and that
13 * both that copyright notice and this permission notice appear in
14 * supporting documentation, and that the name of Digital not be
15 * used in advertising or publicity pertaining to distribution of the
16 * software without specific, written prior permission.
17 *
18 * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
19 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
20 * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
21 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
22 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
23 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
24 * SOFTWARE.
25 */
26
27#include <stdio.h>
28#include <stdlib.h>
29
30#include "tiffio.h"
31
32#define WIDTH 512
33#define HEIGHT WIDTH
34
35int main(int argc, char **argv)
36{
37 int i;
38 unsigned char * scan_line;
39 TIFF * tif;
40
41 if (argc != 2) {
42 fprintf(stderr, "Usage: %s tiff-image\n", argv[0]);
43 return 0;
44 }
45
46 if ((tif = TIFFOpen(argv[1], "w")) == NULL) {
47 fprintf(stderr, "can't open %s as a TIFF file\n", argv[1]);
48 return 0;
49 }
50
51 TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, WIDTH);
52 TIFFSetField(tif, TIFFTAG_IMAGELENGTH, HEIGHT);
53 TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 1);
54 TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
55 TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
56 TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
57 TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
58 TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
59 TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_NONE);
60
61 scan_line = (unsigned char *) malloc(WIDTH / 8);
62
63 for (i = 0; i < (WIDTH / 8) / 2; i++)
64 scan_line[i] = 0;
65
66 for (i = (WIDTH / 8) / 2; i < (WIDTH / 8); i++)
67 scan_line[i] = 255;
68
69 for (i = 0; i < HEIGHT / 2; i++)
70 TIFFWriteScanline(tif, scan_line, i, 0);
71
72 for (i = 0; i < (WIDTH / 8) / 2; i++)
73 scan_line[i] = 255;
74
75 for (i = (WIDTH / 8) / 2; i < (WIDTH / 8); i++)
76 scan_line[i] = 0;
77
78 for (i = HEIGHT / 2; i < HEIGHT; i++)
79 TIFFWriteScanline(tif, scan_line, i, 0);
80
81 free(scan_line);
82 TIFFClose(tif);
83 return 0;
84}