]> git.saurik.com Git - wxWidgets.git/blob - src/tiff/contrib/dbs/tiff-bi.c
wxMessageBox off the main thread lost result code.
[wxWidgets.git] / src / tiff / contrib / dbs / tiff-bi.c
1
2 /*
3 * tiff-bi.c -- create a Class B (bilevel) TIFF file
4 *
5 * Copyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
6 *
7 * All Rights Reserved
8 *
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.
16 *
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
23 * SOFTWARE.
24 */
25
26 #include <stdio.h>
27 #include <stdlib.h>
28
29 #include "tiffio.h"
30
31 #define WIDTH 512
32 #define HEIGHT WIDTH
33
34 int main(int argc, char **argv)
35 {
36 int i;
37 unsigned char * scan_line;
38 TIFF * tif;
39
40 if (argc != 2) {
41 fprintf(stderr, "Usage: %s tiff-image\n", argv[0]);
42 return 0;
43 }
44
45 if ((tif = TIFFOpen(argv[1], "w")) == NULL) {
46 fprintf(stderr, "can't open %s as a TIFF file\n", argv[1]);
47 return 0;
48 }
49
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);
59
60 scan_line = (unsigned char *) malloc(WIDTH / 8);
61
62 for (i = 0; i < (WIDTH / 8) / 2; i++)
63 scan_line[i] = 0;
64
65 for (i = (WIDTH / 8) / 2; i < (WIDTH / 8); i++)
66 scan_line[i] = 255;
67
68 for (i = 0; i < HEIGHT / 2; i++)
69 TIFFWriteScanline(tif, scan_line, i, 0);
70
71 for (i = 0; i < (WIDTH / 8) / 2; i++)
72 scan_line[i] = 255;
73
74 for (i = (WIDTH / 8) / 2; i < (WIDTH / 8); i++)
75 scan_line[i] = 0;
76
77 for (i = HEIGHT / 2; i < HEIGHT; i++)
78 TIFFWriteScanline(tif, scan_line, i, 0);
79
80 free(scan_line);
81 TIFFClose(tif);
82 return 0;
83 }
84 /*
85 * Local Variables:
86 * mode: c
87 * c-basic-offset: 8
88 * fill-column: 78
89 * End:
90 */