]>
git.saurik.com Git - wxWidgets.git/blob - src/tiff/contrib/dbs/tiff-bi.c
3 * tiff-bi.c -- create a Class B (bilevel) TIFF file
5 * Copyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
9 * Permission to use, copy, modify, and distribute this software and its
10 * documentation for any purpose and without fee is hereby granted,
11 * provided that the above copyright notice appear in all copies and that
12 * both that copyright notice and this permission notice appear in
13 * supporting documentation, and that the name of Digital not be
14 * used in advertising or publicity pertaining to distribution of the
15 * software without specific, written prior permission.
17 * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
18 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
19 * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
20 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
21 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
22 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
34 int main(int argc
, char **argv
)
37 unsigned char * scan_line
;
41 fprintf(stderr
, "Usage: %s tiff-image\n", argv
[0]);
45 if ((tif
= TIFFOpen(argv
[1], "w")) == NULL
) {
46 fprintf(stderr
, "can't open %s as a TIFF file\n", argv
[1]);
50 TIFFSetField(tif
, TIFFTAG_IMAGEWIDTH
, WIDTH
);
51 TIFFSetField(tif
, TIFFTAG_IMAGELENGTH
, HEIGHT
);
52 TIFFSetField(tif
, TIFFTAG_BITSPERSAMPLE
, 1);
53 TIFFSetField(tif
, TIFFTAG_COMPRESSION
, COMPRESSION_NONE
);
54 TIFFSetField(tif
, TIFFTAG_PHOTOMETRIC
, PHOTOMETRIC_MINISBLACK
);
55 TIFFSetField(tif
, TIFFTAG_SAMPLESPERPIXEL
, 1);
56 TIFFSetField(tif
, TIFFTAG_ROWSPERSTRIP
, 1);
57 TIFFSetField(tif
, TIFFTAG_PLANARCONFIG
, PLANARCONFIG_CONTIG
);
58 TIFFSetField(tif
, TIFFTAG_RESOLUTIONUNIT
, RESUNIT_NONE
);
60 scan_line
= (unsigned char *) malloc(WIDTH
/ 8);
62 for (i
= 0; i
< (WIDTH
/ 8) / 2; i
++)
65 for (i
= (WIDTH
/ 8) / 2; i
< (WIDTH
/ 8); i
++)
68 for (i
= 0; i
< HEIGHT
/ 2; i
++)
69 TIFFWriteScanline(tif
, scan_line
, i
, 0);
71 for (i
= 0; i
< (WIDTH
/ 8) / 2; i
++)
74 for (i
= (WIDTH
/ 8) / 2; i
< (WIDTH
/ 8); i
++)
77 for (i
= HEIGHT
/ 2; i
< HEIGHT
; i
++)
78 TIFFWriteScanline(tif
, scan_line
, i
, 0);