|
roentgen |
b75cab |
/* $Id: tiff-bi.c,v 1.3 2010-06-08 18:55:15 bfriesen Exp $ */
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
/*
|
|
roentgen |
b75cab |
* tiff-bi.c -- create a Class B (bilevel) TIFF file
|
|
roentgen |
b75cab |
*
|
|
roentgen |
b75cab |
* Copyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
|
|
roentgen |
b75cab |
*
|
|
roentgen |
b75cab |
* All Rights Reserved
|
|
roentgen |
b75cab |
*
|
|
roentgen |
b75cab |
* Permission to use, copy, modify, and distribute this software and its
|
|
roentgen |
b75cab |
* documentation for any purpose and without fee is hereby granted,
|
|
roentgen |
b75cab |
* provided that the above copyright notice appear in all copies and that
|
|
roentgen |
b75cab |
* both that copyright notice and this permission notice appear in
|
|
roentgen |
b75cab |
* supporting documentation, and that the name of Digital not be
|
|
roentgen |
b75cab |
* used in advertising or publicity pertaining to distribution of the
|
|
roentgen |
b75cab |
* software without specific, written prior permission.
|
|
roentgen |
b75cab |
*
|
|
roentgen |
b75cab |
* DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
|
roentgen |
b75cab |
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
|
roentgen |
b75cab |
* DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
|
roentgen |
b75cab |
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
roentgen |
b75cab |
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
|
roentgen |
b75cab |
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
roentgen |
b75cab |
* SOFTWARE.
|
|
roentgen |
b75cab |
*/
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
#include <stdio.h></stdio.h>
|
|
roentgen |
b75cab |
#include <stdlib.h></stdlib.h>
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
#include "tiffio.h"
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
#define WIDTH 512
|
|
roentgen |
b75cab |
#define HEIGHT WIDTH
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
int main(int argc, char **argv)
|
|
roentgen |
b75cab |
{
|
|
roentgen |
b75cab |
int i;
|
|
roentgen |
b75cab |
unsigned char * scan_line;
|
|
roentgen |
b75cab |
TIFF * tif;
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
if (argc != 2) {
|
|
roentgen |
b75cab |
fprintf(stderr, "Usage: %s tiff-image\n", argv[0]);
|
|
roentgen |
b75cab |
return 0;
|
|
roentgen |
b75cab |
}
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
if ((tif = TIFFOpen(argv[1], "w")) == NULL) {
|
|
roentgen |
b75cab |
fprintf(stderr, "can't open %s as a TIFF file\n", argv[1]);
|
|
roentgen |
b75cab |
return 0;
|
|
roentgen |
b75cab |
}
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, WIDTH);
|
|
roentgen |
b75cab |
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, HEIGHT);
|
|
roentgen |
b75cab |
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 1);
|
|
roentgen |
b75cab |
TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
|
|
roentgen |
b75cab |
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
|
|
roentgen |
b75cab |
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
|
|
roentgen |
b75cab |
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
|
|
roentgen |
b75cab |
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
|
|
roentgen |
b75cab |
TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_NONE);
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
scan_line = (unsigned char *) malloc(WIDTH / 8);
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
for (i = 0; i < (WIDTH / 8) / 2; i++)
|
|
roentgen |
b75cab |
scan_line[i] = 0;
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
for (i = (WIDTH / 8) / 2; i < (WIDTH / 8); i++)
|
|
roentgen |
b75cab |
scan_line[i] = 255;
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
for (i = 0; i < HEIGHT / 2; i++)
|
|
roentgen |
b75cab |
TIFFWriteScanline(tif, scan_line, i, 0);
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
for (i = 0; i < (WIDTH / 8) / 2; i++)
|
|
roentgen |
b75cab |
scan_line[i] = 255;
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
for (i = (WIDTH / 8) / 2; i < (WIDTH / 8); i++)
|
|
roentgen |
b75cab |
scan_line[i] = 0;
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
for (i = HEIGHT / 2; i < HEIGHT; i++)
|
|
roentgen |
b75cab |
TIFFWriteScanline(tif, scan_line, i, 0);
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
free(scan_line);
|
|
roentgen |
b75cab |
TIFFClose(tif);
|
|
roentgen |
b75cab |
return 0;
|
|
roentgen |
b75cab |
}
|
|
roentgen |
b75cab |
/*
|
|
roentgen |
b75cab |
* Local Variables:
|
|
roentgen |
b75cab |
* mode: c
|
|
roentgen |
b75cab |
* c-basic-offset: 8
|
|
roentgen |
b75cab |
* fill-column: 78
|
|
roentgen |
b75cab |
* End:
|
|
roentgen |
b75cab |
*/
|