]>
git.saurik.com Git - wxWidgets.git/blob - src/tiff/contrib/dbs/tiff-bi.c
4 * tiff-bi.c -- create a Class B (bilevel) TIFF file
6 * Copyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
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.
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
35 int main(int argc
, char **argv
)
38 unsigned char * scan_line
;
42 fprintf(stderr
, "Usage: %s tiff-image\n", argv
[0]);
46 if ((tif
= TIFFOpen(argv
[1], "w")) == NULL
) {
47 fprintf(stderr
, "can't open %s as a TIFF file\n", argv
[1]);
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
);
61 scan_line
= (unsigned char *) malloc(WIDTH
/ 8);
63 for (i
= 0; i
< (WIDTH
/ 8) / 2; i
++)
66 for (i
= (WIDTH
/ 8) / 2; i
< (WIDTH
/ 8); i
++)
69 for (i
= 0; i
< HEIGHT
/ 2; i
++)
70 TIFFWriteScanline(tif
, scan_line
, i
, 0);
72 for (i
= 0; i
< (WIDTH
/ 8) / 2; i
++)
75 for (i
= (WIDTH
/ 8) / 2; i
< (WIDTH
/ 8); i
++)
78 for (i
= HEIGHT
/ 2; i
< HEIGHT
; i
++)
79 TIFFWriteScanline(tif
, scan_line
, i
, 0);