Binary files pdftexsrc-orig/pdftexsrc.tgz and pdftexsrc/pdftexsrc.tgz differ diff -urN pdftexsrc-orig/texk/web2c/pdftexdir/Makefile.in pdftexsrc/texk/web2c/pdftexdir/Makefile.in --- pdftexsrc-orig/texk/web2c/pdftexdir/Makefile.in Mon Feb 8 06:20:46 1999 +++ pdftexsrc/texk/web2c/pdftexdir/Makefile.in Fri Feb 12 13:26:55 1999 @@ -14,7 +14,7 @@ OBJS = epdf.o mapfile.o papersiz.o utils.o config.o vfpacket.o pkin.o \ writefont.o writet1.o writet3.o writezip.o writeenc.o writettf.o \ -writejpg.o writepng.o writeimg.o +writejpg.o writepng.o writetiff.o writeimg.o all: libpdf.a diff -urN pdftexsrc-orig/texk/web2c/pdftexdir/image.h pdftexsrc/texk/web2c/pdftexdir/image.h --- pdftexsrc-orig/texk/web2c/pdftexdir/image.h Thu Jan 7 16:30:11 1999 +++ pdftexsrc/texk/web2c/pdftexdir/image.h Fri Feb 12 13:27:56 1999 @@ -15,11 +15,13 @@ #endif /* PNG_LIBPNG_VER < 10001 */ #include "jpg.h" +#include "tiffx.h" #define PDF_INFO(N) (image_tab[N].image_struct.pdf) #define PNG_PTR(N) (image_tab[N].image_struct.png.png_ptr) #define PNG_INFO(N) (image_tab[N].image_struct.png.info_ptr) #define JPG_INFO(N) (image_tab[N].image_struct.jpg) +#define TIFF_INFO(N) (image_tab[N].image_struct.tiff) #define IMG_TYPE(N) (image_tab[N].image_type) #define IMG_NAME(N) (image_tab[N].image_name) #define IMG_REFCOUNT(N) (image_tab[N].ref_count) @@ -27,6 +29,7 @@ #define IMAGE_TYPE_PDF 0 #define IMAGE_TYPE_PNG 1 #define IMAGE_TYPE_JPG 2 +#define IMAGE_TYPE_TIFF 3 typedef struct { png_structp png_ptr; @@ -48,6 +51,7 @@ pdf_image_struct *pdf; png_image_struct png; JPG_IMAGE_INFO *jpg; + TIFF_IMAGE_INFO *tiff; } image_struct; } image_entry; @@ -62,3 +66,5 @@ extern void write_png(integer, integer); extern integer read_jpg_info(integer); extern void write_jpg(integer, integer); +extern integer read_tiff_info(integer); +extern void write_tiff(integer, integer); diff -urN pdftexsrc-orig/texk/web2c/pdftexdir/pdftex.ch pdftexsrc/texk/web2c/pdftexdir/pdftex.ch --- pdftexsrc-orig/texk/web2c/pdftexdir/pdftex.ch Wed Feb 3 08:52:27 1999 +++ pdftexsrc/texk/web2c/pdftexdir/pdftex.ch Fri Feb 12 13:28:22 1999 @@ -26,7 +26,7 @@ {printed when \pdfTeX\ starts} @d pdftex_version==13 { \.{\\pdftexversion} } @d pdftex_revision=="b" { \.{\\pdftexrevision} } -@d pdftex_version_string=='13b' {current pdf\TeX\ version} +@d pdftex_version_string=='13b-tiff' {current pdf\TeX\ version} @z % Some procedures that need to be declared forward diff -urN pdftexsrc-orig/texk/web2c/pdftexdir/tiffx.h pdftexsrc/texk/web2c/pdftexdir/tiffx.h --- pdftexsrc-orig/texk/web2c/pdftexdir/tiffx.h Thu Jan 1 01:00:00 1970 +++ pdftexsrc/texk/web2c/pdftexdir/tiffx.h Fri Feb 12 13:28:46 1999 @@ -0,0 +1,37 @@ +/* This is header file for TIFF support of pdfTeX. */ + +#include +#include +#include + +/* TIFF_IMAGE_INFO is main structure for interchange of image data */ + +typedef struct { + unsigned int width, /* width of image in pixels */ + height, /* height of image in pixels */ + x_res, /* horizontal resolution in dpi, 0 if unknown */ + y_res, /* vertical resolution in dpi, 0 if unknown */ + color_space; /* used color space. */ + unsigned char bits_per_component; /* bits per component */ + unsigned long length; /* length of file/data */ + FILE *file; /* TIFF file */ + } TIFF_IMAGE_INFO; + + +/* Function tiff_read_image_info opens specified file and reads informations + * into TIFF_IMAGE_INFO structure. + * + * Return value: 0 - OK + * 1 - Cannot open file for read + */ + +int tiff_read_image_info(TIFF_IMAGE_INFO *image_info,char *file_name); + + +/* Function tiff_read_image reads specified number of bytes into specified + * buffer. + * + * Return value: number of read bytes.0 - OK + */ + +unsigned int tiff_read_file(TIFF_IMAGE_INFO *image_info,unsigned char *buf,unsigned int num_of_bytes); diff -urN pdftexsrc-orig/texk/web2c/pdftexdir/writeimg.c pdftexsrc/texk/web2c/pdftexdir/writeimg.c --- pdftexsrc-orig/texk/web2c/pdftexdir/writeimg.c Fri Jan 15 10:27:40 1999 +++ pdftexsrc/texk/web2c/pdftexdir/writeimg.c Fri Feb 12 13:28:46 1999 @@ -47,6 +47,9 @@ case IMAGE_TYPE_JPG: xfclose(JPG_INFO(img)->file, filename); break; + case IMAGE_TYPE_TIFF: + TIFFClose((TIFF *) TIFF_INFO(img)->file); + break; case IMAGE_TYPE_PDF: epdf_xref = PDF_INFO(img)->xref; epdf_doc = PDF_INFO(img)->doc; @@ -68,6 +71,8 @@ return PNG_INFO(img)->width; case IMAGE_TYPE_JPG: return JPG_INFO(img)->width; + case IMAGE_TYPE_TIFF: + return TIFF_INFO(img)->width; case IMAGE_TYPE_PDF: return PDF_INFO(img)->width; default: @@ -82,6 +87,8 @@ return PNG_INFO(img)->height; case IMAGE_TYPE_JPG: return JPG_INFO(img)->height; + case IMAGE_TYPE_TIFF: + return TIFF_INFO(img)->height; case IMAGE_TYPE_PDF: return PDF_INFO(img)->height; default: @@ -99,6 +106,8 @@ return 0; case IMAGE_TYPE_JPG: return JPG_INFO(img)->x_res; + case IMAGE_TYPE_TIFF: + return TIFF_INFO(img)->x_res; case IMAGE_TYPE_PDF: return 0; default: @@ -116,6 +125,8 @@ return 0; case IMAGE_TYPE_JPG: return JPG_INFO(img)->y_res; + case IMAGE_TYPE_TIFF: + return TIFF_INFO(img)->y_res; case IMAGE_TYPE_PDF: return 0; default: @@ -177,6 +188,16 @@ } IMG_TYPE(img) = IMAGE_TYPE_JPG; } + else if (strcasecmp(strchr(filename, 0) - 4, ".tif") == 0) { + TIFF_INFO(img) = XTALLOC(1, TIFF_IMAGE_INFO); + switch (read_tiff_info(img)) { + case 0: + break; + default: + FAIL("reading TIFF image failed"); + } + IMG_TYPE(img) = IMAGE_TYPE_TIFF; + } else FAIL("unknown type of image"); return img; } @@ -191,6 +212,9 @@ break; case IMAGE_TYPE_JPG: write_jpg(n, img); + break; + case IMAGE_TYPE_TIFF: + write_tiff(n, img); break; case IMAGE_TYPE_PDF: epdf_xref = PDF_INFO(img)->xref; diff -urN pdftexsrc-orig/texk/web2c/pdftexdir/writetiff.c pdftexsrc/texk/web2c/pdftexdir/writetiff.c --- pdftexsrc-orig/texk/web2c/pdftexdir/writetiff.c Thu Jan 1 01:00:00 1970 +++ pdftexsrc/texk/web2c/pdftexdir/writetiff.c Fri Feb 12 13:28:46 1999 @@ -0,0 +1,82 @@ + +/* ----------------------------------------------------------------------- + * This is TIFF support to pdfTeX. + * ----------------------------------------------------------------------- + */ + +#include "libpdftex.h" +#include "image.h" + +/* Function tiff_read_image_info opens specified file and reads informations + * into TIFF_IMAGE_INFO structure. + * + * Return value: 0 - OK + * 1 - Cannot open file for read or not a TIFF file + */ + +integer read_tiff_info(integer img) +{ + TIFF_IMAGE_INFO *image_info = TIFF_INFO(img); + float xres=72.0, yres=72.0; /* default resolution */ + unsigned short units; + + image_info->file = (FILE *) TIFFOpen(IMG_NAME(img), FOPEN_RBIN_MODE); + + if (!image_info->file) + return 1; /* This is not a TIFF file */ + + image_info->x_res=image_info->y_res=0; + + TIFFGetField((TIFF *) image_info->file, TIFFTAG_IMAGELENGTH, &image_info->height); + TIFFGetField((TIFF *) image_info->file, TIFFTAG_IMAGEWIDTH, &image_info->width); + + TIFFGetField((TIFF *) image_info->file, TIFFTAG_XRESOLUTION, &xres); + TIFFGetField((TIFF *) image_info->file, TIFFTAG_YRESOLUTION, &yres); + TIFFGetField((TIFF *) image_info->file, TIFFTAG_RESOLUTIONUNIT, &units); + + switch (units) { + case RESUNIT_INCH: break; /* pixels per inch */ + case RESUNIT_CENTIMETER: xres*=2.54; yres*=2.54; + break; /* pixels per cm */ + case RESUNIT_NONE: xres=0;yres=0; break; /* no resolution */ + } + + image_info->x_res=xres; image_info->y_res=yres; + image_info->length=3*image_info->height*image_info->width; + image_info->color_space=0; + image_info->bits_per_component=8; + +return 0; +} + +void write_tiff(integer n, integer img) +{ + + long unsigned row, col; + unsigned long int *raster=(unsigned long int *) _TIFFmalloc(TIFF_INFO(img)->height*TIFF_INFO(img)->width*sizeof(unsigned long int)); + + pdfbegindict(n); + PDF_PRINTF("/Type /XObject\n/Subtype /Image\n/Width %li\n/Height %li\n/BitsPerComponent %li\n" AND + (long int)TIFF_INFO(img)->width AND + (long int)TIFF_INFO(img)->height AND + (long int)TIFF_INFO(img)->bits_per_component); + PDF_PRINTF("/ColorSpace /DeviceRGB\n"); + + TIFFReadRGBAImage((TIFF *) TIFF_INFO(img)->file, TIFF_INFO(img)->width, TIFF_INFO(img)->height, raster,0); + + pdfbeginstream(); + + for (row = 0; rowheight; row++) + for (col = 0; colwidth; col++) + { + if (pdfptr + 3 >= pdfbufsize) + pdfflush(); + + pdfbuf[pdfptr++] = TIFFGetR(*(raster+col+TIFF_INFO(img)->width*(TIFF_INFO(img)->height-1-row))); + pdfbuf[pdfptr++] = TIFFGetG(*(raster+col+TIFF_INFO(img)->width*(TIFF_INFO(img)->height-1-row))); + pdfbuf[pdfptr++] = TIFFGetB(*(raster+col+TIFF_INFO(img)->width*(TIFF_INFO(img)->height-1-row))); + } + + pdfflush(); + pdfendstream(); +}