Initial import
git-svn-id: http://moon:8086/svn/software/trunk/libsrc/libtiff_2007@1 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#
|
||||
# Imakefile -- to generate a Makefile, do xmkmf
|
||||
#
|
||||
TIFF = ../../libtiff
|
||||
EXTRA_LIBRARIES = $(TIFF)/libtiff.a
|
||||
EXTRA_INCLUDES = -I$(TIFF)
|
||||
|
||||
AllTarget(bi gray pal rgb)
|
||||
NormalProgramTarget(bi,tiff-bi.o,,,)
|
||||
NormalProgramTarget(gray,tiff-grayscale.o,,,-lm)
|
||||
NormalProgramTarget(pal,tiff-palette.o,,,)
|
||||
NormalProgramTarget(rgb,tiff-rgb.o,,,-lm)
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
Wed May 9 09:11:35 PDT 1990
|
||||
|
||||
This directory contains programs from Dan Sears
|
||||
(dbs@decwrl.dec.com). Contact him directly if
|
||||
you have questions/problems.
|
||||
|
||||
Sam
|
||||
Executable
+85
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* tiff-bi.c -- create a Class B (bilevel) TIFF file
|
||||
*
|
||||
* Copyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
|
||||
*
|
||||
* All Rights Reserved
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted,
|
||||
* provided that the above copyright notice appear in all copies and that
|
||||
* both that copyright notice and this permission notice appear in
|
||||
* supporting documentation, and that the name of Digital not be
|
||||
* used in advertising or publicity pertaining to distribution of the
|
||||
* software without specific, written prior permission.
|
||||
*
|
||||
* DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
||||
* DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
||||
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <tiffio.h>
|
||||
|
||||
#define WIDTH 512
|
||||
#define HEIGHT WIDTH
|
||||
|
||||
typedef unsigned char u_char;
|
||||
|
||||
void
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char ** argv;
|
||||
{
|
||||
int i;
|
||||
u_char * scan_line;
|
||||
TIFF * tif;
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "Usage: %s tiff-image\n", argv[0]);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ((tif = TIFFOpen(argv[1], "w")) == NULL) {
|
||||
fprintf(stderr, "can't open %s as a TIFF file\n", argv[1]);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, WIDTH);
|
||||
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, HEIGHT);
|
||||
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 1);
|
||||
TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
|
||||
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
|
||||
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
|
||||
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
|
||||
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
|
||||
TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_NONE);
|
||||
|
||||
scan_line = (u_char *) malloc(WIDTH / 8);
|
||||
|
||||
for (i = 0; i < (WIDTH / 8) / 2; i++)
|
||||
scan_line[i] = 0;
|
||||
|
||||
for (i = (WIDTH / 8) / 2; i < (WIDTH / 8); i++)
|
||||
scan_line[i] = 255;
|
||||
|
||||
for (i = 0; i < HEIGHT / 2; i++)
|
||||
TIFFWriteScanline(tif, scan_line, i, 0);
|
||||
|
||||
for (i = 0; i < (WIDTH / 8) / 2; i++)
|
||||
scan_line[i] = 255;
|
||||
|
||||
for (i = (WIDTH / 8) / 2; i < (WIDTH / 8); i++)
|
||||
scan_line[i] = 0;
|
||||
|
||||
for (i = HEIGHT / 2; i < HEIGHT; i++)
|
||||
TIFFWriteScanline(tif, scan_line, i, 0);
|
||||
|
||||
free(scan_line);
|
||||
TIFFClose(tif);
|
||||
exit(0);
|
||||
}
|
||||
Executable
+141
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* tiff-grayscale.c -- create a Class G (grayscale) TIFF file
|
||||
* with a gray response curve in linear optical density
|
||||
*
|
||||
* Copyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
|
||||
*
|
||||
* All Rights Reserved
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted,
|
||||
* provided that the above copyright notice appear in all copies and that
|
||||
* both that copyright notice and this permission notice appear in
|
||||
* supporting documentation, and that the name of Digital not be
|
||||
* used in advertising or publicity pertaining to distribution of the
|
||||
* software without specific, written prior permission.
|
||||
*
|
||||
* DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
||||
* DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
||||
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <tiffio.h>
|
||||
|
||||
#define WIDTH 512
|
||||
#define HEIGHT WIDTH
|
||||
|
||||
typedef unsigned char u_char;
|
||||
typedef unsigned short u_short;
|
||||
typedef unsigned long u_long;
|
||||
|
||||
char * programName;
|
||||
void Usage();
|
||||
|
||||
void
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char ** argv;
|
||||
{
|
||||
int bits_per_pixel, cmsize, i, j, k,
|
||||
gray_index, chunk_size, nchunks;
|
||||
u_char * scan_line;
|
||||
u_short * gray;
|
||||
u_long refblackwhite[2*1];
|
||||
TIFF * tif;
|
||||
|
||||
programName = argv[0];
|
||||
|
||||
if (argc != 4)
|
||||
Usage();
|
||||
|
||||
if (!strcmp(argv[1], "-depth"))
|
||||
bits_per_pixel = atoi(argv[2]);
|
||||
else
|
||||
Usage();
|
||||
|
||||
switch (bits_per_pixel) {
|
||||
case 8:
|
||||
nchunks = 16;
|
||||
chunk_size = 32;
|
||||
break;
|
||||
case 4:
|
||||
nchunks = 4;
|
||||
chunk_size = 128;
|
||||
break;
|
||||
case 2:
|
||||
nchunks = 2;
|
||||
chunk_size = 256;
|
||||
break;
|
||||
default:
|
||||
Usage();
|
||||
}
|
||||
|
||||
cmsize = nchunks * nchunks;
|
||||
gray = (u_short *) malloc(cmsize * sizeof(u_short));
|
||||
|
||||
gray[0] = 3000;
|
||||
for (i = 1; i < cmsize; i++)
|
||||
gray[i] = (u_short) (-log10((double) i / (cmsize - 1)) * 1000);
|
||||
|
||||
refblackwhite[0] = 0;
|
||||
refblackwhite[0] = (1L<<bits_per_pixel) - 1;
|
||||
|
||||
if ((tif = TIFFOpen(argv[3], "w")) == NULL) {
|
||||
fprintf(stderr, "can't open %s as a TIFF file\n", argv[3]);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, WIDTH);
|
||||
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, HEIGHT);
|
||||
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bits_per_pixel);
|
||||
TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
|
||||
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
|
||||
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
|
||||
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
|
||||
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
|
||||
TIFFSetField(tif, TIFFTAG_REFERENCEBLACKWHITE, refblackwhite);
|
||||
TIFFSetField(tif, TIFFTAG_TRANSFERFUNCTION, gray);
|
||||
TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_NONE);
|
||||
|
||||
scan_line = (u_char *) malloc(WIDTH / (8 / bits_per_pixel));
|
||||
|
||||
for (i = 0; i < HEIGHT; i++) {
|
||||
for (j = 0, k = 0; j < WIDTH;) {
|
||||
gray_index = (j / chunk_size) + ((i / chunk_size) * nchunks);
|
||||
|
||||
switch (bits_per_pixel) {
|
||||
case 8:
|
||||
scan_line[k++] = gray_index;
|
||||
j++;
|
||||
break;
|
||||
case 4:
|
||||
scan_line[k++] = (gray_index << 4) + gray_index;
|
||||
j += 2;
|
||||
break;
|
||||
case 2:
|
||||
scan_line[k++] = (gray_index << 6) + (gray_index << 4)
|
||||
+ (gray_index << 2) + gray_index;
|
||||
j += 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
TIFFWriteScanline(tif, scan_line, i, 0);
|
||||
}
|
||||
|
||||
free(scan_line);
|
||||
TIFFClose(tif);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
Usage()
|
||||
{
|
||||
fprintf(stderr, "Usage: %s -depth (8 | 4 | 2) tiff-image\n", programName);
|
||||
exit(0);
|
||||
}
|
||||
Executable
+277
@@ -0,0 +1,277 @@
|
||||
/*
|
||||
* tiff-palette.c -- create a Class P (palette) TIFF file
|
||||
*
|
||||
* Copyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
|
||||
*
|
||||
* All Rights Reserved
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted,
|
||||
* provided that the above copyright notice appear in all copies and that
|
||||
* both that copyright notice and this permission notice appear in
|
||||
* supporting documentation, and that the name of Digital not be
|
||||
* used in advertising or publicity pertaining to distribution of the
|
||||
* software without specific, written prior permission.
|
||||
*
|
||||
* DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
||||
* DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
||||
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <tiffio.h>
|
||||
|
||||
#define WIDTH 512
|
||||
#define HEIGHT WIDTH
|
||||
#define SCALE(x) ((x) * 257L)
|
||||
|
||||
typedef unsigned char u_char;
|
||||
typedef unsigned short u_short;
|
||||
|
||||
char * programName;
|
||||
void Usage();
|
||||
|
||||
void
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char ** argv;
|
||||
{
|
||||
int bits_per_pixel, cmsize, i, j, k,
|
||||
cmap_index, chunk_size, nchunks;
|
||||
u_char * scan_line;
|
||||
u_short *red, *green, *blue;
|
||||
TIFF * tif;
|
||||
|
||||
programName = argv[0];
|
||||
|
||||
if (argc != 4)
|
||||
Usage();
|
||||
|
||||
if (!strcmp(argv[1], "-depth"))
|
||||
bits_per_pixel = atoi(argv[2]);
|
||||
else
|
||||
Usage();
|
||||
|
||||
switch (bits_per_pixel) {
|
||||
case 8:
|
||||
nchunks = 16;
|
||||
chunk_size = 32;
|
||||
break;
|
||||
case 4:
|
||||
nchunks = 4;
|
||||
chunk_size = 128;
|
||||
break;
|
||||
case 2:
|
||||
nchunks = 2;
|
||||
chunk_size = 256;
|
||||
break;
|
||||
case 1:
|
||||
nchunks = 2;
|
||||
chunk_size = 256;
|
||||
break;
|
||||
default:
|
||||
Usage();
|
||||
}
|
||||
|
||||
if (bits_per_pixel != 1) {
|
||||
cmsize = nchunks * nchunks;
|
||||
} else {
|
||||
cmsize = 2;
|
||||
}
|
||||
red = (u_short *) malloc(cmsize * sizeof(u_short));
|
||||
green = (u_short *) malloc(cmsize * sizeof(u_short));
|
||||
blue = (u_short *) malloc(cmsize * sizeof(u_short));
|
||||
|
||||
switch (bits_per_pixel) {
|
||||
case 8:
|
||||
for (i = 0; i < cmsize; i++) {
|
||||
if (i < 32)
|
||||
red[i] = 0;
|
||||
else if (i < 64)
|
||||
red[i] = SCALE(36);
|
||||
else if (i < 96)
|
||||
red[i] = SCALE(73);
|
||||
else if (i < 128)
|
||||
red[i] = SCALE(109);
|
||||
else if (i < 160)
|
||||
red[i] = SCALE(146);
|
||||
else if (i < 192)
|
||||
red[i] = SCALE(182);
|
||||
else if (i < 224)
|
||||
red[i] = SCALE(219);
|
||||
else if (i < 256)
|
||||
red[i] = SCALE(255);
|
||||
|
||||
if ((i % 32) < 4)
|
||||
green[i] = 0;
|
||||
else if (i < 8)
|
||||
green[i] = SCALE(36);
|
||||
else if ((i % 32) < 12)
|
||||
green[i] = SCALE(73);
|
||||
else if ((i % 32) < 16)
|
||||
green[i] = SCALE(109);
|
||||
else if ((i % 32) < 20)
|
||||
green[i] = SCALE(146);
|
||||
else if ((i % 32) < 24)
|
||||
green[i] = SCALE(182);
|
||||
else if ((i % 32) < 28)
|
||||
green[i] = SCALE(219);
|
||||
else if ((i % 32) < 32)
|
||||
green[i] = SCALE(255);
|
||||
|
||||
if ((i % 4) == 0)
|
||||
blue[i] = SCALE(0);
|
||||
else if ((i % 4) == 1)
|
||||
blue[i] = SCALE(85);
|
||||
else if ((i % 4) == 2)
|
||||
blue[i] = SCALE(170);
|
||||
else if ((i % 4) == 3)
|
||||
blue[i] = SCALE(255);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
red[0] = SCALE(255);
|
||||
green[0] = 0;
|
||||
blue[0] = 0;
|
||||
|
||||
red[1] = 0;
|
||||
green[1] = SCALE(255);
|
||||
blue[1] = 0;
|
||||
|
||||
red[2] = 0;
|
||||
green[2] = 0;
|
||||
blue[2] = SCALE(255);
|
||||
|
||||
red[3] = SCALE(255);
|
||||
green[3] = SCALE(255);
|
||||
blue[3] = SCALE(255);
|
||||
|
||||
red[4] = 0;
|
||||
green[4] = SCALE(255);
|
||||
blue[4] = SCALE(255);
|
||||
|
||||
red[5] = SCALE(255);
|
||||
green[5] = 0;
|
||||
blue[5] = SCALE(255);
|
||||
|
||||
red[6] = SCALE(255);
|
||||
green[6] = SCALE(255);
|
||||
blue[6] = 0;
|
||||
|
||||
red[7] = 0;
|
||||
green[7] = 0;
|
||||
blue[7] = 0;
|
||||
|
||||
red[8] = SCALE(176);
|
||||
green[8] = SCALE(224);
|
||||
blue[8] = SCALE(230);
|
||||
red[9] = SCALE(100);
|
||||
green[9] = SCALE(149);
|
||||
blue[9] = SCALE(237);
|
||||
red[10] = SCALE(46);
|
||||
green[10] = SCALE(139);
|
||||
blue[10] = SCALE(87);
|
||||
red[11] = SCALE(160);
|
||||
green[11] = SCALE(82);
|
||||
blue[11] = SCALE(45);
|
||||
red[12] = SCALE(238);
|
||||
green[12] = SCALE(130);
|
||||
blue[12] = SCALE(238);
|
||||
red[13] = SCALE(176);
|
||||
green[13] = SCALE(48);
|
||||
blue[13] = SCALE(96);
|
||||
red[14] = SCALE(50);
|
||||
green[14] = SCALE(205);
|
||||
blue[14] = SCALE(50);
|
||||
red[15] = SCALE(240);
|
||||
green[15] = SCALE(152);
|
||||
blue[15] = SCALE(35);
|
||||
break;
|
||||
case 2:
|
||||
red[0] = SCALE(255);
|
||||
green[0] = 0;
|
||||
blue[0] = 0;
|
||||
|
||||
red[1] = 0;
|
||||
green[1] = SCALE(255);
|
||||
blue[1] = 0;
|
||||
|
||||
red[2] = 0;
|
||||
green[2] = 0;
|
||||
blue[2] = SCALE(255);
|
||||
red[3] = SCALE(255);
|
||||
green[3] = SCALE(255);
|
||||
blue[3] = SCALE(255);
|
||||
break;
|
||||
case 1:
|
||||
red[0] = 0;
|
||||
green[0] = 0;
|
||||
blue[0] = 0;
|
||||
|
||||
red[1] = SCALE(255);
|
||||
green[1] = SCALE(255);
|
||||
blue[1] = SCALE(255);
|
||||
break;
|
||||
}
|
||||
|
||||
if ((tif = TIFFOpen(argv[3], "w")) == NULL) {
|
||||
fprintf(stderr, "can't open %s as a TIFF file\n", argv[3]);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, WIDTH);
|
||||
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, HEIGHT);
|
||||
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bits_per_pixel);
|
||||
TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
|
||||
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE);
|
||||
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
|
||||
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
|
||||
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
|
||||
TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_NONE);
|
||||
TIFFSetField(tif, TIFFTAG_COLORMAP, red, green, blue);
|
||||
|
||||
scan_line = (u_char *) malloc(WIDTH / (8 / bits_per_pixel));
|
||||
|
||||
for (i = 0; i < HEIGHT; i++) {
|
||||
for (j = 0, k = 0; j < WIDTH;) {
|
||||
cmap_index = (j / chunk_size) + ((i / chunk_size) * nchunks);
|
||||
|
||||
switch (bits_per_pixel) {
|
||||
case 8:
|
||||
scan_line[k++] = cmap_index;
|
||||
j++;
|
||||
break;
|
||||
case 4:
|
||||
scan_line[k++] = (cmap_index << 4) + cmap_index;
|
||||
j += 2;
|
||||
break;
|
||||
case 2:
|
||||
scan_line[k++] = (cmap_index << 6) + (cmap_index << 4)
|
||||
+ (cmap_index << 2) + cmap_index;
|
||||
j += 4;
|
||||
break;
|
||||
case 1:
|
||||
scan_line[k++] =
|
||||
((j / chunk_size) == (i / chunk_size)) ? 0x00 : 0xff;
|
||||
j += 8;
|
||||
break;
|
||||
}
|
||||
}
|
||||
TIFFWriteScanline(tif, scan_line, i, 0);
|
||||
}
|
||||
|
||||
free(scan_line);
|
||||
TIFFClose(tif);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
Usage()
|
||||
{
|
||||
fprintf(stderr, "Usage: %s -depth (8 | 4 | 2 | 1) tiff-image\n", programName);
|
||||
exit(0);
|
||||
}
|
||||
Executable
+196
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
* tiff-rgb.c -- create a 24-bit Class R (rgb) TIFF file
|
||||
*
|
||||
* Copyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
|
||||
*
|
||||
* All Rights Reserved
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted,
|
||||
* provided that the above copyright notice appear in all copies and that
|
||||
* both that copyright notice and this permission notice appear in
|
||||
* supporting documentation, and that the name of Digital not be
|
||||
* used in advertising or publicity pertaining to distribution of the
|
||||
* software without specific, written prior permission.
|
||||
*
|
||||
* DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
||||
* DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
||||
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <tiffio.h>
|
||||
|
||||
#define ROUND(x) (u_short) ((x) + 0.5)
|
||||
#define CMSIZE 256
|
||||
#define WIDTH 525
|
||||
#define HEIGHT 512
|
||||
#define TIFF_GAMMA 2.2
|
||||
|
||||
typedef unsigned char u_char;
|
||||
typedef unsigned short u_short;
|
||||
typedef unsigned long u_long;
|
||||
|
||||
void Usage();
|
||||
char * programName;
|
||||
|
||||
void
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char ** argv;
|
||||
{
|
||||
char * input_file;
|
||||
double image_gamma;
|
||||
int i, j;
|
||||
TIFF * tif;
|
||||
u_char * scan_line;
|
||||
u_short red[CMSIZE], green[CMSIZE], blue[CMSIZE];
|
||||
u_long refblackwhite[2*3];
|
||||
|
||||
programName = argv[0];
|
||||
|
||||
switch (argc) {
|
||||
case 2:
|
||||
image_gamma = TIFF_GAMMA;
|
||||
input_file = argv[1];
|
||||
break;
|
||||
case 4:
|
||||
if (!strcmp(argv[1], "-gamma")) {
|
||||
image_gamma = atof(argv[2]);
|
||||
input_file = argv[3];
|
||||
} else
|
||||
Usage();
|
||||
break;
|
||||
default:
|
||||
Usage();
|
||||
}
|
||||
|
||||
for (i = 0; i < CMSIZE; i++) {
|
||||
if (i == 0)
|
||||
red[i] = green[i] = blue[i] = 0;
|
||||
else {
|
||||
red[i] = ROUND((pow(i / 255.0, 1.0 / image_gamma) * 65535.0));
|
||||
green[i] = ROUND((pow(i / 255.0, 1.0 / image_gamma) * 65535.0));
|
||||
blue[i] = ROUND((pow(i / 255.0, 1.0 / image_gamma) * 65535.0));
|
||||
}
|
||||
}
|
||||
refblackwhite[0] = 0; refblackwhite[1] = 255;
|
||||
refblackwhite[2] = 0; refblackwhite[3] = 255;
|
||||
refblackwhite[4] = 0; refblackwhite[5] = 255;
|
||||
|
||||
if ((tif = TIFFOpen(input_file, "w")) == NULL) {
|
||||
fprintf(stderr, "can't open %s as a TIFF file\n", input_file);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, WIDTH);
|
||||
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, HEIGHT);
|
||||
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
|
||||
TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
|
||||
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
|
||||
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3);
|
||||
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
|
||||
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
|
||||
TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_NONE);
|
||||
#ifdef notdef
|
||||
TIFFSetField(tif, TIFFTAG_WHITEPOINT, whitex, whitey);
|
||||
TIFFSetField(tif, TIFFTAG_PRIMARYCHROMATICITIES, primaries);
|
||||
#endif
|
||||
TIFFSetField(tif, TIFFTAG_REFERENCEBLACKWHITE, refblackwhite);
|
||||
TIFFSetField(tif, TIFFTAG_TRANSFERFUNCTION, red, green, blue);
|
||||
|
||||
scan_line = (u_char *) malloc(WIDTH * 3);
|
||||
|
||||
for (i = 0; i < 255; i++) {
|
||||
for (j = 0; j < 75; j++) {
|
||||
scan_line[j * 3] = 255;
|
||||
scan_line[(j * 3) + 1] = 255 - i;
|
||||
scan_line[(j * 3) + 2] = 255 - i;
|
||||
}
|
||||
for (j = 75; j < 150; j++) {
|
||||
scan_line[j * 3] = 255 - i;
|
||||
scan_line[(j * 3) + 1] = 255;
|
||||
scan_line[(j * 3) + 2] = 255 - i;
|
||||
}
|
||||
for (j = 150; j < 225; j++) {
|
||||
scan_line[j * 3] = 255 - i;
|
||||
scan_line[(j * 3) + 1] = 255 - i;
|
||||
scan_line[(j * 3) + 2] = 255;
|
||||
}
|
||||
for (j = 225; j < 300; j++) {
|
||||
scan_line[j * 3] = (i - 1) / 2;
|
||||
scan_line[(j * 3) + 1] = (i - 1) / 2;
|
||||
scan_line[(j * 3) + 2] = (i - 1) / 2;
|
||||
}
|
||||
for (j = 300; j < 375; j++) {
|
||||
scan_line[j * 3] = 255 - i;
|
||||
scan_line[(j * 3) + 1] = 255;
|
||||
scan_line[(j * 3) + 2] = 255;
|
||||
}
|
||||
for (j = 375; j < 450; j++) {
|
||||
scan_line[j * 3] = 255;
|
||||
scan_line[(j * 3) + 1] = 255 - i;
|
||||
scan_line[(j * 3) + 2] = 255;
|
||||
}
|
||||
for (j = 450; j < 525; j++) {
|
||||
scan_line[j * 3] = 255;
|
||||
scan_line[(j * 3) + 1] = 255;
|
||||
scan_line[(j * 3) + 2] = 255 - i;
|
||||
}
|
||||
TIFFWriteScanline(tif, scan_line, i, 0);
|
||||
}
|
||||
for (i = 255; i < 512; i++) {
|
||||
for (j = 0; j < 75; j++) {
|
||||
scan_line[j * 3] = i;
|
||||
scan_line[(j * 3) + 1] = 0;
|
||||
scan_line[(j * 3) + 2] = 0;
|
||||
}
|
||||
for (j = 75; j < 150; j++) {
|
||||
scan_line[j * 3] = 0;
|
||||
scan_line[(j * 3) + 1] = i;
|
||||
scan_line[(j * 3) + 2] = 0;
|
||||
}
|
||||
for (j = 150; j < 225; j++) {
|
||||
scan_line[j * 3] = 0;
|
||||
scan_line[(j * 3) + 1] = 0;
|
||||
scan_line[(j * 3) + 2] = i;
|
||||
}
|
||||
for (j = 225; j < 300; j++) {
|
||||
scan_line[j * 3] = (i - 1) / 2;
|
||||
scan_line[(j * 3) + 1] = (i - 1) / 2;
|
||||
scan_line[(j * 3) + 2] = (i - 1) / 2;
|
||||
}
|
||||
for (j = 300; j < 375; j++) {
|
||||
scan_line[j * 3] = 0;
|
||||
scan_line[(j * 3) + 1] = i;
|
||||
scan_line[(j * 3) + 2] = i;
|
||||
}
|
||||
for (j = 375; j < 450; j++) {
|
||||
scan_line[j * 3] = i;
|
||||
scan_line[(j * 3) + 1] = 0;
|
||||
scan_line[(j * 3) + 2] = i;
|
||||
}
|
||||
for (j = 450; j < 525; j++) {
|
||||
scan_line[j * 3] = i;
|
||||
scan_line[(j * 3) + 1] = i;
|
||||
scan_line[(j * 3) + 2] = 0;
|
||||
}
|
||||
TIFFWriteScanline(tif, scan_line, i, 0);
|
||||
}
|
||||
|
||||
free(scan_line);
|
||||
TIFFClose(tif);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
Usage()
|
||||
{
|
||||
fprintf(stderr, "Usage: %s -gamma gamma tiff-image\n", programName);
|
||||
exit(0);
|
||||
}
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#
|
||||
# Imakefile -- to generate a Makefile for xtiff, use:
|
||||
# /usr/local/X11/mit/config/imake \
|
||||
# -I/usr/local/X11/mit/config \
|
||||
# -DTOPDIR=/usr/local/X11/mit \
|
||||
# -DCURDIR=/usr/local/X11/mit \
|
||||
# -DDESTDIR=/usr/local/X11/mit
|
||||
#
|
||||
|
||||
SYS_LIBRARIES = -lm
|
||||
LOCAL_LIBRARIES = XawClientLibs
|
||||
DEPLIBS = XawClientDepLibs
|
||||
TIFF = ../../../libtiff
|
||||
EXTRA_LIBRARIES = $(TIFF)/libtiff.so -lm
|
||||
EXTRA_INCLUDES = -I$(TIFF)
|
||||
|
||||
SimpleProgramTarget(xtiff)
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
#define PATCHLEVEL 0
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
xtiff 2.0
|
||||
|
||||
xtiff is a tool for viewing a TIFF file in an X window. It was written to
|
||||
handle as many different kinds of TIFF files as possible while remaining
|
||||
simple, portable and efficient. xtiff requires X11 R4, the Athena Widgets
|
||||
and Sam Leffler's libtiff package (which can be found on ucbvax.berkeley.edu).
|
||||
Executable
+1275
File diff suppressed because it is too large
Load Diff
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#define xtifficon_width 32
|
||||
#define xtifficon_height 32
|
||||
static char xtifficon_bits[] = {
|
||||
0xff, 0x00, 0x00, 0xc0, 0xfe, 0x01, 0x7e, 0xc0, 0xfc, 0x03, 0x7e, 0x60,
|
||||
0xf8, 0x07, 0x06, 0x30, 0xf8, 0x07, 0x1e, 0x18, 0xf0, 0x0f, 0x1e, 0x0c,
|
||||
0xe0, 0x1f, 0x06, 0x06, 0xc0, 0x3f, 0x06, 0x06, 0xc0, 0x3f, 0x06, 0x03,
|
||||
0x80, 0x7f, 0x80, 0x01, 0x00, 0xff, 0xc0, 0x00, 0x00, 0xfe, 0x61, 0x00,
|
||||
0x00, 0xfe, 0x31, 0x7e, 0x7e, 0xfc, 0x33, 0x7e, 0x7e, 0xf8, 0x1b, 0x06,
|
||||
0x18, 0xf0, 0x0d, 0x1e, 0x18, 0xf0, 0x0e, 0x1e, 0x18, 0x60, 0x1f, 0x06,
|
||||
0x18, 0xb0, 0x3f, 0x06, 0x18, 0x98, 0x7f, 0x06, 0x18, 0x98, 0x7f, 0x00,
|
||||
0x00, 0x0c, 0xff, 0x00, 0x00, 0x06, 0xfe, 0x01, 0x00, 0x63, 0xfc, 0x03,
|
||||
0x80, 0x61, 0xfc, 0x03, 0xc0, 0x60, 0xf8, 0x07, 0xc0, 0x60, 0xf0, 0x0f,
|
||||
0x60, 0x60, 0xe0, 0x1f, 0x30, 0x60, 0xe0, 0x1f, 0x18, 0x60, 0xc0, 0x3f,
|
||||
0x0c, 0x60, 0x80, 0x7f, 0x06, 0x00, 0x00, 0xff};
|
||||
Reference in New Issue
Block a user