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
+165
@@ -0,0 +1,165 @@
|
||||
# Project: LibTIFF
|
||||
|
||||
|
||||
# Toolflags:
|
||||
CCflags = -c -zo -ffah -depend !Depend -IC:
|
||||
C++flags = -c -depend !Depend -IC: -throwback
|
||||
Linkflags = -aif -c++ -o $@
|
||||
DrLinkflags = -nounused -aif -c++ -o $@
|
||||
ObjAsmflags = -throwback -NoCache -depend !Depend
|
||||
CMHGflags =
|
||||
LibFileflags = -c -o $@
|
||||
Squeezeflags = -o $@
|
||||
|
||||
|
||||
# Final targets:
|
||||
@.o.LIBTIFF: \
|
||||
@.o.tif_acorn \
|
||||
@.o.tif_aux \
|
||||
@.o.tif_close \
|
||||
@.o.tif_codec \
|
||||
@.o.tif_compress \
|
||||
@.o.tif_dir \
|
||||
@.o.tif_dirinfo \
|
||||
@.o.tif_dirread \
|
||||
@.o.tif_dirwrite \
|
||||
@.o.tif_dumpmode \
|
||||
@.o.tif_error \
|
||||
@.o.tif_fax3 \
|
||||
@.o.tif_flush \
|
||||
@.o.tif_getimage \
|
||||
@.o.tif_jpeg \
|
||||
@.o.tif_lzw \
|
||||
@.o.tif_next \
|
||||
@.o.tif_open \
|
||||
@.o.tif_packbits \
|
||||
@.o.tif_predict \
|
||||
@.o.tif_print \
|
||||
@.o.tif_read \
|
||||
@.o.tif_strip \
|
||||
@.o.tif_swab \
|
||||
@.o.tif_thunder \
|
||||
@.o.tif_tile \
|
||||
@.o.tif_version \
|
||||
@.o.tif_warning \
|
||||
@.o.tif_write \
|
||||
@.o.tif_zip \
|
||||
@.o.tif_fax3sm \
|
||||
@.h.version
|
||||
LibFile $(LibFileflags) \
|
||||
@.o.tif_acorn \
|
||||
@.o.tif_aux \
|
||||
@.o.tif_close \
|
||||
@.o.tif_codec \
|
||||
@.o.tif_compress \
|
||||
@.o.tif_dir \
|
||||
@.o.tif_dirinfo \
|
||||
@.o.tif_dirread \
|
||||
@.o.tif_dirwrite \
|
||||
@.o.tif_dumpmode \
|
||||
@.o.tif_error \
|
||||
@.o.tif_fax3 \
|
||||
@.o.tif_flush \
|
||||
@.o.tif_getimage \
|
||||
@.o.tif_jpeg \
|
||||
@.o.tif_lzw \
|
||||
@.o.tif_next \
|
||||
@.o.tif_open \
|
||||
@.o.tif_packbits \
|
||||
@.o.tif_predict \
|
||||
@.o.tif_print \
|
||||
@.o.tif_read \
|
||||
@.o.tif_strip \
|
||||
@.o.tif_swab \
|
||||
@.o.tif_thunder \
|
||||
@.o.tif_tile \
|
||||
@.o.tif_version \
|
||||
@.o.tif_warning \
|
||||
@.o.tif_write \
|
||||
@.o.tif_zip \
|
||||
@.o.tif_fax3sm
|
||||
|
||||
|
||||
# User-editable dependencies:
|
||||
@.mkversion: @.o.mkversion C:o.Stubs
|
||||
Link $(linkflags) @.o.mkversion C:o.Stubs
|
||||
@.h.version: @.VERSION @.mkversion
|
||||
<Prefix$Dir>.mkversion -v @.VERSION -a @.tiff/alpha @.h.version
|
||||
@.mkg3states: @.o.mkg3states @.o.getopt C:o.Stubs
|
||||
link $(linkflags) @.o.mkg3states C:o.Stubs @.o.getopt
|
||||
@.c.tif_fax3sm: @.mkg3states
|
||||
<Prefix$Dir>.mkg3states -c const @.c.tif_fax3sm
|
||||
|
||||
# Static dependencies:
|
||||
@.o.tif_acorn: @.c.tif_acorn
|
||||
cc $(ccflags) -o @.o.tif_acorn @.c.tif_acorn
|
||||
@.o.tif_aux: @.c.tif_aux
|
||||
cc $(ccflags) -o @.o.tif_aux @.c.tif_aux
|
||||
@.o.tif_close: @.c.tif_close
|
||||
cc $(ccflags) -o @.o.tif_close @.c.tif_close
|
||||
@.o.tif_codec: @.c.tif_codec
|
||||
cc $(ccflags) -o @.o.tif_codec @.c.tif_codec
|
||||
@.o.tif_compress: @.c.tif_compress
|
||||
cc $(ccflags) -o @.o.tif_compress @.c.tif_compress
|
||||
@.o.tif_dir: @.c.tif_dir
|
||||
cc $(ccflags) -o @.o.tif_dir @.c.tif_dir
|
||||
@.o.tif_dirinfo: @.c.tif_dirinfo
|
||||
cc $(ccflags) -o @.o.tif_dirinfo @.c.tif_dirinfo
|
||||
@.o.tif_dirread: @.c.tif_dirread
|
||||
cc $(ccflags) -o @.o.tif_dirread @.c.tif_dirread
|
||||
@.o.tif_dirwrite: @.c.tif_dirwrite
|
||||
cc $(ccflags) -o @.o.tif_dirwrite @.c.tif_dirwrite
|
||||
@.o.tif_dumpmode: @.c.tif_dumpmode
|
||||
cc $(ccflags) -o @.o.tif_dumpmode @.c.tif_dumpmode
|
||||
@.o.tif_error: @.c.tif_error
|
||||
cc $(ccflags) -o @.o.tif_error @.c.tif_error
|
||||
@.o.tif_fax3: @.c.tif_fax3
|
||||
cc $(ccflags) -o @.o.tif_fax3 @.c.tif_fax3
|
||||
@.o.tif_flush: @.c.tif_flush
|
||||
cc $(ccflags) -o @.o.tif_flush @.c.tif_flush
|
||||
@.o.tif_getimage: @.c.tif_getimage
|
||||
cc $(ccflags) -o @.o.tif_getimage @.c.tif_getimage
|
||||
@.o.tif_jpeg: @.c.tif_jpeg
|
||||
cc $(ccflags) -o @.o.tif_jpeg @.c.tif_jpeg
|
||||
@.o.tif_lzw: @.c.tif_lzw
|
||||
cc $(ccflags) -o @.o.tif_lzw @.c.tif_lzw
|
||||
@.o.tif_next: @.c.tif_next
|
||||
cc $(ccflags) -o @.o.tif_next @.c.tif_next
|
||||
@.o.tif_open: @.c.tif_open
|
||||
cc $(ccflags) -o @.o.tif_open @.c.tif_open
|
||||
@.o.tif_packbits: @.c.tif_packbits
|
||||
cc $(ccflags) -o @.o.tif_packbits @.c.tif_packbits
|
||||
@.o.tif_predict: @.c.tif_predict
|
||||
cc $(ccflags) -o @.o.tif_predict @.c.tif_predict
|
||||
@.o.tif_print: @.c.tif_print
|
||||
cc $(ccflags) -o @.o.tif_print @.c.tif_print
|
||||
@.o.tif_read: @.c.tif_read
|
||||
cc $(ccflags) -o @.o.tif_read @.c.tif_read
|
||||
@.o.tif_strip: @.c.tif_strip
|
||||
cc $(ccflags) -o @.o.tif_strip @.c.tif_strip
|
||||
@.o.tif_swab: @.c.tif_swab
|
||||
cc $(ccflags) -o @.o.tif_swab @.c.tif_swab
|
||||
@.o.tif_thunder: @.c.tif_thunder
|
||||
cc $(ccflags) -o @.o.tif_thunder @.c.tif_thunder
|
||||
@.o.tif_tile: @.c.tif_tile
|
||||
cc $(ccflags) -o @.o.tif_tile @.c.tif_tile
|
||||
@.o.tif_version: @.c.tif_version
|
||||
cc $(ccflags) -o @.o.tif_version @.c.tif_version
|
||||
@.o.tif_warning: @.c.tif_warning
|
||||
cc $(ccflags) -o @.o.tif_warning @.c.tif_warning
|
||||
@.o.tif_write: @.c.tif_write
|
||||
cc $(ccflags) -o @.o.tif_write @.c.tif_write
|
||||
@.o.tif_zip: @.c.tif_zip
|
||||
cc $(ccflags) -o @.o.tif_zip @.c.tif_zip
|
||||
@.o.mkg3states: @.c.mkg3states
|
||||
cc $(ccflags) -o @.o.mkg3states @.c.mkg3states
|
||||
@.o.getopt: @.c.getopt
|
||||
cc $(ccflags) -o @.o.getopt @.c.getopt
|
||||
@.o.mkspans: @.c.mkspans
|
||||
cc $(ccflags) -o @.o.mkspans @.c.mkspans
|
||||
@.o.tif_fax3sm: @.c.tif_fax3sm
|
||||
cc $(ccflags) -o @.o.tif_fax3sm @.c.tif_fax3sm
|
||||
@.o.mkversion: @.c.mkversion
|
||||
cc $(ccflags) -o @.o.mkversion @.c.mkversion
|
||||
|
||||
# Dynamic dependencies:
|
||||
Executable
+79
@@ -0,0 +1,79 @@
|
||||
Building the Software on an Acorn RISC OS system
|
||||
|
||||
The directory contrib/acorn contains support for compiling the library under
|
||||
Acorn C/C++ under Acorn's RISC OS 3.10 or above. Subsequent pathnames will
|
||||
use the Acorn format: The full-stop or period character is a pathname
|
||||
delimeter, and the slash character is not interpreted; the reverse position
|
||||
from Unix. Thus "libtiff/tif_acorn.c" becomes "libtiff.tif_acorn/c".
|
||||
|
||||
This support was contributed by Peter Greenham.
|
||||
(peterg@angmulti.demon.co.uk).
|
||||
|
||||
Installing LibTIFF:
|
||||
|
||||
LIBTIFF uses several files which have names longer than the normal RISC OS
|
||||
maximum of ten characters. This complicates matters. Maybe one day Acorn will
|
||||
address the problem and implement long filenames properly. Until then this
|
||||
gets messy, especially as I'm trying to do this with obeyfiles and not have
|
||||
to include binaries in this distribution.
|
||||
|
||||
First of all, ensure you have Truncate configured on (type *Configure
|
||||
Truncate On) Although it is, of course, preferable to have long filenames,
|
||||
LIBTIFF can be installed with short filenames, and it will compile and link
|
||||
without problems. However, getting it there is more problematic.
|
||||
contrib.acorn.install is an installation obeyfile which will create a normal
|
||||
Acorn-style library from the source (ie: with c, h and o folders etc.), but
|
||||
needs the distribution library to have been unpacked into a location which is
|
||||
capable of supporting long filenames, even if only temporarily.
|
||||
|
||||
My recommendation, until Acorn address this problem properly, is to use Jason
|
||||
Tribbeck's LongFilenames , or any other working system that gives you long
|
||||
filenames, like a nearby NFS server for instance.
|
||||
|
||||
If you are using Longfilenames, even if only temporarily to install LIBTIFF,
|
||||
unpack the TAR into a RAMDisc which has been longfilenamed (ie: *addlongfs
|
||||
ram) and then install from there to the hard disk. Unfortunately
|
||||
Longfilenames seems a bit unhappy about copying a bunch of long-named files
|
||||
across the same filing system, but is happy going between systems. You'll
|
||||
need to create a ramdisk of about 2Mb.
|
||||
|
||||
Now you can run the installation script I've supplied (in contrib.acorn),
|
||||
which will automate the process of installing LIBTIFF as an Acorn-style
|
||||
library. The syntax is as follows:
|
||||
|
||||
install <source_dir> <dest_dir>
|
||||
|
||||
Install will then create <dest_dir> and put the library in there. For
|
||||
example, having used LongFilenames on the RAMDisk and unpacked the library
|
||||
into there, you can then type:
|
||||
|
||||
Obey RAM::RamDisc0.$.contrib.acorn.install RAM::RamDisc0.$ ADFS::4.$.LIBTIFF
|
||||
|
||||
It doesn't matter if the destination location can cope with long filenames or
|
||||
not. The filenames will be truncated if necessary (*Configure Truncate On if
|
||||
you get errors) and all will be well.
|
||||
|
||||
Compiling LibTIFF:
|
||||
|
||||
Once the LibTIFF folder has been created and the files put inside, making the
|
||||
library should be just a matter of running 'SetVars' to set the appropriate
|
||||
system variables, then running 'Makefile'.
|
||||
|
||||
OSLib
|
||||
|
||||
OSLib is a comprehensive API for RISC OS machines, written by Jonathan
|
||||
Coxhead of Acorn Computers (although OSLib is not an official Acorn product).
|
||||
Using the OSLib SWI veneers produces code which is more compact and more
|
||||
efficient than code written using _kernel_swi or _swi. The Acorn port of
|
||||
LibTIFF can take advantage of this if present. Edit the Makefile and go to
|
||||
the Static dependencies section. The first entry is:
|
||||
|
||||
# Static dependencies:
|
||||
@.o.tif_acorn: @.c.tif_acorn
|
||||
cc $(ccflags) -o @.o.tif_acorn @.c.tif_acorn
|
||||
Change the cc line to:
|
||||
|
||||
cc $(ccflags) -DINCLUDE_OSLIB -o @.o.tif_acorn @.c.tif_acorn
|
||||
|
||||
Remember, however, that OSLib is only recommended for efficiency's sake. It
|
||||
is not required.
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
Set LibTIFF$Dir <Obey$Dir>
|
||||
Set LibTIFF$Path <LibTIFF$Dir>.
|
||||
Set C$Path <C$Path>,LibTIFF:
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
IfThere LibTIFF:o.* THEN Wipe LibTIFF:o.* ~CFR~V
|
||||
IfThere LibTIFF:c.tif_fax3sm THEN Delete LibTIFF:c.tif_fax3sm
|
||||
IfThere LibTIFF:mkg3states THEN Delete LibTIFF:mkg3states
|
||||
IfThere LibTIFF:h.version THEN Delete LibTIFF:h.version
|
||||
IfThere LibTIFF:mkversion THEN Delete LibTIFF:mkversion
|
||||
Executable
+175
@@ -0,0 +1,175 @@
|
||||
RISC OS Conversion log
|
||||
======================
|
||||
|
||||
mkversion.c
|
||||
~~~~~~~~~~~
|
||||
The RISC OS command-line does not allow the direct creation of the version.h
|
||||
file in the proper manner. To remedy this in such a way that the version
|
||||
header is made at compiletime, I wrote this small program. It is fully
|
||||
portable, so should work quite happily for any other platform that might need
|
||||
it.
|
||||
|
||||
msg3states.c
|
||||
~~~~~~~~~~~~
|
||||
Needed getopt.c from the port folder, then compiled and worked fine.
|
||||
|
||||
|
||||
tiff.h
|
||||
~~~~~~
|
||||
|
||||
====1====
|
||||
|
||||
The symbol _MIPS_SZLONG, if not defined, causes a compiler error. Fixed by
|
||||
ensuring it does exist. This looks to me like this wouldn't be an
|
||||
Acorn-specific problem. The new code fragment is as follows:
|
||||
|
||||
#ifndef _MIPS_SZLONG
|
||||
#define _MIPS_SZLONG 32
|
||||
#endif
|
||||
#if defined(__alpha) || _MIPS_SZLONG == 64
|
||||
|
||||
|
||||
|
||||
tiffcomp.h
|
||||
~~~~~~~~~~
|
||||
|
||||
====1====
|
||||
|
||||
#if !defined(__MWERKS__) && !defined(THINK_C)
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
Acorn also doesn't have this header so:
|
||||
|
||||
#if !defined(__MWERKS__) && !defined(THINK_C) && !defined(__acorn)
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
====2====
|
||||
|
||||
#ifdef VMS
|
||||
#include <file.h>
|
||||
#include <unixio.h>
|
||||
#else
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
This seems to indicate that fcntl.h is included on all systems except
|
||||
VMS. Odd, because I've never heard of it before. Sure it's in the ANSI
|
||||
definition? Anyway, following change:
|
||||
|
||||
#ifdef VMS
|
||||
#include <file.h>
|
||||
#include <unixio.h>
|
||||
#else
|
||||
#ifndef __acorn
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
This will probably change when I find out what it wants from fcntl.h!
|
||||
|
||||
====3====
|
||||
|
||||
#if defined(__MWERKS__) || defined(THINK_C) || defined(applec)
|
||||
#include <stdlib.h>
|
||||
#define BSDTYPES
|
||||
#endif
|
||||
|
||||
Added RISC OS to above thus:
|
||||
|
||||
#if defined(__MWERKS__) || defined(THINK_C) || defined(applec) || defined(__acorn)
|
||||
#include <stdlib.h>
|
||||
#define BSDTYPES
|
||||
#endif
|
||||
|
||||
====4====
|
||||
|
||||
/*
|
||||
* The library uses the ANSI C/POSIX SEEK_*
|
||||
* definitions that should be defined in unistd.h
|
||||
* (except on VMS where they are in stdio.h and
|
||||
* there is no unistd.h).
|
||||
*/
|
||||
#ifndef SEEK_SET
|
||||
#if !defined(VMS) && !defined (applec) && !defined(THINK_C) && !defined(__MWERKS__)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
RISC OS is like VMS and Mac in this regard. So changed to:
|
||||
|
||||
/*
|
||||
* The library uses the ANSI C/POSIX SEEK_*
|
||||
* definitions that should be defined in unistd.h
|
||||
* (except on VMS or the Mac or RISC OS, where they are in stdio.h and
|
||||
* there is no unistd.h).
|
||||
*/
|
||||
#ifndef SEEK_SET
|
||||
#if !defined(VMS) && !defined (applec) && !defined(THINK_C) && !defined(__MWERKS__) && !defined(__acorn)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
====5====
|
||||
|
||||
NB: HAVE_IEEEFP is defined in tiffconf.h, not tiffcomp.h as mentioned
|
||||
in libtiff.README. (Note written on original port from 3.4beta004)
|
||||
|
||||
Acorn C/C++ claims to accord with IEEE 754, so no change (yet) to
|
||||
tiffconf.h.
|
||||
|
||||
====6====
|
||||
|
||||
Unsure about whether this compiler supports inline functions. Will
|
||||
leave it on for the time being and see if it works! (Likely if
|
||||
everything else does.)
|
||||
|
||||
... Seems to be OK ...
|
||||
|
||||
====7====
|
||||
|
||||
Added to the end:
|
||||
|
||||
/*
|
||||
* osfcn.h is part of C++Lib on Acorn C/C++, and as such can't be used
|
||||
* on C alone. For that reason, the relevant functions have been
|
||||
* implemented by myself in tif_acorn.c, and the elements from the header
|
||||
* included here.
|
||||
*/
|
||||
|
||||
#ifdef __acorn
|
||||
#ifdef __cplusplus
|
||||
#include <osfcn.h>
|
||||
#else
|
||||
#include "kernel.h"
|
||||
#define O_RDONLY 0
|
||||
#define O_WRONLY 1
|
||||
#define O_RDWR 2
|
||||
#define O_APPEND 8
|
||||
#define O_CREAT 0x200
|
||||
#define O_TRUNC 0x400
|
||||
typedef long off_t;
|
||||
extern int open(const char *name, int flags, int mode);
|
||||
extern int close(int fd);
|
||||
extern int write(int fd, const char *buf, int nbytes);
|
||||
extern int read(int fd, char *buf, int nbytes);
|
||||
extern off_t lseek(int fd, off_t offset, int whence);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
===============================================================================
|
||||
|
||||
tif_acorn.c
|
||||
~~~~~~~~~~~
|
||||
|
||||
Created file tif_acorn.c, copied initially from tif_unix.c
|
||||
|
||||
Documented internally where necessary.
|
||||
|
||||
Note that I have implemented the low-level file-handling functions normally
|
||||
found in osfcn.h in here, and put the header info at the bottom of
|
||||
tiffcomp.h. This is further documented from a RISC OS perspective inside the
|
||||
file.
|
||||
|
||||
===============================================================================
|
||||
Executable
+128
@@ -0,0 +1,128 @@
|
||||
If "%0" = "" Then Error Syntax: install |<source_dir> |<dest_dir>
|
||||
If "%1" = "" Then Error Syntax: install |<source_dir> |<dest_dir>
|
||||
Set LibTiffInstall$Dir %0
|
||||
Set LibTiff$Dir %1
|
||||
Set Alias$CPY Copy <LibTiffInstall$Dir>.%%0 <LibTiff$Dir>.%%1 ~C~DF~NRV
|
||||
CDir <LibTiff$Dir>
|
||||
CDir <LibTiff$Dir>.c
|
||||
CDir <LibTiff$Dir>.h
|
||||
CDir <LibTiff$Dir>.o
|
||||
CPY COPYRIGHT COPYRIGHT
|
||||
CPY README README
|
||||
CPY VERSION VERSION
|
||||
CPY dist.tiff/alpha tiff/alpha
|
||||
CPY contrib.acorn.SetVars SetVars
|
||||
CPY contrib.acorn.Makefile Makefile
|
||||
CPY contrib.acorn.cleanlib cleanlib
|
||||
CPY port.getopt/c c.getopt
|
||||
CPY libtiff.mkg3states/c c.mkg3states
|
||||
CPY libtiff.mkspans/c c.mkspans
|
||||
CPY libtiff.mkversion/c c.mkversion
|
||||
CPY libtiff.tif_acorn/c c.tif_acorn
|
||||
CPY libtiff.tif_aux/c c.tif_aux
|
||||
CPY libtiff.tif_close/c c.tif_close
|
||||
CPY libtiff.tif_codec/c c.tif_codec
|
||||
CPY libtiff.tif_compress/c c.tif_compre
|
||||
CPY libtiff.tif_dir/c c.tif_dir
|
||||
CPY libtiff.tif_dirinfo/c c.tif_dirinf
|
||||
CPY libtiff.tif_dirread/c c.tif_dirrea
|
||||
CPY libtiff.tif_dirwrite/c c.tif_dirwri
|
||||
CPY libtiff.tif_dumpmode/c c.tif_dumpmo
|
||||
CPY libtiff.tif_error/c c.tif_error
|
||||
CPY libtiff.tif_fax3/c c.tif_fax3
|
||||
CPY libtiff.tif_flush/c c.tif_flush
|
||||
CPY libtiff.tif_getimage/c c.tif_getima
|
||||
CPY libtiff.tif_jpeg/c c.tif_jpeg
|
||||
CPY libtiff.tif_lzw/c c.tif_lzw
|
||||
CPY libtiff.tif_next/c c.tif_next
|
||||
CPY libtiff.tif_open/c c.tif_open
|
||||
CPY libtiff.tif_packbits/c c.tif_packbi
|
||||
CPY libtiff.tif_predict/c c.tif_predic
|
||||
CPY libtiff.tif_print/c c.tif_print
|
||||
CPY libtiff.tif_read/c c.tif_read
|
||||
CPY libtiff.tif_strip/c c.tif_strip
|
||||
CPY libtiff.tif_swab/c c.tif_swab
|
||||
CPY libtiff.tif_thunder/c c.tif_thunde
|
||||
CPY libtiff.tif_tile/c c.tif_tile
|
||||
CPY libtiff.tif_version/c c.tif_versio
|
||||
CPY libtiff.tif_warning/c c.tif_warnin
|
||||
CPY libtiff.tif_write/c c.tif_write
|
||||
CPY libtiff.tif_zip/c c.tif_zip
|
||||
CPY libtiff.t4/h h.t4
|
||||
CPY libtiff.tiff/h h.tiff
|
||||
CPY libtiff.tiffcomp/h h.tiffcomp
|
||||
CPY libtiff.tiffconf/h h.tiffconf
|
||||
CPY libtiff.tiffio/h h.tiffio
|
||||
CPY libtiff.tiffiop/h h.tiffiop
|
||||
CPY libtiff.tif_dir/h h.tif_dir
|
||||
CPY libtiff.tif_fax3/h h.tif_fax3
|
||||
CPY libtiff.tif_predict/h h.tif_predic
|
||||
SetType <LibTiff$Dir>.COPYRIGHT Text
|
||||
SetType <LibTiff$Dir>.README Text
|
||||
SetType <LibTiff$Dir>.VERSION Text
|
||||
SetType <LibTiff$Dir>.tiff/alpha Text
|
||||
SetType <LibTiff$Dir>.SetVars Obey
|
||||
SetType <LibTiff$Dir>.Makefile fe1
|
||||
SetType <LibTiff$Dir>.cleanlib Obey
|
||||
SetType <LibTiff$Dir>.c.getopt Text
|
||||
SetType <LibTiff$Dir>.c.mkg3states Text
|
||||
SetType <LibTiff$Dir>.c.mkspans Text
|
||||
SetType <LibTiff$Dir>.c.mkversion Text
|
||||
SetType <LibTiff$Dir>.c.tif_acorn Text
|
||||
SetType <LibTiff$Dir>.c.tif_aux Text
|
||||
SetType <LibTiff$Dir>.c.tif_close Text
|
||||
SetType <LibTiff$Dir>.c.tif_codec Text
|
||||
SetType <LibTiff$Dir>.c.tif_compre Text
|
||||
SetType <LibTiff$Dir>.c.tif_dir Text
|
||||
SetType <LibTiff$Dir>.c.tif_dirinf Text
|
||||
SetType <LibTiff$Dir>.c.tif_dirrea Text
|
||||
SetType <LibTiff$Dir>.c.tif_dirwri Text
|
||||
SetType <LibTiff$Dir>.c.tif_dumpmo Text
|
||||
SetType <LibTiff$Dir>.c.tif_error Text
|
||||
SetType <LibTiff$Dir>.c.tif_fax3 Text
|
||||
SetType <LibTiff$Dir>.c.tif_flush Text
|
||||
SetType <LibTiff$Dir>.c.tif_getima Text
|
||||
SetType <LibTiff$Dir>.c.tif_jpeg Text
|
||||
SetType <LibTiff$Dir>.c.tif_lzw Text
|
||||
SetType <LibTiff$Dir>.c.tif_next Text
|
||||
SetType <LibTiff$Dir>.c.tif_open Text
|
||||
SetType <LibTiff$Dir>.c.tif_packbi Text
|
||||
SetType <LibTiff$Dir>.c.tif_predic Text
|
||||
SetType <LibTiff$Dir>.c.tif_print Text
|
||||
SetType <LibTiff$Dir>.c.tif_read Text
|
||||
SetType <LibTiff$Dir>.c.tif_strip Text
|
||||
SetType <LibTiff$Dir>.c.tif_swab Text
|
||||
SetType <LibTiff$Dir>.c.tif_thunde Text
|
||||
SetType <LibTiff$Dir>.c.tif_tile Text
|
||||
SetType <LibTiff$Dir>.c.tif_versio Text
|
||||
SetType <LibTiff$Dir>.c.tif_warnin Text
|
||||
SetType <LibTiff$Dir>.c.tif_write Text
|
||||
SetType <LibTiff$Dir>.c.tif_zip Text
|
||||
SetType <LibTiff$Dir>.h.t4 Text
|
||||
SetType <LibTiff$Dir>.h.tiff Text
|
||||
SetType <LibTiff$Dir>.h.tiffcomp Text
|
||||
SetType <LibTiff$Dir>.h.tiffconf Text
|
||||
SetType <LibTiff$Dir>.h.tiffio Text
|
||||
SetType <LibTiff$Dir>.h.tiffiop Text
|
||||
SetType <LibTiff$Dir>.h.tif_dir Text
|
||||
SetType <LibTiff$Dir>.h.tif_fax3 Text
|
||||
SetType <LibTiff$Dir>.h.tif_predic Text
|
||||
Unset Alias$CPY
|
||||
Unset LibTiffInstall$Dir
|
||||
| Now attempt to restore longfilename status. If it causes an error, OK.
|
||||
Set Alias$RN Rename <LibTiff$Dir>.%%0 <LibTiff$Dir>.%%1
|
||||
Unset LibTiff$Dir
|
||||
RN c.tif_compre c.tif_compress
|
||||
RN c.tif_dirinf c.tif_dirinfo
|
||||
RN c.tif_dirrea c.tif_dirread
|
||||
RN c.tif_dirwri c.tif_dirwrite
|
||||
RN c.tif_dumpmo c.tif_dumpmode
|
||||
RN c.tif_getima c.tif_getimage
|
||||
RN c.tif_packbi c.tif_packbits
|
||||
RN c.tif_predic c.tif_predict
|
||||
RN c.tif_thunde c.tif_thunder
|
||||
RN c.tif_versio c.tif_version
|
||||
RN c.tif_warnin c.tif_warning
|
||||
RN h.tif_predic h.tif_predict
|
||||
Unset Alias$RN
|
||||
Echo All done!
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#
|
||||
# If libtiff.a is installed in /usr/lib or /usr/local/lib just point
|
||||
# LIBTIFF_DIR there. It doesn't need a full libtiff tree.
|
||||
#
|
||||
LIBTIFF_DIR = ../../libtiff
|
||||
#
|
||||
CC = gcc
|
||||
CFLAGS = -O -I$(LIBTIFF_DIR)
|
||||
LIBS = $(LIBTIFF_DIR)/libtiff.a -lm
|
||||
|
||||
addtiffo: addtiffo.o tif_overview.o tif_ovrcache.o
|
||||
$(CXX) $(CFLAGS) addtiffo.o tif_overview.o tif_ovrcache.o \
|
||||
$(LIBS) -o addtiffo
|
||||
|
||||
|
||||
addtiffo.o: addtiffo.c
|
||||
$(CC) -c $(CFLAGS) addtiffo.c
|
||||
|
||||
tif_overview.o: tif_overview.c
|
||||
$(CC) -c $(CFLAGS) tif_overview.c
|
||||
|
||||
tif_ovrcache.o: tif_ovrcache.c
|
||||
$(CC) -c $(CFLAGS) tif_ovrcache.c
|
||||
|
||||
clean:
|
||||
rm *.o addtiffo
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# If libtiff.a is installed in /usr/lib or /usr/local/lib just point
|
||||
# LIBTIFF_DIR there. It doesn't need a full libtiff tree.
|
||||
#
|
||||
LIBTIFF_DIR = ..\..\libtiff
|
||||
#
|
||||
CC = cl.exe
|
||||
CPPC = cl.exe
|
||||
CFLAGS = -O -I$(LIBTIFF_DIR)
|
||||
LIBS = $(LIBTIFF_DIR)\libtiff.lib
|
||||
|
||||
addtiffo: addtiffo.obj tif_overview.obj tif_ovrcache.obj
|
||||
$(CC) $(CFLAGS) addtiffo.obj tif_overview.obj tif_ovrcache.obj \
|
||||
$(LIBS) /Feaddtiffo.exe
|
||||
|
||||
|
||||
addtiffo.obj: addtiffo.c
|
||||
$(CC) -c $(CFLAGS) addtiffo.c
|
||||
|
||||
tif_overview.obj: tif_overview.c
|
||||
$(CPPC) -c $(CFLAGS) tif_overview.c
|
||||
|
||||
tif_ovrcache.obj: tif_ovrcache.c
|
||||
$(CPPC) -c $(CFLAGS) tif_ovrcache.c
|
||||
|
||||
clean:
|
||||
del *.obj addtiffo.exe
|
||||
Executable
+131
@@ -0,0 +1,131 @@
|
||||
/******************************************************************************
|
||||
* $Id: addtiffo.c,v 1.1.1.1 2000/06/24 19:10:17 tshead Exp $
|
||||
*
|
||||
* Project: GeoTIFF Overview Builder
|
||||
* Purpose: Mainline for building overviews in a TIFF file.
|
||||
* Author: Frank Warmerdam, warmerda@home.com
|
||||
*
|
||||
******************************************************************************
|
||||
* Copyright (c) 1999, Frank Warmerdam
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
******************************************************************************
|
||||
*
|
||||
* $Log: addtiffo.c,v $
|
||||
* Revision 1.1.1.1 2000/06/24 19:10:17 tshead
|
||||
* * Initial import of libtiff-3.5.5
|
||||
*
|
||||
* Revision 1.2 2000/01/28 15:36:38 warmerda
|
||||
* pass TIFF handle instead of filename to overview builder
|
||||
*
|
||||
* Revision 1.1 1999/08/17 01:47:59 warmerda
|
||||
* New
|
||||
*
|
||||
* Revision 1.1 1999/03/12 17:46:32 warmerda
|
||||
* New
|
||||
*
|
||||
* Revision 1.2 1999/02/11 22:27:12 warmerda
|
||||
* Added multi-sample support
|
||||
*
|
||||
* Revision 1.1 1999/02/11 18:12:30 warmerda
|
||||
* New
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "tiffio.h"
|
||||
|
||||
void TIFFBuildOverviews( TIFF *, int, int *, int );
|
||||
|
||||
/************************************************************************/
|
||||
/* main() */
|
||||
/************************************************************************/
|
||||
|
||||
int main( int argc, char ** argv )
|
||||
|
||||
{
|
||||
int anOverviews[100];
|
||||
int nOverviewCount = 0;
|
||||
int bUseSubIFD = 0;
|
||||
TIFF *hTIFF;
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Usage: */
|
||||
/* -------------------------------------------------------------------- */
|
||||
if( argc < 2 )
|
||||
{
|
||||
printf( "Usage: addtiffo tiff_filename [resolution_reductions]\n" );
|
||||
printf( "\n" );
|
||||
printf( "Example:\n" );
|
||||
printf( " %% addtifo abc.tif 2 4 8 16\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
if( strcmp(argv[1],"-subifd") == 0 )
|
||||
{
|
||||
bUseSubIFD = 1;
|
||||
argv++;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Collect the user requested reduction factors. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
while( nOverviewCount < argc - 2 && nOverviewCount < 100 )
|
||||
{
|
||||
anOverviews[nOverviewCount] = atoi(argv[nOverviewCount+2]);
|
||||
nOverviewCount++;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Default to four overview levels. It would be nicer if it */
|
||||
/* defaulted based on the size of the source image. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
if( nOverviewCount == 0 )
|
||||
{
|
||||
nOverviewCount = 4;
|
||||
|
||||
anOverviews[0] = 2;
|
||||
anOverviews[1] = 4;
|
||||
anOverviews[2] = 8;
|
||||
anOverviews[3] = 16;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Build the overview. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
hTIFF = TIFFOpen( argv[1], "r+" );
|
||||
if( hTIFF == NULL )
|
||||
{
|
||||
fprintf( stderr, "TIFFOpen(%s) failed.\n", argv[1] );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
TIFFBuildOverviews( hTIFF, nOverviewCount, anOverviews, bUseSubIFD );
|
||||
|
||||
TIFFClose( hTIFF );
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Optionally test for memory leaks. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
#ifdef DBMALLOC
|
||||
malloc_dump(1);
|
||||
#endif
|
||||
|
||||
exit( 0 );
|
||||
}
|
||||
Executable
+145
@@ -0,0 +1,145 @@
|
||||
addtiffo 1.0
|
||||
============
|
||||
|
||||
The addtiffo utility is used to add overview pyramids to an existing
|
||||
TIFF or GeoTIFF file. Some applications can take advantage of these
|
||||
overviews to accelerate overview display performance of large rasters.
|
||||
|
||||
This release of addtiffo is primarily intended for compatibility testing
|
||||
with applications, and to see if there is interest in a cleaner release
|
||||
of the capability ... perhaps incorporation into the libtiff tools
|
||||
distribution.
|
||||
|
||||
Please feel free to contact me with questions, or problems.
|
||||
|
||||
warmerda@home.com
|
||||
http://members.home.com/warmerda
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Usage: addtiffo [-subifd] tiff_filename [resolution_reductions]
|
||||
|
||||
Example:
|
||||
% addtiffo abc.tif 2 4 8 16
|
||||
|
||||
The numeric arguments are the list of reduction factors to
|
||||
generate. In this example a 1/2, 1/4 1/8 and 1/16
|
||||
|
||||
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
|
||||
See tif_overview.cpp for up to date details.
|
||||
|
||||
o RawBlockedImage will create temporary files in the current directory
|
||||
to cache the overviews so it doesn't have to hold them all in memory.
|
||||
If the application crashes these will not be deleted (*.rbi).
|
||||
|
||||
o Currently only images with bits_per_sample of a multiple of eight
|
||||
will work.
|
||||
|
||||
o The downsampler currently just takes the top left pixel from the
|
||||
source rectangle. Eventually sampling options of averaging, mode, and
|
||||
``center pixel'' should be offered.
|
||||
|
||||
o The code will attempt to use the same kind of compression,
|
||||
photometric interpretation, and organization as the source image, but
|
||||
it doesn't copy geotiff tags to the reduced resolution images.
|
||||
|
||||
o Reduced resolution overviews for multi-sample files will currently
|
||||
always be generated as PLANARCONFIG_SEPARATE. This could be fixed
|
||||
reasonable easily if needed to improve compatibility with other
|
||||
packages. Many don't properly support PLANARCONFIG_SEPARATE.
|
||||
|
||||
o Overviews are always written as appended IFDs, rather than using the
|
||||
``tree of tree's'' approach using the SUBIFD tag. I wanted to implement
|
||||
both, but it isn't currently easy to add a SUBIFD tag to an existing
|
||||
main tiff IFD with libtiff. I hope to try this again later.
|
||||
|
||||
|
||||
TIFF File Tags
|
||||
--------------
|
||||
|
||||
The results of running addtiffo on a 1024x1024 tiled greyscale file
|
||||
with the arguments ``2 4 8 16'' is to add four additional TIFF directories
|
||||
appended on the file with the SUBFILETYPE flag to 0x1 indicating the extra
|
||||
items are reduced resolution images.
|
||||
|
||||
The tiffinfo output of such a file might look like this:
|
||||
|
||||
TIFF Directory at offset 0x118008
|
||||
Image Width: 1024 Image Length: 1024
|
||||
Tile Width: 256 Tile Length: 112
|
||||
Bits/Sample: 8
|
||||
Compression Scheme: none
|
||||
Photometric Interpretation: min-is-black
|
||||
Samples/Pixel: 1
|
||||
Planar Configuration: single image plane
|
||||
TIFF Directory at offset 0x15e1d2
|
||||
Subfile Type: reduced-resolution image (1 = 0x1)
|
||||
Image Width: 512 Image Length: 512
|
||||
Tile Width: 256 Tile Length: 112
|
||||
Bits/Sample: 8
|
||||
Compression Scheme: none
|
||||
Photometric Interpretation: min-is-black
|
||||
Samples/Pixel: 1
|
||||
Planar Configuration: separate image planes
|
||||
TIFF Directory at offset 0x1732b8
|
||||
Subfile Type: reduced-resolution image (1 = 0x1)
|
||||
Image Width: 256 Image Length: 256
|
||||
Tile Width: 256 Tile Length: 112
|
||||
Bits/Sample: 8
|
||||
Compression Scheme: none
|
||||
Photometric Interpretation: min-is-black
|
||||
Samples/Pixel: 1
|
||||
Planar Configuration: separate image planes
|
||||
TIFF Directory at offset 0x17a366
|
||||
Subfile Type: reduced-resolution image (1 = 0x1)
|
||||
Image Width: 128 Image Length: 128
|
||||
Tile Width: 128 Tile Length: 112
|
||||
Bits/Sample: 8
|
||||
Compression Scheme: none
|
||||
Photometric Interpretation: min-is-black
|
||||
Samples/Pixel: 1
|
||||
Planar Configuration: separate image planes
|
||||
TIFF Directory at offset 0x17b40c
|
||||
Subfile Type: reduced-resolution image (1 = 0x1)
|
||||
Image Width: 64 Image Length: 64
|
||||
Tile Width: 64 Tile Length: 64
|
||||
Bits/Sample: 8
|
||||
Compression Scheme: none
|
||||
Photometric Interpretation: min-is-black
|
||||
Samples/Pixel: 1
|
||||
Planar Configuration: separate image planes
|
||||
|
||||
|
||||
Building
|
||||
--------
|
||||
|
||||
You will need a C, and C++ compiler. You will need to have libtiff already
|
||||
built and installed. The provided Makefile should work on most Unix systems.
|
||||
A similar file will be needed for Windows, but is not provided.
|
||||
|
||||
The CFLAGS and LIBS macros in the Makefile will have to be updated to
|
||||
point to the correct location of the libtiff include files, and library.
|
||||
|
||||
|
||||
Credits
|
||||
-------
|
||||
|
||||
o Intergraph Corporation for partially funding the work.
|
||||
|
||||
o Global Geomatics for partially funding reorganization of the overview
|
||||
building ability as a separate utility.
|
||||
|
||||
o Orrin Long, and Ed Grissom of Intergraph for explaining what needed to
|
||||
be done.
|
||||
|
||||
o Max Martinez of Erdas for his discussion of external overviews.
|
||||
|
||||
o Frank Warmerdam for writing the bulk of the code.
|
||||
|
||||
o Sam Leffler since this only exists because of his libtiff.
|
||||
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};
|
||||
Executable
+249
@@ -0,0 +1,249 @@
|
||||
# $Header: /home/cvsroot/libtiff/contrib/dosdjgpp/Makefile.lib,v 1.1.1.1 2000/06/24 19:10:17 tshead Exp $
|
||||
#
|
||||
# manually derived from Makefile.in for DJGPP v2.x (GNU C for DOS/386).
|
||||
#
|
||||
# Tag Image File Format Library
|
||||
#
|
||||
# Copyright (c) 1988-1996 Sam Leffler
|
||||
# Copyright (c) 1991-1996 Silicon Graphics, Inc.
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and
|
||||
# its documentation for any purpose is hereby granted without fee, provided
|
||||
# that (i) the above copyright notices and this permission notice appear in
|
||||
# all copies of the software and related documentation, and (ii) the names of
|
||||
# Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
# publicity relating to the software without the specific, prior written
|
||||
# permission of Sam Leffler and Silicon Graphics.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
# OF THIS SOFTWARE.
|
||||
#
|
||||
|
||||
SRCDIR = .
|
||||
|
||||
NULL =
|
||||
CC = gcc
|
||||
AR = ar
|
||||
AROPTS = rc
|
||||
RANLIB = ranlib
|
||||
|
||||
#
|
||||
# If JPEG support is to be included and the Independent JPEG
|
||||
# Software distribution is not installed then DIR_JPEG must
|
||||
# refer to the directory where the include files reside.
|
||||
#
|
||||
# Similarly, if the libgz distribution is not installed, then
|
||||
# DIR_LIBGZ must refer to the directory where the include files
|
||||
# are located. Note that recent versions
|
||||
#
|
||||
IPATH = -I. -I${SRCDIR}
|
||||
# @COPT_LIBINC@
|
||||
#
|
||||
# To enable JPEG support include -DJPEG_SUPPORT here.
|
||||
# To enable Deflate support add a -DZIP_SUPPORT here.
|
||||
# Note that where the configure script is used these defines
|
||||
# are automatically setup when JPEG/ZIP is set to "yes".
|
||||
#
|
||||
# Otherwise, consult tiffconf.h for information on controlling
|
||||
# the configuration of optional library support.
|
||||
#
|
||||
CONF_LIBRARY=#@CONF_JPEG@ @CONF_ZIP@
|
||||
COPTS =
|
||||
OPTIMIZER=-O
|
||||
CFLAGS = ${COPTS} ${OPTIMIZER} ${IPATH} ${CONF_LIBRARY}
|
||||
#
|
||||
SRCS = \
|
||||
tif_aux.c \
|
||||
tif_close.c \
|
||||
tif_codec.c \
|
||||
tif_compress.c \
|
||||
tif_dir.c \
|
||||
tif_dirinfo.c \
|
||||
tif_dirread.c \
|
||||
tif_dirwrite.c \
|
||||
tif_dumpmode.c \
|
||||
tif_error.c \
|
||||
tif_fax3.c \
|
||||
tif_fx3s.c \
|
||||
tif_getimage.c \
|
||||
tif_jpeg.c \
|
||||
tif_flush.c \
|
||||
tif_lzw.c \
|
||||
tif_next.c \
|
||||
tif_open.c \
|
||||
tif_packbits.c \
|
||||
tif_predict.c \
|
||||
tif_print.c \
|
||||
tif_read.c \
|
||||
tif_swab.c \
|
||||
tif_strip.c \
|
||||
tif_thunder.c \
|
||||
tif_tile.c \
|
||||
tif_msdos.c \
|
||||
tif_version.c \
|
||||
tif_warning.c \
|
||||
tif_write.c \
|
||||
tif_zip.c \
|
||||
tif_luv.c \
|
||||
${NULL}
|
||||
OBJS = \
|
||||
tif_aux.o \
|
||||
tif_close.o \
|
||||
tif_codec.o \
|
||||
tif_compress.o \
|
||||
tif_dir.o \
|
||||
tif_dirinfo.o \
|
||||
tif_dirread.o \
|
||||
tif_dirwrite.o \
|
||||
tif_dumpmode.o \
|
||||
tif_error.o \
|
||||
tif_fax3.o \
|
||||
tif_fx3s.o \
|
||||
tif_getimage.o \
|
||||
tif_jpeg.o \
|
||||
tif_flush.o \
|
||||
tif_lzw.o \
|
||||
tif_next.o \
|
||||
tif_open.o \
|
||||
tif_packbits.o \
|
||||
tif_predict.o \
|
||||
tif_print.o \
|
||||
tif_read.o \
|
||||
tif_swab.o \
|
||||
tif_strip.o \
|
||||
tif_thunder.o \
|
||||
tif_tile.o \
|
||||
tif_msdos.o \
|
||||
tif_version.o \
|
||||
tif_warning.o \
|
||||
tif_write.o \
|
||||
tif_zip.o \
|
||||
tif_luv.o \
|
||||
${NULL}
|
||||
TARGETS = libtiff.a
|
||||
|
||||
all: ${TARGETS}
|
||||
|
||||
libtiff.a: ${OBJS}
|
||||
${AR} ${AROPTS} libtiff.a $?
|
||||
${RANLIB} libtiff.a
|
||||
|
||||
${OBJS}: ${SRCDIR}/tiffio.h ${SRCDIR}/tiff.h ${SRCDIR}/tif_dir.h
|
||||
${OBJS}: ${SRCDIR}/tiffcomp.h ${SRCDIR}/tiffiop.h ${SRCDIR}/tiffconf.h
|
||||
|
||||
ALPHA = ../dist/tiff.alpha
|
||||
VERSION = ../VERSION
|
||||
|
||||
version.h: ${VERSION} ${ALPHA} ${SRCDIR}/mkversion.c
|
||||
${CC} -o mkversion ${CFLAGS} ${SRCDIR}/mkversion.c
|
||||
del version.h
|
||||
mkversion -v ${VERSION} -a ${ALPHA} version.h
|
||||
|
||||
tif_version.o: version.h
|
||||
|
||||
#
|
||||
# The finite state machine tables used by the G3/G4 decoders
|
||||
# are generated by the mkg3states program. On systems without
|
||||
# make these rules have to be manually carried out.
|
||||
#
|
||||
# The file is called tif_fax3sm.c is the normal (unix) Makefile, but this
|
||||
# may cause problems when compiling without support for LFN, then the file
|
||||
# tif_fax3.o is considered the same name as tif_fax3sm.o, since only 8 chars
|
||||
# are significant.
|
||||
#
|
||||
tif_fx3s.c: ${SRCDIR}/mkg3states.c ${SRCDIR}/tif_fax3.h
|
||||
${CC} -o mkg3states ${CFLAGS} ${SRCDIR}/mkg3states.c
|
||||
del tif_fx3s.c
|
||||
mkg3states -c const tif_fx3s.c
|
||||
|
||||
tif_fx3s.o: tif_fx3s.c
|
||||
@echo If the following gcc command fails due to lack of virtual memory, try
|
||||
@echo compiling it in a non-DPMI environment with the cwsdpmi swapfile on a
|
||||
@echo drive that has plenty of space.
|
||||
${CC} -c ${CFLAGS} tif_fx3s.c
|
||||
|
||||
tif_aux.o: ${SRCDIR}/tif_aux.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_aux.c
|
||||
tif_close.o: ${SRCDIR}/tif_close.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_close.c
|
||||
tif_codec.o: ${SRCDIR}/tif_codec.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_codec.c
|
||||
tif_compress.o: ${SRCDIR}/tif_compress.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_compress.c
|
||||
tif_dir.o: ${SRCDIR}/tif_dir.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_dir.c
|
||||
tif_dirinfo.o: ${SRCDIR}/tif_dirinfo.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_dirinfo.c
|
||||
tif_dirread.o: ${SRCDIR}/tif_dirread.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_dirread.c
|
||||
tif_dirwrite.o: ${SRCDIR}/tif_dirwrite.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_dirwrite.c
|
||||
tif_dumpmode.o: ${SRCDIR}/tif_dumpmode.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_dumpmode.c
|
||||
tif_error.o: ${SRCDIR}/tif_error.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_error.c
|
||||
tif_fax3.o: ${SRCDIR}/tif_fax3.c ${SRCDIR}/t4.h ${SRCDIR}/tif_fax3.h
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_fax3.c
|
||||
tif_getimage.o: ${SRCDIR}/tif_getimage.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_getimage.c
|
||||
tif_jpeg.o: ${SRCDIR}/tif_jpeg.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_jpeg.c
|
||||
tif_flush.o: ${SRCDIR}/tif_flush.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_flush.c
|
||||
tif_lzw.o: ${SRCDIR}/tif_lzw.c ${SRCDIR}/tif_predict.h
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_lzw.c
|
||||
tif_next.o: ${SRCDIR}/tif_next.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_next.c
|
||||
tif_open.o: ${SRCDIR}/tif_open.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_open.c
|
||||
tif_packbits.o: ${SRCDIR}/tif_packbits.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_packbits.c
|
||||
tif_predict.o: ${SRCDIR}/tif_predict.c ${SRCDIR}/tif_predict.h
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_predict.c
|
||||
tif_print.o: ${SRCDIR}/tif_print.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_print.c
|
||||
tif_read.o: ${SRCDIR}/tif_read.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_read.c
|
||||
tif_swab.o: ${SRCDIR}/tif_swab.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_swab.c
|
||||
tif_strip.o: ${SRCDIR}/tif_strip.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_strip.c
|
||||
tif_thunder.o: ${SRCDIR}/tif_thunder.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_thunder.c
|
||||
tif_tile.o: ${SRCDIR}/tif_tile.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_tile.c
|
||||
tif_unix.o: ${SRCDIR}/tif_unix.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_unix.c
|
||||
tif_version.o: ${SRCDIR}/tif_version.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_version.c
|
||||
tif_warning.o: ${SRCDIR}/tif_warning.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_warning.c
|
||||
tif_write.o: ${SRCDIR}/tif_write.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_write.c
|
||||
tif_zip.o: ${SRCDIR}/tif_zip.c ${SRCDIR}/tif_predict.h
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_zip.c
|
||||
|
||||
tif_apple.o: ${SRCDIR}/tif_apple.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_apple.c
|
||||
tif_atari.o: ${SRCDIR}/tif_atari.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_atari.c
|
||||
tif_msdos.o: ${SRCDIR}/tif_msdos.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_msdos.c
|
||||
tif_vms.o: ${SRCDIR}/tif_vms.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_vms.c
|
||||
tif_win3.o: ${SRCDIR}/tif_win3.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tif_win3.c
|
||||
|
||||
INCS = ${SRCDIR}/tiff.h ${SRCDIR}/tiffio.h
|
||||
|
||||
clean:
|
||||
rm -f ${TARGETS} ${OBJS} mkg3states mkg3states.exe tif_fx3s.c
|
||||
rm -f version.h libtiff.a mkversion mkversion.exe
|
||||
Executable
+217
@@ -0,0 +1,217 @@
|
||||
# $Header: /home/cvsroot/libtiff/contrib/dosdjgpp/Makefile.tools,v 1.1.1.1 2000/06/24 19:10:17 tshead Exp $
|
||||
#
|
||||
# manually derived from Makefile.in for DJGPP v2.x (GNU C for DOS/386).
|
||||
#
|
||||
# TIFF Library Tools
|
||||
#
|
||||
# Copyright (c) 1988-1996 Sam Leffler
|
||||
# Copyright (c) 1991-1996 Silicon Graphics, Inc.
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and
|
||||
# its documentation for any purpose is hereby granted without fee, provided
|
||||
# that (i) the above copyright notices and this permission notice appear in
|
||||
# all copies of the software and related documentation, and (ii) the names of
|
||||
# Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
# publicity relating to the software without the specific, prior written
|
||||
# permission of Stanford and Silicon Graphics.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
# OF THIS SOFTWARE.
|
||||
#
|
||||
DEPTH = ..
|
||||
SRCDIR = .
|
||||
LIBDIR = ${DEPTH}/libtiff
|
||||
|
||||
NULL =
|
||||
CC = gcc
|
||||
#
|
||||
COPTS =
|
||||
OPTIMIZER=-O
|
||||
IPATH = -I. -I${SRCDIR} -I${LIBDIR}
|
||||
CFLAGS = ${COPTS} ${OPTIMIZER} ${IPATH}
|
||||
#
|
||||
LIBTIFF = ${DEPTH}/libtiff/libtiff.a
|
||||
LIBJPEG = #@LIBJPEG@
|
||||
LIBGZ = #@LIBGZ@
|
||||
LIBS = ${LIBTIFF} ${LIBJPEG} ${LIBGZ}
|
||||
#
|
||||
OBJS= \
|
||||
fax2tiff.o \
|
||||
fax2ps.o \
|
||||
gif2tiff.o \
|
||||
pal2rgb.o \
|
||||
ppm2tiff.o \
|
||||
rgb2ycbcr.o \
|
||||
ras2tiff.o \
|
||||
thumbnail.o \
|
||||
tiff2bw.o \
|
||||
tiff2ps.o \
|
||||
tiffcmp.o \
|
||||
tiffcp.o \
|
||||
tiffdither.o \
|
||||
tiffdump.o \
|
||||
tiffinfo.o \
|
||||
tiffmedian.o \
|
||||
tiffsplit.o \
|
||||
${NULL}
|
||||
TARGETS =\
|
||||
fax2tiff \
|
||||
fax2ps \
|
||||
gif2tiff \
|
||||
pal2rgb \
|
||||
ppm2tiff \
|
||||
rgb2ycbcr \
|
||||
thumbnail \
|
||||
ras2tiff \
|
||||
tiff2bw \
|
||||
tiff2ps \
|
||||
tiffcmp \
|
||||
tiffcp \
|
||||
tiffdither \
|
||||
tiffdump \
|
||||
tiffinfo \
|
||||
tiffmedian \
|
||||
tiffsplit \
|
||||
${NULL}
|
||||
|
||||
all: ${TARGETS}
|
||||
|
||||
clean:
|
||||
rm -f ${TARGETS} ${addsuffix .exe, ${TARGETS}} ${OBJS}
|
||||
rm -f sgigt.o tiffgt sgisv.o tiffsv sgi2tiff.o sgi2tiff ycbcr
|
||||
|
||||
#
|
||||
# System-independent tools
|
||||
#
|
||||
|
||||
tiffinfo: tiffinfo.o ${LIBTIFF}
|
||||
${CC} -o tiffinfo ${CFLAGS} tiffinfo.o ${LIBS}
|
||||
tiffinfo.o: ${SRCDIR}/tiffinfo.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tiffinfo.c
|
||||
|
||||
tiffcmp:tiffcmp.o ${LIBTIFF}
|
||||
${CC} -o tiffcmp ${CFLAGS} tiffcmp.o ${LIBS}
|
||||
tiffcmp.o: ${SRCDIR}/tiffcmp.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tiffcmp.c
|
||||
|
||||
tiffcp: tiffcp.o ${LIBTIFF}
|
||||
${CC} -o tiffcp ${CFLAGS} tiffcp.o ${LIBS}
|
||||
tiffcp.o: ${SRCDIR}/tiffcp.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tiffcp.c
|
||||
|
||||
tiffdump: tiffdump.o
|
||||
${CC} -o tiffdump ${CFLAGS} tiffdump.o ${LIBS}
|
||||
tiffdump.o: ${SRCDIR}/tiffdump.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tiffdump.c
|
||||
|
||||
tiffmedian: tiffmedian.o ${LIBTIFF}
|
||||
${CC} -o tiffmedian ${CFLAGS} tiffmedian.o ${LIBS}
|
||||
tiffmedian.o: ${SRCDIR}/tiffmedian.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tiffmedian.c
|
||||
|
||||
tiffsplit: tiffsplit.o ${LIBTIFF}
|
||||
${CC} -o tiffsplit ${CFLAGS} tiffsplit.o ${LIBS}
|
||||
tiffsplit.o: ${SRCDIR}/tiffsplit.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tiffsplit.c
|
||||
|
||||
tiff2ps: tiff2ps.o ${LIBTIFF}
|
||||
${CC} -o tiff2ps ${CFLAGS} tiff2ps.o ${LIBS}
|
||||
tiff2ps.o: ${SRCDIR}/tiff2ps.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tiff2ps.c
|
||||
|
||||
#
|
||||
# Junky stuff... programs that are more examples of how
|
||||
# to use the library than full-blown useful tools.
|
||||
#
|
||||
|
||||
# convert RGB image to B&W
|
||||
tiff2bw: tiff2bw.o ${LIBTIFF}
|
||||
${CC} -o tiff2bw ${CFLAGS} tiff2bw.o ${LIBS}
|
||||
tiff2bw.o: ${SRCDIR}/tiff2bw.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tiff2bw.c
|
||||
|
||||
# convert B&W image to bilevel w/ FS dithering
|
||||
tiffdither: tiffdither.o ${LIBTIFF}
|
||||
${CC} -o tiffdither ${CFLAGS} tiffdither.o ${LIBS}
|
||||
tiffdither.o: ${SRCDIR}/tiffdither.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/tiffdither.c
|
||||
|
||||
# simple Sun rasterfile converter
|
||||
ras2tiff: ras2tiff.o ${LIBTIFF}
|
||||
${CC} -o ras2tiff ${CFLAGS} ras2tiff.o ${LIBS}
|
||||
ras2tiff.o: ${SRCDIR}/ras2tiff.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/ras2tiff.c
|
||||
|
||||
# simple GIF converter
|
||||
gif2tiff: gif2tiff.o ${LIBTIFF}
|
||||
${CC} -o gif2tiff ${CFLAGS} gif2tiff.o ${LIBS}
|
||||
gif2tiff.o: ${SRCDIR}/gif2tiff.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/gif2tiff.c
|
||||
|
||||
# very limited PBM converter
|
||||
ppm2tiff: ppm2tiff.o ${LIBTIFF}
|
||||
${CC} -o ppm2tiff ${CFLAGS} ppm2tiff.o ${LIBS}
|
||||
ppm2tiff.o: ${SRCDIR}/ppm2tiff.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/ppm2tiff.c
|
||||
|
||||
# Group 3/4 FAX file converter
|
||||
fax2tiff: fax2tiff.o ${LIBTIFF}
|
||||
${CC} -o fax2tiff ${CFLAGS} fax2tiff.o ${LIBS}
|
||||
fax2tiff.o: ${SRCDIR}/fax2tiff.c
|
||||
${CC} -c -I${LIBDIR} -I${DEPTH}/libtiff ${CFLAGS} ${SRCDIR}/fax2tiff.c
|
||||
|
||||
# Group 3/4 FAX to encoded PS converter
|
||||
fax2ps: fax2ps.o ${LIBTIFF}
|
||||
${CC} -o fax2ps ${CFLAGS} fax2ps.o ${LIBS}
|
||||
fax2ps.o: ${SRCDIR}/fax2ps.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/fax2ps.c
|
||||
|
||||
# convert Palette image to RGB
|
||||
pal2rgb: pal2rgb.o ${LIBTIFF}
|
||||
${CC} -o pal2rgb ${CFLAGS} pal2rgb.o ${LIBS}
|
||||
pal2rgb.o: ${SRCDIR}/pal2rgb.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/pal2rgb.c
|
||||
|
||||
# convert RGB image to YCbCr
|
||||
rgb2ycbcr: rgb2ycbcr.o ${LIBTIFF}
|
||||
${CC} -o rgb2ycbcr ${CFLAGS} rgb2ycbcr.o ${LIBS}
|
||||
rgb2ycbcr.o: ${SRCDIR}/rgb2ycbcr.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/rgb2ycbcr.c
|
||||
|
||||
# generate thumbnail images from fax (example of SubIFD usage)
|
||||
thumbnail: thumbnail.o ${LIBTIFF}
|
||||
${CC} -o thumbnail ${CFLAGS} thumbnail.o ${LIBS}
|
||||
thumbnail.o: ${SRCDIR}/thumbnail.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/thumbnail.c
|
||||
|
||||
#
|
||||
# System-specific tools.
|
||||
#
|
||||
|
||||
#
|
||||
# sgi2tiff converts SGI RGB images to TIFF; it requires
|
||||
# the SGI image library -limage.
|
||||
#
|
||||
sgi2tiff: sgi2tiff.o ${LIBTIFF}
|
||||
${CC} -o sgi2tiff ${CFLAGS} sgi2tiff.o -limage ${LIBS}
|
||||
sgi2tiff.o: ${SRCDIR}/sgi2tiff.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/sgi2tiff.c
|
||||
|
||||
# SGI versions of tiffgt & tiffsv that require -lgl
|
||||
tiffgt: sgigt.o ${LIBTIFF}
|
||||
${CC} -o tiffgt ${CFLAGS} sgigt.o ${LIBS} -lgutil -lgl_s
|
||||
sgigt.o: ${SRCDIR}/sgigt.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/sgigt.c
|
||||
|
||||
tiffsv: sgisv.o ${LIBTIFF}
|
||||
${CC} -o tiffsv ${CFLAGS} sgisv.o ${LIBS} -lgutil -lgl_s
|
||||
sgisv.o: ${SRCDIR}/sgisv.c
|
||||
${CC} -c ${CFLAGS} ${SRCDIR}/sgisv.c
|
||||
Executable
+54
@@ -0,0 +1,54 @@
|
||||
#! smake
|
||||
# $Header: /home/cvsroot/libtiff/contrib/dosdjgpp/Makefile.top,v 1.1.1.1 2000/06/24 19:10:17 tshead Exp $
|
||||
#
|
||||
# manually derived from Makefile.in (though basically nothing remains)
|
||||
# for DJGPP v2.x (GNU C for DOS/386).
|
||||
#
|
||||
# A warning about the filename structure:
|
||||
#
|
||||
# Some of the filenames used in the Makefiles are longer than 8 characters
|
||||
# this will work with the normal 8.3 file system since all files are unique
|
||||
# in the first 8 chars. To compile under the long filename support in Win95
|
||||
# you can either extract the files with a program that truncates filenames
|
||||
# (e.g. the DOS pkunzip) and disable LFN support with set LFN=n or with a
|
||||
# program that supports long filenames (e.g. WinZip 6.0) and set LFN=y.
|
||||
# The default environment in djgpp 2 is supposed to have LFN disabled, but
|
||||
# due to a bug in the init code it doesn't work properly. Setting the LFN
|
||||
# variable explicitly should fix that.
|
||||
#
|
||||
# Tag Image File Format Library
|
||||
#
|
||||
# Copyright (c) 1988-1996 Sam Leffler
|
||||
# Copyright (c) 1991-1996 Silicon Graphics, Inc.
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and
|
||||
# its documentation for any purpose is hereby granted without fee, provided
|
||||
# that (i) the above copyright notices and this permission notice appear in
|
||||
# all copies of the software and related documentation, and (ii) the names of
|
||||
# Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
# publicity relating to the software without the specific, prior written
|
||||
# permission of Sam Leffler and Silicon Graphics.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
# OF THIS SOFTWARE.
|
||||
#
|
||||
|
||||
SRCDIR = .
|
||||
|
||||
all default:
|
||||
@${MAKE} -C libtiff
|
||||
@${MAKE} -C tools
|
||||
|
||||
clean:
|
||||
@${MAKE} -C libtiff clean
|
||||
@${MAKE} -C tools clean
|
||||
|
||||
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
@echo off
|
||||
rem copy the Makefiles for libtiff for DJGPP2 into proper locations
|
||||
rem we assume to be in $(top)/contrib/dosdjgpp/
|
||||
|
||||
copy Makefile.top ..\..\Makefile
|
||||
copy Makefile.lib ..\..\libtiff\Makefile
|
||||
copy port.h ..\..\libtiff\port.h
|
||||
copy Makefile.too* ..\..\tools\Makefile
|
||||
|
||||
echo all set for building the library. Now just do make
|
||||
cd ..\..
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#ifndef _PORT_
|
||||
#define _PORT_ 1
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
typedef unsigned char u_char;
|
||||
typedef unsigned short u_short;
|
||||
typedef unsigned int u_int;
|
||||
typedef unsigned long u_long;
|
||||
|
||||
#define HOST_FILLORDER FILLORDER_LSB2MSB
|
||||
#define HOST_BIGENDIAN 0
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
typedef double dblparam_t;
|
||||
#ifdef __STRICT_ANSI__
|
||||
#define INLINE __inline__
|
||||
#else
|
||||
#define INLINE inline
|
||||
#endif
|
||||
#define GLOBALDATA(TYPE,NAME) extern TYPE NAME
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
|
||||
This directory contains the files necessary to build the free TIFF library
|
||||
with the DJGPP v2 compiler under MSDOS. Since DJGPP defines the unix flag,
|
||||
I have created a port.h instead of putting the necessary defines into
|
||||
tiffcomp.h. Makefiles are included for the top level and the libtiff and
|
||||
tools directories.
|
||||
|
||||
All you have to do is copy the files into the respective directories and run
|
||||
make. If you want, you can use the conf.bat to do that for you, make sure that
|
||||
the file is stored with MSDOS text EOL-convention (CR/LF), otherwise the
|
||||
command.com will not do anything (if you used unzip, use the -a option,
|
||||
otherwise edit the file and save it again).
|
||||
|
||||
Note that you probably will not be able to built the library with the v1.x
|
||||
versions of djgpp, due to two problems. First, the top makefile calls a
|
||||
sub-make for each directory and you are likely to run out of memory, since
|
||||
each recursive invocation of a djgpp v1.x program requires about 130k, to
|
||||
avoid that, you can enter the directories manually and call make (well, there
|
||||
are only two dirs). The 2nd problem is that djgpp 1.x doesn't call the
|
||||
coff2exe (stubify) program when creating an executable. This means that all
|
||||
programs compiled are not converted to exe and consequently are not available
|
||||
for calling directly. For the tools directory, you can just call coff2exe for
|
||||
each program after make finishes, but in the libtiff directory, a few programs
|
||||
are created during the make process that have to be called for make to
|
||||
continue (e.g. mkg3states). Make will probably report an error at each
|
||||
such stage. To fix that, either add a coff2exe call before each program is
|
||||
called or call coff2exe manually and rerun make (there 2-3 such programs).
|
||||
|
||||
Alexander Lehmann <alex@hal.rhein-main.de>
|
||||
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
CC=gcc
|
||||
CFLAGS=
|
||||
iptcutil: iptcutil.c
|
||||
$(CC) $(CFLAGS) -o iptcutil iptcutil.c
|
||||
|
||||
clean:
|
||||
rm iptcutil *~
|
||||
|
||||
all: iptcutil
|
||||
|
||||
|
||||
|
||||
Executable
+920
@@ -0,0 +1,920 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#ifdef WIN32
|
||||
#include <io.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <memory.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#define STRNICMP strnicmp
|
||||
#else
|
||||
#define STRNICMP strncasecmp
|
||||
#endif
|
||||
|
||||
typedef struct _tag_spec
|
||||
{
|
||||
short
|
||||
id;
|
||||
|
||||
char
|
||||
*name;
|
||||
} tag_spec;
|
||||
|
||||
static tag_spec tags[] = {
|
||||
5,"Image Name",
|
||||
7,"Edit Status",
|
||||
10,"Priority",
|
||||
15,"Category",
|
||||
20,"Supplemental Category",
|
||||
22,"Fixture Identifier",
|
||||
25,"Keyword",
|
||||
30,"Release Date",
|
||||
35,"Release Time",
|
||||
40,"Special Instructions",
|
||||
45,"Reference Service",
|
||||
47,"Reference Date",
|
||||
50,"Reference Number",
|
||||
55,"Created Date",
|
||||
60,"Created Time",
|
||||
65,"Originating Program",
|
||||
70,"Program Version",
|
||||
75,"Object Cycle",
|
||||
80,"Byline",
|
||||
85,"Byline Title",
|
||||
90,"City",
|
||||
95,"Province State",
|
||||
100,"Country Code",
|
||||
101,"Country",
|
||||
103,"Original Transmission Reference",
|
||||
105,"Headline",
|
||||
110,"Credit",
|
||||
115,"Source",
|
||||
116,"Copyright String",
|
||||
120,"Caption",
|
||||
121,"Local Caption",
|
||||
122,"Caption Writer",
|
||||
200,"Custom Field 1",
|
||||
201,"Custom Field 2",
|
||||
202,"Custom Field 3",
|
||||
203,"Custom Field 4",
|
||||
204,"Custom Field 5",
|
||||
205,"Custom Field 6",
|
||||
206,"Custom Field 7",
|
||||
207,"Custom Field 8",
|
||||
208,"Custom Field 9",
|
||||
209,"Custom Field 10",
|
||||
210,"Custom Field 11",
|
||||
211,"Custom Field 12",
|
||||
212,"Custom Field 13",
|
||||
213,"Custom Field 14",
|
||||
214,"Custom Field 15",
|
||||
215,"Custom Field 16",
|
||||
216,"Custom Field 17",
|
||||
217,"Custom Field 18",
|
||||
218,"Custom Field 19",
|
||||
219,"Custom Field 20"
|
||||
};
|
||||
|
||||
/*
|
||||
* We format the output using HTML conventions
|
||||
* to preserve control characters and such.
|
||||
*/
|
||||
void formatString(FILE *ofile, const char *s, int len)
|
||||
{
|
||||
putc('"', ofile);
|
||||
for (; len > 0; --len, ++s) {
|
||||
char c = *s;
|
||||
switch (c) {
|
||||
case '&':
|
||||
fputs("&", ofile);
|
||||
break;
|
||||
#ifdef HANDLE_GT_LT
|
||||
case '<':
|
||||
fputs("<", ofile);
|
||||
break;
|
||||
case '>':
|
||||
fputs(">", ofile);
|
||||
break;
|
||||
#endif
|
||||
case '"':
|
||||
fputs(""", ofile);
|
||||
break;
|
||||
default:
|
||||
if (iscntrl(c))
|
||||
fprintf(ofile, "&#%d;", c);
|
||||
else
|
||||
putc(*s, ofile);
|
||||
break;
|
||||
}
|
||||
}
|
||||
fputs("\"\n", ofile);
|
||||
}
|
||||
|
||||
typedef struct _html_code
|
||||
{
|
||||
short
|
||||
len;
|
||||
const char
|
||||
*code,
|
||||
val;
|
||||
} html_code;
|
||||
|
||||
static html_code html_codes[] = {
|
||||
#ifdef HANDLE_GT_LT
|
||||
4,"<",'<',
|
||||
4,">",'>',
|
||||
#endif
|
||||
5,"&",'&',
|
||||
6,""",'"'
|
||||
};
|
||||
|
||||
/*
|
||||
* This routine converts HTML escape sequence
|
||||
* back to the original ASCII representation.
|
||||
* - returns the number of characters dropped.
|
||||
*/
|
||||
int convertHTMLcodes(char *s, int len)
|
||||
{
|
||||
if (len <=0 || s==(char*)NULL || *s=='\0')
|
||||
return 0;
|
||||
|
||||
if (s[1] == '#')
|
||||
{
|
||||
int val, o;
|
||||
|
||||
if (sscanf(s,"&#%d;",&val) == 1)
|
||||
{
|
||||
o = 3;
|
||||
while (s[o] != ';')
|
||||
{
|
||||
o++;
|
||||
if (o > 5)
|
||||
break;
|
||||
}
|
||||
if (o < 5)
|
||||
strcpy(s+1, s+1+o);
|
||||
*s = val;
|
||||
return o;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int
|
||||
i,
|
||||
codes = sizeof(html_codes) / sizeof(html_code);
|
||||
|
||||
for (i=0; i < codes; i++)
|
||||
{
|
||||
if (html_codes[i].len <= len)
|
||||
if (STRNICMP(s, html_codes[i].code, html_codes[i].len) == 0)
|
||||
{
|
||||
strcpy(s+1, s+html_codes[i].len);
|
||||
*s = html_codes[i].val;
|
||||
return html_codes[i].len-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int formatIPTC(FILE *ifile, FILE *ofile)
|
||||
{
|
||||
unsigned int
|
||||
foundiptc,
|
||||
tagsfound;
|
||||
|
||||
unsigned char
|
||||
recnum,
|
||||
dataset;
|
||||
|
||||
unsigned char
|
||||
*readable,
|
||||
*str;
|
||||
|
||||
long
|
||||
tagindx,
|
||||
taglen;
|
||||
|
||||
int
|
||||
i,
|
||||
tagcount = sizeof(tags) / sizeof(tag_spec);
|
||||
|
||||
char
|
||||
c;
|
||||
|
||||
foundiptc = 0; /* found the IPTC-Header */
|
||||
tagsfound = 0; /* number of tags found */
|
||||
|
||||
c = getc(ifile);
|
||||
while (c != EOF)
|
||||
{
|
||||
if (c == 0x1c)
|
||||
foundiptc = 1;
|
||||
else
|
||||
{
|
||||
if (foundiptc)
|
||||
return -1;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
||||
/* we found the 0x1c tag and now grab the dataset and record number tags */
|
||||
dataset = getc(ifile);
|
||||
if ((char) dataset == EOF)
|
||||
return -1;
|
||||
recnum = getc(ifile);
|
||||
if ((char) recnum == EOF)
|
||||
return -1;
|
||||
/* try to match this record to one of the ones in our named table */
|
||||
for (i=0; i< tagcount; i++)
|
||||
{
|
||||
if (tags[i].id == recnum)
|
||||
break;
|
||||
}
|
||||
if (i < tagcount)
|
||||
readable = tags[i].name;
|
||||
else
|
||||
readable = "";
|
||||
|
||||
/* then we decode the length of the block that follows - long or short fmt */
|
||||
c = getc(ifile);
|
||||
if (c == EOF)
|
||||
return 0;
|
||||
if (c & (unsigned char) 0x80)
|
||||
{
|
||||
unsigned char
|
||||
buffer[4];
|
||||
|
||||
for (i=0; i<4; i++)
|
||||
{
|
||||
c = buffer[i] = getc(ifile);
|
||||
if (c == EOF)
|
||||
return -1;
|
||||
}
|
||||
taglen = (((long) buffer[ 0 ]) << 24) |
|
||||
(((long) buffer[ 1 ]) << 16) |
|
||||
(((long) buffer[ 2 ]) << 8) |
|
||||
(((long) buffer[ 3 ]));
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char
|
||||
x = c;
|
||||
|
||||
taglen = ((long) x) << 8;
|
||||
x = getc(ifile);
|
||||
if ((char)x == EOF)
|
||||
return -1;
|
||||
taglen |= (long) x;
|
||||
}
|
||||
/* make a buffer to hold the tag data and snag it from the input stream */
|
||||
str=(unsigned char *) malloc((unsigned int) (taglen+1));
|
||||
if (str == (unsigned char *) NULL)
|
||||
{
|
||||
printf("Memory allocation failed");
|
||||
return 0;
|
||||
}
|
||||
for (tagindx=0; tagindx<taglen; tagindx++)
|
||||
{
|
||||
c = str[tagindx] = getc(ifile);
|
||||
if (c == EOF)
|
||||
return -1;
|
||||
}
|
||||
str[ taglen ] = 0;
|
||||
|
||||
/* now finish up by formatting this binary data into ASCII equivalent */
|
||||
if (strlen(readable) > 0)
|
||||
fprintf(ofile, "%d#%d#%s=",(unsigned int)dataset, (unsigned int) recnum, readable);
|
||||
else
|
||||
fprintf(ofile, "%d#%d=",(unsigned int)dataset, (unsigned int) recnum);
|
||||
formatString( ofile, str, taglen );
|
||||
free(str);
|
||||
|
||||
tagsfound++;
|
||||
|
||||
c = getc(ifile);
|
||||
}
|
||||
return tagsfound;
|
||||
}
|
||||
|
||||
int tokenizer(unsigned inflag,char *token,int tokmax,char *line,
|
||||
char *white,char *brkchar,char *quote,char eschar,char *brkused,
|
||||
int *next,char *quoted);
|
||||
|
||||
char *super_fgets(char *b, int *blen, FILE *file)
|
||||
{
|
||||
int
|
||||
c,
|
||||
len;
|
||||
|
||||
unsigned char
|
||||
*q;
|
||||
|
||||
len=*blen;
|
||||
for (q=b; ; q++)
|
||||
{
|
||||
c=fgetc(file);
|
||||
if (c == EOF || c == '\n')
|
||||
break;
|
||||
if (((int)q - (int)b + 1 ) >= (int) len)
|
||||
{
|
||||
int
|
||||
tlen;
|
||||
|
||||
tlen=(int)q-(int)b;
|
||||
len<<=1;
|
||||
b=(unsigned char *) realloc((char *) b,(len+2));
|
||||
if ((unsigned char *) b == (unsigned char *) NULL)
|
||||
break;
|
||||
q=b+tlen;
|
||||
}
|
||||
*q=(unsigned char) c;
|
||||
}
|
||||
*blen=0;
|
||||
if ((unsigned char *)b != (unsigned char *) NULL)
|
||||
{
|
||||
int
|
||||
tlen;
|
||||
|
||||
tlen=(int)q - (int)b;
|
||||
if (tlen == 0)
|
||||
return (char *) NULL;
|
||||
b[tlen] = '\0';
|
||||
*blen=++tlen;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
#define BUFFER_SZ 4096
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
unsigned int
|
||||
length;
|
||||
|
||||
unsigned char
|
||||
*buffer;
|
||||
|
||||
int
|
||||
i,
|
||||
mode; /* iptc binary, or iptc text */
|
||||
|
||||
FILE
|
||||
*ifile = stdin,
|
||||
*ofile = stdout;
|
||||
|
||||
char
|
||||
c,
|
||||
*usage = "usage: iptcutil -t | -b [-i file] [-o file] <input >output";
|
||||
|
||||
if( argc < 2 )
|
||||
{
|
||||
printf(usage);
|
||||
return 1;
|
||||
}
|
||||
|
||||
mode = 0;
|
||||
length = -1;
|
||||
buffer = (unsigned char *)NULL;
|
||||
|
||||
for (i=1; i<argc; i++)
|
||||
{
|
||||
c = argv[i][0];
|
||||
if (c == '-' || c == '/')
|
||||
{
|
||||
c = argv[i][1];
|
||||
switch( c )
|
||||
{
|
||||
case 't':
|
||||
mode = 1;
|
||||
#ifdef WIN32
|
||||
/* Set "stdout" to binary mode: */
|
||||
_setmode( _fileno( ofile ), _O_BINARY );
|
||||
#endif
|
||||
break;
|
||||
case 'b':
|
||||
mode = 0;
|
||||
#ifdef WIN32
|
||||
/* Set "stdin" to binary mode: */
|
||||
_setmode( _fileno( ifile ), _O_BINARY );
|
||||
#endif
|
||||
break;
|
||||
case 'i':
|
||||
if (mode == 0)
|
||||
ifile = fopen(argv[++i], "rb");
|
||||
else
|
||||
ifile = fopen(argv[++i], "rt");
|
||||
if (ifile == (FILE *)NULL)
|
||||
{
|
||||
printf("Unable to open: %s\n", argv[i]);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case 'o':
|
||||
if (mode == 0)
|
||||
ofile = fopen(argv[++i], "wt");
|
||||
else
|
||||
ofile = fopen(argv[++i], "wb");
|
||||
if (ofile == (FILE *)NULL)
|
||||
{
|
||||
printf("Unable to open: %s\n", argv[i]);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
printf("Unknown option: %s\n", argv[i]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf(usage);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (mode == 0) /* handle binary iptc info */
|
||||
formatIPTC(ifile, ofile);
|
||||
|
||||
if (mode == 1) /* handle text form of iptc info */
|
||||
{
|
||||
char
|
||||
brkused,
|
||||
quoted,
|
||||
*line,
|
||||
*token,
|
||||
*newstr;
|
||||
|
||||
int
|
||||
state,
|
||||
next;
|
||||
|
||||
unsigned char
|
||||
recnum,
|
||||
dataset;
|
||||
|
||||
int
|
||||
inputlen = BUFFER_SZ;
|
||||
|
||||
line = (char *) malloc(inputlen);
|
||||
token = (char *)NULL;
|
||||
while((line = super_fgets(line,&inputlen,ifile))!=NULL)
|
||||
{
|
||||
state=0;
|
||||
next=0;
|
||||
|
||||
token = (char *) malloc(inputlen);
|
||||
newstr = (char *) malloc(inputlen);
|
||||
while(tokenizer(0, token, inputlen, line, "", "=", "\"", 0,
|
||||
&brkused,&next,"ed)==0)
|
||||
{
|
||||
if (state == 0)
|
||||
{
|
||||
int
|
||||
state,
|
||||
next;
|
||||
|
||||
char
|
||||
brkused,
|
||||
quoted;
|
||||
|
||||
state=0;
|
||||
next=0;
|
||||
while(tokenizer(0, newstr, inputlen, token, "", "#", "", 0,
|
||||
&brkused, &next, "ed)==0)
|
||||
{
|
||||
if (state == 0)
|
||||
dataset = (unsigned char) atoi(newstr);
|
||||
else
|
||||
if (state == 1)
|
||||
recnum = (unsigned char) atoi(newstr);
|
||||
state++;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (state == 1)
|
||||
{
|
||||
int
|
||||
next;
|
||||
|
||||
unsigned long
|
||||
len;
|
||||
|
||||
char
|
||||
brkused,
|
||||
quoted;
|
||||
|
||||
next=0;
|
||||
len = strlen(token);
|
||||
while(tokenizer(0, newstr, inputlen, token, "", "&", "", 0,
|
||||
&brkused, &next, "ed)==0)
|
||||
{
|
||||
if (brkused && next > 0)
|
||||
{
|
||||
char
|
||||
*s = &token[next-1];
|
||||
|
||||
len -= convertHTMLcodes(s, strlen(s));
|
||||
}
|
||||
}
|
||||
|
||||
fputc(0x1c, ofile);
|
||||
fputc(dataset, ofile);
|
||||
fputc(recnum, ofile);
|
||||
if (len < 0x10000)
|
||||
{
|
||||
fputc((len >> 8) & 255, ofile);
|
||||
fputc(len & 255, ofile);
|
||||
}
|
||||
else
|
||||
{
|
||||
fputc(((len >> 24) & 255) | 0x80, ofile);
|
||||
fputc((len >> 16) & 255, ofile);
|
||||
fputc((len >> 8) & 255, ofile);
|
||||
fputc(len & 255, ofile);
|
||||
}
|
||||
next=0;
|
||||
while (len--)
|
||||
fputc(token[next++], ofile);
|
||||
}
|
||||
state++;
|
||||
}
|
||||
free(token);
|
||||
token = (char *)NULL;
|
||||
free(newstr);
|
||||
newstr = (char *)NULL;
|
||||
}
|
||||
free(line);
|
||||
|
||||
fclose( ifile );
|
||||
fclose( ofile );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
This routine is a generalized, finite state token parser. It allows
|
||||
you extract tokens one at a time from a string of characters. The
|
||||
characters used for white space, for break characters, and for quotes
|
||||
can be specified. Also, characters in the string can be preceded by
|
||||
a specifiable escape character which removes any special meaning the
|
||||
character may have.
|
||||
|
||||
There are a lot of formal parameters in this subroutine call, but
|
||||
once you get familiar with them, this routine is fairly easy to use.
|
||||
"#define" macros can be used to generate simpler looking calls for
|
||||
commonly used applications of this routine.
|
||||
|
||||
First, some terminology:
|
||||
|
||||
token: used here, a single unit of information in
|
||||
the form of a group of characters.
|
||||
|
||||
white space: space that gets ignored (except within quotes
|
||||
or when escaped), like blanks and tabs. in
|
||||
addition, white space terminates a non-quoted
|
||||
token.
|
||||
|
||||
break character: a character that separates non-quoted tokens.
|
||||
commas are a common break character. the
|
||||
usage of break characters to signal the end
|
||||
of a token is the same as that of white space,
|
||||
except multiple break characters with nothing
|
||||
or only white space between generate a null
|
||||
token for each two break characters together.
|
||||
|
||||
for example, if blank is set to be the white
|
||||
space and comma is set to be the break
|
||||
character, the line ...
|
||||
|
||||
A, B, C , , DEF
|
||||
|
||||
... consists of 5 tokens:
|
||||
|
||||
1) "A"
|
||||
2) "B"
|
||||
3) "C"
|
||||
4) "" (the null string)
|
||||
5) "DEF"
|
||||
|
||||
quote character: a character that, when surrounding a group
|
||||
of other characters, causes the group of
|
||||
characters to be treated as a single token,
|
||||
no matter how many white spaces or break
|
||||
characters exist in the group. also, a
|
||||
token always terminates after the closing
|
||||
quote. for example, if ' is the quote
|
||||
character, blank is white space, and comma
|
||||
is the break character, the following
|
||||
string ...
|
||||
|
||||
A, ' B, CD'EF GHI
|
||||
|
||||
... consists of 4 tokens:
|
||||
|
||||
1) "A"
|
||||
2) " B, CD" (note the blanks & comma)
|
||||
3) "EF"
|
||||
4) "GHI"
|
||||
|
||||
the quote characters themselves do
|
||||
not appear in the resultant tokens. the
|
||||
double quotes are delimiters i use here for
|
||||
documentation purposes only.
|
||||
|
||||
escape character: a character which itself is ignored but
|
||||
which causes the next character to be
|
||||
used as is. ^ and \ are often used as
|
||||
escape characters. an escape in the last
|
||||
position of the string gets treated as a
|
||||
"normal" (i.e., non-quote, non-white,
|
||||
non-break, and non-escape) character.
|
||||
for example, assume white space, break
|
||||
character, and quote are the same as in the
|
||||
above examples, and further, assume that
|
||||
^ is the escape character. then, in the
|
||||
string ...
|
||||
|
||||
ABC, ' DEF ^' GH' I ^ J K^ L ^
|
||||
|
||||
... there are 7 tokens:
|
||||
|
||||
1) "ABC"
|
||||
2) " DEF ' GH"
|
||||
3) "I"
|
||||
4) " " (a lone blank)
|
||||
5) "J"
|
||||
6) "K L"
|
||||
7) "^" (passed as is at end of line)
|
||||
|
||||
|
||||
OK, now that you have this background, here's how to call "tokenizer":
|
||||
|
||||
result=tokenizer(flag,token,maxtok,string,white,break,quote,escape,
|
||||
brkused,next,quoted)
|
||||
|
||||
result: 0 if we haven't reached EOS (end of string), and
|
||||
1 if we have (this is an "int").
|
||||
|
||||
flag: right now, only the low order 3 bits are used.
|
||||
1 => convert non-quoted tokens to upper case
|
||||
2 => convert non-quoted tokens to lower case
|
||||
0 => do not convert non-quoted tokens
|
||||
(this is a "char").
|
||||
|
||||
token: a character string containing the returned next token
|
||||
(this is a "char[]").
|
||||
|
||||
maxtok: the maximum size of "token". characters beyond
|
||||
"maxtok" are truncated (this is an "int").
|
||||
|
||||
string: the string to be parsed (this is a "char[]").
|
||||
|
||||
white: a string of the valid white spaces. example:
|
||||
|
||||
char whitesp[]={" \t"};
|
||||
|
||||
blank and tab will be valid white space (this is
|
||||
a "char[]").
|
||||
|
||||
break: a string of the valid break characters. example:
|
||||
|
||||
char breakch[]={";,"};
|
||||
|
||||
semicolon and comma will be valid break characters
|
||||
(this is a "char[]").
|
||||
|
||||
IMPORTANT: do not use the name "break" as a C
|
||||
variable, as this is a reserved word in C.
|
||||
|
||||
quote: a string of the valid quote characters. an example
|
||||
would be
|
||||
|
||||
char whitesp[]={"'\"");
|
||||
|
||||
(this causes single and double quotes to be valid)
|
||||
note that a token starting with one of these characters
|
||||
needs the same quote character to terminate it.
|
||||
|
||||
for example,
|
||||
|
||||
"ABC '
|
||||
|
||||
is unterminated, but
|
||||
|
||||
"DEF" and 'GHI'
|
||||
|
||||
are properly terminated. note that different quote
|
||||
characters can appear on the same line; only for
|
||||
a given token do the quote characters have to be
|
||||
the same (this is a "char[]").
|
||||
|
||||
escape: the escape character (NOT a string ... only one
|
||||
allowed). use zero if none is desired (this is
|
||||
a "char").
|
||||
|
||||
brkused: the break character used to terminate the current
|
||||
token. if the token was quoted, this will be the
|
||||
quote used. if the token is the last one on the
|
||||
line, this will be zero (this is a pointer to a
|
||||
"char").
|
||||
|
||||
next: this variable points to the first character of the
|
||||
next token. it gets reset by "tokenizer" as it steps
|
||||
through the string. set it to 0 upon initialization,
|
||||
and leave it alone after that. you can change it
|
||||
if you want to jump around in the string or re-parse
|
||||
from the beginning, but be careful (this is a
|
||||
pointer to an "int").
|
||||
|
||||
quoted: set to 1 (true) if the token was quoted and 0 (false)
|
||||
if not. you may need this information (for example:
|
||||
in C, a string with quotes around it is a character
|
||||
string, while one without is an identifier).
|
||||
|
||||
(this is a pointer to a "char").
|
||||
*/
|
||||
|
||||
/* states */
|
||||
|
||||
#define IN_WHITE 0
|
||||
#define IN_TOKEN 1
|
||||
#define IN_QUOTE 2
|
||||
#define IN_OZONE 3
|
||||
|
||||
int _p_state; /* current state */
|
||||
unsigned _p_flag; /* option flag */
|
||||
char _p_curquote; /* current quote char */
|
||||
int _p_tokpos; /* current token pos */
|
||||
|
||||
/* routine to find character in string ... used only by "tokenizer" */
|
||||
|
||||
int sindex(char ch,char *string)
|
||||
{
|
||||
char *cp;
|
||||
for(cp=string;*cp;++cp)
|
||||
if(ch==*cp)
|
||||
return (int)(cp-string); /* return postion of character */
|
||||
return -1; /* eol ... no match found */
|
||||
}
|
||||
|
||||
/* routine to store a character in a string ... used only by "tokenizer" */
|
||||
|
||||
void chstore(char *string,int max,char ch)
|
||||
{
|
||||
char c;
|
||||
if(_p_tokpos>=0&&_p_tokpos<max-1)
|
||||
{
|
||||
if(_p_state==IN_QUOTE)
|
||||
c=ch;
|
||||
else
|
||||
switch(_p_flag&3)
|
||||
{
|
||||
case 1: /* convert to upper */
|
||||
c=toupper(ch);
|
||||
break;
|
||||
|
||||
case 2: /* convert to lower */
|
||||
c=tolower(ch);
|
||||
break;
|
||||
|
||||
default: /* use as is */
|
||||
c=ch;
|
||||
break;
|
||||
}
|
||||
string[_p_tokpos++]=c;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int tokenizer(unsigned inflag,char *token,int tokmax,char *line,
|
||||
char *white,char *brkchar,char *quote,char eschar,char *brkused,
|
||||
int *next,char *quoted)
|
||||
{
|
||||
int qp;
|
||||
char c,nc;
|
||||
|
||||
*brkused=0; /* initialize to null */
|
||||
*quoted=0; /* assume not quoted */
|
||||
|
||||
if(!line[*next]) /* if we're at end of line, indicate such */
|
||||
return 1;
|
||||
|
||||
_p_state=IN_WHITE; /* initialize state */
|
||||
_p_curquote=0; /* initialize previous quote char */
|
||||
_p_flag=inflag; /* set option flag */
|
||||
|
||||
for(_p_tokpos=0;c=line[*next];++(*next)) /* main loop */
|
||||
{
|
||||
if((qp=sindex(c,brkchar))>=0) /* break */
|
||||
{
|
||||
switch(_p_state)
|
||||
{
|
||||
case IN_WHITE: /* these are the same here ... */
|
||||
case IN_TOKEN: /* ... just get out */
|
||||
case IN_OZONE: /* ditto */
|
||||
++(*next);
|
||||
*brkused=brkchar[qp];
|
||||
goto byebye;
|
||||
|
||||
case IN_QUOTE: /* just keep going */
|
||||
chstore(token,tokmax,c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if((qp=sindex(c,quote))>=0) /* quote */
|
||||
{
|
||||
switch(_p_state)
|
||||
{
|
||||
case IN_WHITE: /* these are identical, */
|
||||
_p_state=IN_QUOTE; /* change states */
|
||||
_p_curquote=quote[qp]; /* save quote char */
|
||||
*quoted=1; /* set to true as long as something is in quotes */
|
||||
break;
|
||||
|
||||
case IN_QUOTE:
|
||||
if(quote[qp]==_p_curquote) /* same as the beginning quote? */
|
||||
{
|
||||
_p_state=IN_OZONE;
|
||||
_p_curquote=0;
|
||||
}
|
||||
else
|
||||
chstore(token,tokmax,c); /* treat as regular char */
|
||||
break;
|
||||
|
||||
case IN_TOKEN:
|
||||
case IN_OZONE:
|
||||
*brkused=c; /* uses quote as break char */
|
||||
goto byebye;
|
||||
}
|
||||
}
|
||||
else if((qp=sindex(c,white))>=0) /* white */
|
||||
{
|
||||
switch(_p_state)
|
||||
{
|
||||
case IN_WHITE:
|
||||
case IN_OZONE:
|
||||
break; /* keep going */
|
||||
|
||||
case IN_TOKEN:
|
||||
_p_state=IN_OZONE;
|
||||
break;
|
||||
|
||||
case IN_QUOTE:
|
||||
chstore(token,tokmax,c); /* it's valid here */
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(c==eschar) /* escape */
|
||||
{
|
||||
nc=line[(*next)+1];
|
||||
if(nc==0) /* end of line */
|
||||
{
|
||||
*brkused=0;
|
||||
chstore(token,tokmax,c);
|
||||
++(*next);
|
||||
goto byebye;
|
||||
}
|
||||
switch(_p_state)
|
||||
{
|
||||
case IN_WHITE:
|
||||
--(*next);
|
||||
_p_state=IN_TOKEN;
|
||||
break;
|
||||
|
||||
case IN_TOKEN:
|
||||
case IN_QUOTE:
|
||||
++(*next);
|
||||
chstore(token,tokmax,nc);
|
||||
break;
|
||||
|
||||
case IN_OZONE:
|
||||
goto byebye;
|
||||
}
|
||||
}
|
||||
else /* anything else is just a real character */
|
||||
{
|
||||
switch(_p_state)
|
||||
{
|
||||
case IN_WHITE:
|
||||
_p_state=IN_TOKEN; /* switch states */
|
||||
|
||||
case IN_TOKEN: /* these 2 are */
|
||||
case IN_QUOTE: /* identical here */
|
||||
chstore(token,tokmax,c);
|
||||
break;
|
||||
|
||||
case IN_OZONE:
|
||||
goto byebye;
|
||||
}
|
||||
}
|
||||
} /* end of main loop */
|
||||
|
||||
byebye:
|
||||
token[_p_tokpos]=0; /* make sure token ends with EOS */
|
||||
|
||||
return 0;
|
||||
}
|
||||
Executable
BIN
Binary file not shown.
Executable
+72
@@ -0,0 +1,72 @@
|
||||
|
||||
(* You must manually set the top-level PATHNAME here; everything else is automatic *)
|
||||
|
||||
set PATHNAME to "ritter:tiff-v3.4beta028:"
|
||||
set PRINTING to "NO"
|
||||
|
||||
set MKG3STATES to PATHNAME & "mkg3states.mw"
|
||||
set LIBTIFF to PATHNAME & "libtiff-68K.mw"
|
||||
set TIFFINFO to PATHNAME & "tiffinfo.mw"
|
||||
|
||||
with timeout of 60000 seconds
|
||||
tell application "MW C/C++ 68K 1.2.2"
|
||||
|
||||
activate
|
||||
|
||||
|
||||
(* Create tif_fax3sm.c file *)
|
||||
Create Project {file MKG3STATES}
|
||||
Add Files {"mkg3states.c", "mkg3_main.c", "getopt.c"}
|
||||
Add Files {"MacOS.lib"} To Segment 2
|
||||
Add Files {"ANSI (4i/8d) C.68K.Lib"} To Segment 3
|
||||
Add Files {"SIOUX.68K.Lib"} To Segment 4
|
||||
Add Files {"MathLib68K (4i/8d).Lib"} To Segment 5
|
||||
|
||||
Set Preferences To {Activate CPlusPlus:false, ARM Conformance:false, ANSI Keywords Only:false, Require Function Prototypes:false, Expand Trigraph Sequences:false, Enums Always Ints:false, MPW Pointer Type Rules:false, Prefix File:"mac_main.h"}
|
||||
Set Preferences To {Illegal Pragmas:false, Empty Declarations:false, Possible Errors:false, Unused Variables:false, Unused Arguments:false, Extra Commas:false, Extended Error Checking:false}
|
||||
Set Preferences To {Code Model:2, Struct Alignment:0, MC68020 CodeGen:false, MC68881 CodeGen:false, Four Bytes Ints:true, Eight Byte Double:true, Peephole Optimizer:true, CSE Optimizer:true, Optimize For Size:true, Far Data:true, Use Profiler:false, Far Virtual Function Tables:false, Far String Constants:true}
|
||||
Set Preferences To {MacsBug Symbols:2, Generate SYM File:false, Full Path In Sym Files:true, Generate Link Map:false, Generate A6 Stack Frames:true, The Debugger Aware:false, Link Single Segment:false, Fast Link:true}
|
||||
Set Preferences To {Project Type:0, File Name:"mkg3states", File Creator:"????", File Type:"APPL"}
|
||||
|
||||
Make Project
|
||||
Run Project
|
||||
Remove Binaries
|
||||
Close Project
|
||||
|
||||
|
||||
(* Create LIBTIFF *)
|
||||
Create Project {file LIBTIFF}
|
||||
Add Files {"tif_apple.c", "tif_aux.c", "tif_close.c", "tif_codec.c", "tif_compress.c", "tif_dumpmode.c", "tif_error.c", "tif_flush.c", "tif_lzw.c", "tif_next.c", "tif_open.c", "tif_packbits.c"}
|
||||
Add Files {"tif_fax3.c"} To Segment 2
|
||||
Add Files {"tif_dirinfo.c", "tif_dir.c", "tif_dirwrite.c", "tif_dirread.c"} To Segment 3
|
||||
Add Files {"tif_predict.c", "tif_print.c", "tif_read.c", "tif_strip.c", "tif_swab.c", "tif_thunder.c", "tif_tile.c", "tif_version.c", "tif_zip.c", "tif_jpeg.c", "tif_warning.c", "tif_write.c"} To Segment 4
|
||||
Add Files {"tif_fax3sm.c"} To Segment 5
|
||||
Add Files {"tif_getimage.c"} To Segment 6
|
||||
|
||||
Set Preferences To {Activate CPlusPlus:false, ARM Conformance:false, ANSI Keywords Only:false, Require Function Prototypes:false, Expand Trigraph Sequences:false, Enums Always Ints:false, MPW Pointer Type Rules:false, Prefix File:"MacHeaders68K"}
|
||||
Set Preferences To {Illegal Pragmas:false, Empty Declarations:false, Possible Errors:false, Unused Variables:false, Unused Arguments:false, Extra Commas:false, Extended Error Checking:false}
|
||||
Set Preferences To {Code Model:2, Struct Alignment:0, MC68020 CodeGen:false, MC68881 CodeGen:false, Four Bytes Ints:true, Eight Byte Double:true, Peephole Optimizer:true, CSE Optimizer:true, Optimize For Size:true, Far Data:true, Use Profiler:false, Far Virtual Function Tables:false, Far String Constants:true}
|
||||
Set Preferences To {MacsBug Symbols:2, Generate SYM File:true, Full Path In Sym Files:true, Generate Link Map:false, Generate A6 Stack Frames:true, The Debugger Aware:false, Link Single Segment:false, Fast Link:true}
|
||||
Set Preferences To {Project Type:2, File Name:"libtiff-68K", File Creator:"????", File Type:"APPL"}
|
||||
Make Project
|
||||
Close Project
|
||||
|
||||
Create Project {file TIFFINFO}
|
||||
Add Files {"tiffinfo.c", "mac_main.c", "getopt.c"}
|
||||
Add Files {"MacOS.lib"} To Segment 2
|
||||
Add Files {"ANSI (4i/8d) C.68K.Lib"} To Segment 3
|
||||
Add Files {"SIOUX.68K.Lib"} To Segment 4
|
||||
Add Files {"MathLib68K (4i/8d).Lib"} To Segment 5
|
||||
Add Files {"libtiff-68K"} To Segment 6
|
||||
|
||||
Set Preferences To {Activate CPlusPlus:false, ARM Conformance:false, ANSI Keywords Only:false, Require Function Prototypes:false, Expand Trigraph Sequences:false, Enums Always Ints:false, MPW Pointer Type Rules:false, Prefix File:"mac_main.h"}
|
||||
Set Preferences To {Illegal Pragmas:false, Empty Declarations:false, Possible Errors:false, Unused Variables:false, Unused Arguments:false, Extra Commas:false, Extended Error Checking:false}
|
||||
Set Preferences To {Code Model:2, Struct Alignment:0, MC68020 CodeGen:false, MC68881 CodeGen:false, Four Bytes Ints:true, Eight Byte Double:true, Peephole Optimizer:true, CSE Optimizer:true, Optimize For Size:true, Far Data:true, Use Profiler:false, Far Virtual Function Tables:false, Far String Constants:true}
|
||||
Set Preferences To {MacsBug Symbols:2, Generate SYM File:false, Full Path In Sym Files:true, Generate Link Map:false, Generate A6 Stack Frames:true, The Debugger Aware:false, Link Single Segment:false, Fast Link:true}
|
||||
Set Preferences To {Project Type:0, File Name:"tiffinfo", File Creator:"????", File Type:"APPL"}
|
||||
|
||||
Make Project
|
||||
Close Project
|
||||
|
||||
end tell
|
||||
end timeout
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* mac_main.c -- The REAL entry point which
|
||||
* calls the tools main code. For the tools
|
||||
* the symbol "main" has been #defined to "tool_main"
|
||||
* so that this entry point may be used to access
|
||||
* the user-input first.
|
||||
*/
|
||||
|
||||
#undef main
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
argc=ccommand(&argv);
|
||||
|
||||
return tool_main(argc,argv); // Call the tool "main()" routine
|
||||
}
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* mac_main.h -- redefines main entry point
|
||||
*/
|
||||
|
||||
#ifndef _mac_main_h
|
||||
#define _mac_main_h
|
||||
|
||||
#undef main
|
||||
#define main tool_main
|
||||
|
||||
#endif /* _mac_main_h */
|
||||
|
||||
Executable
+84
@@ -0,0 +1,84 @@
|
||||
----------------------------------------------------
|
||||
Build instructions for LIBTIFF - CodeWarrior (6.1):
|
||||
----------------------------------------------------
|
||||
|
||||
Note: there is a bug in CW earlier than 6.1 which will generate
|
||||
16-bit offset link errors for any projects using libtiff; you must
|
||||
download the CodeWarrior 6.1 patch located at:
|
||||
|
||||
ftp://ftp.metrowerks.com/pub/updates/metro-patches-61.hqx
|
||||
|
||||
unpack the archive, insert the files and recompile the libraries
|
||||
using the AppleScript provided.
|
||||
|
||||
|
||||
1. Make sure that the directory containing these files is under
|
||||
the "contrib" directory of the tiff folder; otherwise, some
|
||||
access path preferences will need to be updated.
|
||||
|
||||
2. The instructions below are for the 68k platform build.
|
||||
A similar script can be put together for the PPC version,
|
||||
or you can just directly convert the projects. Be sure to
|
||||
use the native libraries as well. NOTE: if anyone cooks
|
||||
up an equivalent script for PPC, send it to me and I'll include
|
||||
it with the rest of the package.
|
||||
|
||||
3. Open the file Makefile.script with an AppleScript Editor
|
||||
and change the PATHNAME variable to point to your
|
||||
top-level TIFF directory
|
||||
|
||||
4. Run the Script. It will do the following things:
|
||||
|
||||
4a. Prompt you for the current location of the CodeWarrior 68K
|
||||
program.
|
||||
|
||||
4b. Create the source file "tif_fax3sm.c":
|
||||
|
||||
i) Build the project CW project mkg3states.cw. It will
|
||||
produce a small program called mkg3states. Only a
|
||||
68k version is provided, since you only have to run
|
||||
this code once, and it only takes a few seconds.
|
||||
|
||||
ii) Run the built mkg3states program:
|
||||
|
||||
The program will temporarily take over ALL of the CPU, so
|
||||
don't panic. After a few seconds it will produce a file called
|
||||
"tif_fax3sm.c".
|
||||
|
||||
4c. Build the library project libtiff-68K.mw, producing library
|
||||
called libtiff-68K.
|
||||
|
||||
4d. Build program project tiffinfo.mw; it will produce a
|
||||
program called tiffinfo, which can dump the tiff tags of
|
||||
a named file. Passing in no arguments will dump a help file
|
||||
for the program. It is unix-flavored, but hey, it works.
|
||||
|
||||
5 When the script finishes, you will have a usable libtiff-68K
|
||||
library, a passable "tiffinfo" program, and the projects used
|
||||
to build them. Note that to get tiffinfo to work I have put
|
||||
an include file in the project that redefines main(), and
|
||||
then have a mac_main.c program that calls ccommand() first
|
||||
and passes that to the actual main code. A real mac app,
|
||||
of course, would never use this stuff at all...
|
||||
|
||||
. The tiffinfo.mw project may be used as a template to build
|
||||
most of the other libtiff tools, or your own code. When
|
||||
modifying a copy of the project, you will most likely need
|
||||
to update the "Access Paths" directory if it is moved out of
|
||||
the contrib folder.
|
||||
|
||||
6. If you are going to create a project from scratch, be sure
|
||||
to set up the preferences with
|
||||
|
||||
4-byte ints
|
||||
8-byte doubles
|
||||
Far Code/Far Data
|
||||
Large Linking model
|
||||
|
||||
and everything should work fine. If the console-style error
|
||||
reports bother you, you can always override the error and
|
||||
warning mechanism with TIFFSetErrorHandler to do something
|
||||
more Mac-like.
|
||||
|
||||
Questions, comments to Niles Ritter (ndr@tazboy.jpl.nasa.gov).
|
||||
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* mkg3_main.c -- passes fake arguments into main
|
||||
*/
|
||||
|
||||
#undef main
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
static char *argv[4] = {
|
||||
"mkg3states", "-c", "const", "tif_fax3sm.c" };
|
||||
|
||||
return tool_main(4,argv); // Call the tool "main()" routine
|
||||
}
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
----------------------------------------------------
|
||||
Build instructions for LIBTIFF - CodeWarrior (6.1):
|
||||
----------------------------------------------------
|
||||
|
||||
In this directory you will find a Makefile.script Applescript
|
||||
file, which should be run in order to build the libtiff code
|
||||
using MetroWerks CodeWarrior.
|
||||
|
||||
Refer to the "metrowerks.note" instructions on building the
|
||||
library for 68k and PowerPC native code, as well as building
|
||||
some of the libtiff tools, which are rather unix-like, but
|
||||
at least give an example of how to link everything together.
|
||||
|
||||
Questions, comments, bug reports to Niles Ritter
|
||||
(ndr@tazboy.jpl.nasa.gov). Sam Leffler takes no responsibility
|
||||
for the viability of this stuff.
|
||||
|
||||
-Niles.
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
#define VERSION \
|
||||
"LIBTIFF, Version 3.4beta028 \n"\
|
||||
"Copyright (c) 1988-1995 Sam Leffler\n"\
|
||||
"Copyright (c) 1991-1996 Silicon Graphics, Inc."
|
||||
Executable
+47
@@ -0,0 +1,47 @@
|
||||
# BUILD.mpw:
|
||||
#
|
||||
# Full build for Apple Macintosh Programmer's Workshop (MPW).
|
||||
#
|
||||
# This is an executable MPW script which creates various
|
||||
# utilities, sets up the MPW makefiles and runs the builds.
|
||||
# This script should be run at the top level TIFF directory with:
|
||||
#
|
||||
# directory :::
|
||||
# :contrib:mac-mpw:BUILD.mpw
|
||||
#
|
||||
# NOTE: The full build requires that MPW have at least 6 MB
|
||||
# allocated to it to compile the CCITT Fax codec tables. To
|
||||
# deactivate CCITT compression edit the file :contrib:mac:libtiff.make
|
||||
# first and follow the directions for disabling Fax decoding.
|
||||
#
|
||||
# All TIFF tools are built as MPW tools, executable from the
|
||||
# MPW shell or other compatible tool server.
|
||||
#
|
||||
# Written by: Niles Ritter (ndr@tazboy.jpl.nasa.gov).
|
||||
#
|
||||
|
||||
echo "############# Full Scratch Build for MPW #############"
|
||||
|
||||
# Create the ascii->mpw translation tool; this is used to
|
||||
# convert standard ASCII files into ones using the special
|
||||
# MPW characters, which don't live comfortably in unix tar files.
|
||||
#
|
||||
echo "######## Creating ASCII->MPW translator ########"
|
||||
set contrib ':contrib:mac-mpw:'
|
||||
directory {contrib}
|
||||
createmake -tool mactrans mactrans.c > dev:null
|
||||
make -f mactrans.make | streamedit -e "/CSANELib/||/Math/||/ToolLibs/ del" > mactrans.bld
|
||||
execute mactrans.bld > dev:null
|
||||
delete -y mactrans.make mactrans.bld mactrans.c.o || set status 0
|
||||
directory ::: #An mpw trick for going up two levels
|
||||
|
||||
# Create the top-level Makefile and run it
|
||||
echo "######## Creating Makefile ########"
|
||||
catenate {contrib}top.make | {contrib}mactrans > Makefile
|
||||
|
||||
echo "######## Running Makefile ########"
|
||||
make > build.mpw
|
||||
execute build.mpw
|
||||
echo "############# MPW Build Complete #############"
|
||||
exit 0
|
||||
|
||||
Executable
+202
@@ -0,0 +1,202 @@
|
||||
#
|
||||
# Tag Image File Format Library
|
||||
#
|
||||
# Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler
|
||||
# Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc.
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and
|
||||
# its documentation for any purpose is hereby granted without fee, provided
|
||||
# that (i) the above copyright notices and this permission notice appear in
|
||||
# all copies of the software and related documentation, and (ii) the names of
|
||||
# Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
# publicity relating to the software without the specific, prior written
|
||||
# permission of Sam Leffler and Silicon Graphics.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
# OF THIS SOFTWARE.
|
||||
#
|
||||
|
||||
#
|
||||
# Makefile for Mac using MPW 3.3.1 and MPW C 3.2.4
|
||||
#
|
||||
# Note: This file must be run through "mactrans" before it can
|
||||
# be recognized by MPW as a valid makefile. The problem is that MPW
|
||||
# uses special non-ASCII characters, which tend to get mangled when stored
|
||||
# in unix tar files, etc. "mactrans" is built as part of the TIFF MPW build.
|
||||
#
|
||||
#
|
||||
|
||||
DEPTH = ::
|
||||
|
||||
# FAX Options: If you do not wish to include the FAX options, uncomment
|
||||
# the first four definitions and comment out the next four
|
||||
# definitions. Note that to build programs with the FAX libraries you
|
||||
# have to include "-model far" in your compile and link statements.
|
||||
#
|
||||
# Also, to build the fax code (including the tif_fax3sm.c file, which is
|
||||
# created by the MPW tool "mkg3states", also built below), you will
|
||||
# need to size the MPW program up to about 6 megabytes or so.
|
||||
|
||||
#FAX_OPTIONS =
|
||||
#FAX_OBJECTS =
|
||||
#FAX_SOURCES = tif_fax3.c
|
||||
#FAX_CONFIG =
|
||||
|
||||
FAX_OPTIONS = -model far
|
||||
FAX_OBJECTS = tif_fax3.c.o tif_fax3sm.c.o
|
||||
FAX_SOURCES = tif_fax3.c tif_fax3sm.c
|
||||
FAX_CONFIG = -d CCITT_SUPPORT
|
||||
|
||||
NULL=
|
||||
|
||||
RM = delete -y -i
|
||||
COPTS =
|
||||
|
||||
LIBPORT=::port:libport.o
|
||||
|
||||
#
|
||||
.c.o %c4 .c
|
||||
{C} -model far {CFLAGS} -s {Default} {DepDir}{Default}.c -o {TargDir}{Default}.c.o
|
||||
|
||||
|
||||
CONF_LIBRARY= %b6
|
||||
-d HAVE_IEEEFP=1 %b6
|
||||
-d BSDTYPES
|
||||
|
||||
CONF_COMPRESSION= %b6
|
||||
{FAX_CONFIG} %b6
|
||||
-d COMPRESSION_SUPPORT %b6
|
||||
-d PACKBITS_SUPPORT %b6
|
||||
-d LZW_SUPPORT %b6
|
||||
-d THUNDER_SUPPORT %b6
|
||||
-d NEXT_SUPPORT
|
||||
|
||||
CFLAGS= {FAX_OPTIONS} {IPATH} {CONF_LIBRARY} {CONF_COMPRESSION}
|
||||
|
||||
INCS= tiff.h tiffio.h
|
||||
|
||||
SRCS= %b6
|
||||
{FAX_SOURCES} %b6
|
||||
tif_apple.c %b6
|
||||
tif_aux.c %b6
|
||||
tif_close.c %b6
|
||||
tif_codec.c %b6
|
||||
tif_compress.c %b6
|
||||
tif_dir.c %b6
|
||||
tif_dirinfo.c %b6
|
||||
tif_dirread.c %b6
|
||||
tif_dirwrite.c %b6
|
||||
tif_dumpmode.c %b6
|
||||
tif_error.c %b6
|
||||
tif_getimage.c %b6
|
||||
tif_jpeg.c %b6
|
||||
tif_flush.c %b6
|
||||
tif_lzw.c %b6
|
||||
tif_next.c %b6
|
||||
tif_open.c %b6
|
||||
tif_packbits.c %b6
|
||||
tif_predict.c %b6
|
||||
tif_print.c %b6
|
||||
tif_read.c %b6
|
||||
tif_swab.c %b6
|
||||
tif_strip.c %b6
|
||||
tif_thunder.c %b6
|
||||
tif_tile.c %b6
|
||||
tif_version.c %b6
|
||||
tif_warning.c %b6
|
||||
tif_write.c %b6
|
||||
tif_zip.c %b6
|
||||
{NULL}
|
||||
|
||||
OBJS= %b6
|
||||
{FAX_OBJECTS} %b6
|
||||
tif_apple.c.o %b6
|
||||
tif_aux.c.o %b6
|
||||
tif_close.c.o %b6
|
||||
tif_codec.c.o %b6
|
||||
tif_compress.c.o %b6
|
||||
tif_dir.c.o %b6
|
||||
tif_dirinfo.c.o %b6
|
||||
tif_dirread.c.o %b6
|
||||
tif_dirwrite.c.o %b6
|
||||
tif_dumpmode.c.o %b6
|
||||
tif_error.c.o %b6
|
||||
tif_getimage.c.o %b6
|
||||
tif_jpeg.c.o %b6
|
||||
tif_flush.c.o %b6
|
||||
tif_lzw.c.o %b6
|
||||
tif_next.c.o %b6
|
||||
tif_open.c.o %b6
|
||||
tif_packbits.c.o %b6
|
||||
tif_predict.c.o %b6
|
||||
tif_print.c.o %b6
|
||||
tif_read.c.o %b6
|
||||
tif_swab.c.o %b6
|
||||
tif_strip.c.o %b6
|
||||
tif_thunder.c.o %b6
|
||||
tif_tile.c.o %b6
|
||||
tif_version.c.o %b6
|
||||
tif_warning.c.o %b6
|
||||
tif_write.c.o %b6
|
||||
tif_zip.c.o %b6
|
||||
{NULL}
|
||||
|
||||
ALL=libtiff.o
|
||||
|
||||
all %c4 {ALL}
|
||||
|
||||
libtiff.o %c4 {OBJS}
|
||||
Lib {OBJS} -o libtiff.o
|
||||
|
||||
|
||||
{OBJS} %c4 tiffio.h tiff.h tiffcomp.h tiffiop.h tiffconf.h
|
||||
|
||||
#
|
||||
# The finite state machine tables used by the G3/G4 decoders
|
||||
# are generated by the mkg3states program. On systems without
|
||||
# make these rules have to be manually carried out.
|
||||
#
|
||||
tif_fax3sm.c %c4 mkg3states tif_fax3.h
|
||||
{RM} tif_fax3sm.c || set status 0
|
||||
:mkg3states -c const tif_fax3sm.c
|
||||
|
||||
mkg3states.c.o %c4 mkg3states.c
|
||||
C -model far mkg3states.c -o mkg3states.c.o
|
||||
|
||||
mkg3states %c4%c4 mkg3states.c.o
|
||||
Link -model far -d -c 'MPS ' -t MPST %b6
|
||||
mkg3states.c.o %b6
|
||||
{LIBPORT} %b6
|
||||
"{CLibraries}"StdClib.o %b6
|
||||
"{Libraries}"Stubs.o %b6
|
||||
"{Libraries}"Runtime.o %b6
|
||||
"{Libraries}"Interface.o %b6
|
||||
-o mkg3states
|
||||
|
||||
ALPHA = "{DEPTH}dist:tiff.alpha"
|
||||
VERSION = "{DEPTH}VERSION"
|
||||
|
||||
version.h %c4 {VERSION} {ALPHA}
|
||||
Set VERSION1 `catenate {VERSION}`
|
||||
Set VERSION2 "{VERSION1}`streamedit -e "1 rep /%a5%c5 %c5 (%c5)%a81/ %a81" {ALPHA}`"
|
||||
delete -y -i version.h || set status 0
|
||||
echo '#define VERSION "LIBTIFF, Version' {VERSION2} '\nCopyright (c) 1988-1995 Sam Leffler\nCopyright (c) 1991-1995 Silicon Graphics, Inc."' >version.h
|
||||
|
||||
tif_version.c.o %c4 version.h
|
||||
|
||||
clean %c4
|
||||
{RM} {ALL} || set status 0
|
||||
{RM} {OBJS} || set status 0
|
||||
{RM} mkg3states || set status 0
|
||||
{RM} mkg3states.c.o || set status 0
|
||||
{RM} tif_fax3sm.c%c5 || set status 0
|
||||
{RM} version.h || set status 0
|
||||
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* mactrans.c -- Hack filter used to generate MPW files
|
||||
* with special characters from pure ASCII, denoted "%nn"
|
||||
* where nn is hex. (except for "%%", which is literal '%').
|
||||
*
|
||||
* calling sequence:
|
||||
*
|
||||
* catenate file | mactrans [-toascii | -fromascii] > output
|
||||
*
|
||||
* Written by: Niles Ritter.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
|
||||
void to_ascii(void);
|
||||
void from_ascii(void);
|
||||
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
if (argc<2 || argv[1][1]=='f') from_ascii();
|
||||
else to_ascii();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
void from_ascii(void)
|
||||
{
|
||||
char c;
|
||||
int d;
|
||||
while ((c=getchar())!=EOF)
|
||||
{
|
||||
if (c!='%' || (c=getchar())=='%') putchar(c);
|
||||
else
|
||||
{
|
||||
ungetc(c,stdin);
|
||||
scanf("%2x",&d);
|
||||
*((unsigned char *)&c) = d;
|
||||
putchar(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void to_ascii(void)
|
||||
{
|
||||
char c;
|
||||
int d;
|
||||
while ((c=getchar())!=EOF)
|
||||
{
|
||||
if (isascii(c)) putchar (c);
|
||||
else
|
||||
{
|
||||
d = *((unsigned char *)&c);
|
||||
printf("%%%2x",d);
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+53
@@ -0,0 +1,53 @@
|
||||
#
|
||||
# Tag Image File Format Library
|
||||
#
|
||||
# Copyright (c) 1995 Sam Leffler
|
||||
# Copyright (c) 1995 Silicon Graphics, Inc.
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and
|
||||
# its documentation for any purpose is hereby granted without fee, provided
|
||||
# that (i) the above copyright notices and this permission notice appear in
|
||||
# all copies of the software and related documentation, and (ii) the names of
|
||||
# Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
# publicity relating to the software without the specific, prior written
|
||||
# permission of Sam Leffler and Silicon Graphics.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
# OF THIS SOFTWARE.
|
||||
#
|
||||
DEPTH= ::
|
||||
SRCDIR= :
|
||||
|
||||
NULL =
|
||||
CC = C
|
||||
AR = Lib
|
||||
AROPTS =
|
||||
RM= delete -y
|
||||
|
||||
IPATH = -I {DEPTH} -I {SRCDIR}
|
||||
COPTS =
|
||||
OPTIMIZER=
|
||||
CFLAGS = {COPTS} {OPTIMIZER} {IPATH}
|
||||
|
||||
CFILES =
|
||||
OBJECTS = getopt.c.o
|
||||
TARGETS = libport.o
|
||||
|
||||
.c.o %c4 .c
|
||||
{CC} -model far {COptions} {CFLAGS} -s {Default} {DepDir}{Default}.c -o {TargDir}{Default}.c.o
|
||||
|
||||
all %c4 {TARGETS}
|
||||
|
||||
libport.o %c4 {OBJECTS}
|
||||
{AR} {OBJECTS} -o libport.o
|
||||
|
||||
clean %c4
|
||||
{RM} {TARGETS} {OBJECTS} || set status 0
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
######################
|
||||
About contrib:mac-mpw:
|
||||
######################
|
||||
|
||||
This directory contains all of the utilities and makefile source
|
||||
to build the LIBTIFF library and tools from the MPW Shell. The
|
||||
file BUILD.mpw in this directory is an executable script
|
||||
which uses all of these files to create the MPW makefiles and
|
||||
run them.
|
||||
|
||||
The <file>.make files are not MPW makefiles as such,
|
||||
but are when run through the "mactrans" program, which turns
|
||||
the ascii "%nn" metacharacters into the standard weird MPW
|
||||
make characters.
|
||||
|
||||
This translation trick is necessary to protect the files when
|
||||
they are put into unix tarfiles, which tend to mangle the
|
||||
special characters.
|
||||
|
||||
--Niles Ritter (ndr@tazboy.jpl.nasa.gov)
|
||||
Executable
+138
@@ -0,0 +1,138 @@
|
||||
#
|
||||
# Tag Image File Format Library
|
||||
#
|
||||
# Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler
|
||||
# Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc.
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and
|
||||
# its documentation for any purpose is hereby granted without fee, provided
|
||||
# that (i) the above copyright notices and this permission notice appear in
|
||||
# all copies of the software and related documentation, and (ii) the names of
|
||||
# Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
# publicity relating to the software without the specific, prior written
|
||||
# permission of Stanford and Silicon Graphics.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
# OF THIS SOFTWARE.
|
||||
#
|
||||
|
||||
#
|
||||
# Makefile for Mac using MPW 3.2.3 and MPW C 3.2.4
|
||||
#
|
||||
COPTS = -model far
|
||||
|
||||
.c.o %c4 .c
|
||||
{C} {COPTS} {CFLAGS} -s {Default} {DepDir}{Default}.c -o {TargDir}{Default}.c.o
|
||||
|
||||
RM = delete -y -i
|
||||
|
||||
CONF_LIBRARY= %b6
|
||||
-d USE_CONST=0 %b6
|
||||
-d BSDTYPES
|
||||
NULL=
|
||||
|
||||
IPATH= -I ::libtiff
|
||||
|
||||
CFLAGS= -w -m {IPATH} {CONF_LIBRARY}
|
||||
|
||||
LIBPORT= ::port:libport.o
|
||||
|
||||
LOptions= -model far -w -srt -d -c 'MPS ' -t MPST
|
||||
|
||||
LIBTIFF= ::libtiff:libtiff.o
|
||||
|
||||
LIBS= {LIBTIFF} %b6
|
||||
{LIBPORT} %b6
|
||||
"{CLibraries}"CSANELib.o %b6
|
||||
"{CLibraries}"Math.o %b6
|
||||
"{CLibraries}"StdClib.o %b6
|
||||
"{Libraries}"Stubs.o %b6
|
||||
"{Libraries}"Runtime.o %b6
|
||||
"{Libraries}"Interface.o %b6
|
||||
"{Libraries}"ToolLibs.o %b6
|
||||
{NULL}
|
||||
|
||||
SRCS= %b6
|
||||
pal2rgb.c %b6
|
||||
ras2tiff.c %b6
|
||||
thumbnail.c %b6
|
||||
tiff2bw.c %b6
|
||||
tiff2ps.c %b6
|
||||
tiffcmp.c %b6
|
||||
tiffcp.c %b6
|
||||
tiffdither.c %b6
|
||||
tiffdump.c %b6
|
||||
tiffinfo.c %b6
|
||||
tiffmedian.c %b6
|
||||
{NULL}
|
||||
|
||||
MACHALL=ras2tiff
|
||||
|
||||
ALL= %b6
|
||||
tiffinfo %b6
|
||||
tiffcmp %b6
|
||||
tiffcp %b6
|
||||
tiffdump %b6
|
||||
tiffmedian %b6
|
||||
tiff2bw %b6
|
||||
tiffdither %b6
|
||||
tiff2ps %b6
|
||||
pal2rgb %b6
|
||||
gif2tiff %b6
|
||||
{MACHALL}
|
||||
|
||||
all %c4 {ALL}
|
||||
|
||||
tiffinfo %c4 tiffinfo.c.o {LIBTIFF}
|
||||
Link {LOptions} tiffinfo.c.o {LIBS} -o tiffinfo
|
||||
|
||||
tiffcmp %c4 tiffcmp.c.o {LIBTIFF}
|
||||
Link {LOptions} tiffcmp.c.o {LIBS} -o tiffcmp
|
||||
|
||||
tiffcp %c4 tiffcp.c.o {LIBTIFF}
|
||||
Link {LOptions} tiffcp.c.o {LIBS} -o tiffcp
|
||||
|
||||
tiffdump %c4 tiffdump.c.o {LIBTIFF}
|
||||
Link {LOptions} tiffdump.c.o {LIBS} -o tiffdump
|
||||
|
||||
tiffmedian %c4 tiffmedian.c.o {LIBTIFF}
|
||||
Link {LOptions} tiffmedian.c.o {LIBS} -o tiffmedian
|
||||
|
||||
tiff2ps %c4 tiff2ps.c.o {LIBTIFF}
|
||||
Link {LOptions} tiff2ps.c.o {LIBS} -o tiff2ps
|
||||
|
||||
# junky stuff...
|
||||
# convert RGB image to B&W
|
||||
tiff2bw %c4 tiff2bw.c.o {LIBTIFF}
|
||||
Link {LOptions} tiff2bw.c.o {LIBS} -o tiff2bw
|
||||
|
||||
# convert B&W image to bilevel w/ FS dithering
|
||||
tiffdither %c4 tiffdither.c.o {LIBTIFF}
|
||||
Link {LOptions} tiffdither.c.o {LIBS} -o tiffdither
|
||||
|
||||
# GIF converter
|
||||
gif2tiff %c4 gif2tiff.c.o {LIBTIFF}
|
||||
Link {LOptions} gif2tiff.c.o {LIBS} -o gif2tiff
|
||||
|
||||
# convert Palette image to RGB
|
||||
pal2rgb %c4 pal2rgb.c.o {LIBTIFF}
|
||||
Link {LOptions} pal2rgb.c.o {LIBS} -o pal2rgb
|
||||
|
||||
# Sun rasterfile converter
|
||||
ras2tiff %c4 ras2tiff.c.o {LIBTIFF}
|
||||
Link {LOptions} ras2tiff.c.o {LIBS} -o ras2tiff
|
||||
|
||||
# generate thumbnail images from fax
|
||||
thumbnail %c4 thumbnail.c.o {LIBTIFF}
|
||||
Link {LOptions} thumbnail.c.o {LIBS} -o thumbnail
|
||||
|
||||
clean %c4
|
||||
{RM} {ALL} %c5.c.o ycbcr
|
||||
Executable
+133
@@ -0,0 +1,133 @@
|
||||
#
|
||||
# Tag Image File Format Library
|
||||
#
|
||||
# Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler
|
||||
# Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc.
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and
|
||||
# its documentation for any purpose is hereby granted without fee, provided
|
||||
# that (i) the above copyright notices and this permission notice appear in
|
||||
# all copies of the software and related documentation, and (ii) the names of
|
||||
# Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
# publicity relating to the software without the specific, prior written
|
||||
# permission of Stanford and Silicon Graphics.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
# OF THIS SOFTWARE.
|
||||
#
|
||||
|
||||
#
|
||||
# Makefile for Mac using MPW 3.2.3 and MPW C 3.2.4
|
||||
#
|
||||
#
|
||||
# Written by: Niles D. Ritter
|
||||
#
|
||||
|
||||
RM= delete -y -i
|
||||
PORT=:port:
|
||||
LIBTIFF=:libtiff:
|
||||
TOOLS=:tools:
|
||||
CONTRIB=:contrib:mac-mpw:
|
||||
|
||||
MACTRANS="{CONTRIB}mactrans"
|
||||
|
||||
NULL=
|
||||
|
||||
MAKEFILES = %b6
|
||||
{PORT}Makefile %b6
|
||||
{LIBTIFF}Makefile %b6
|
||||
{TOOLS}Makefile %b6
|
||||
{NULL}
|
||||
|
||||
all %c4 PORT LIBTIFF TOOLS
|
||||
|
||||
MAKEFILES %c4 {MAKEFILES}
|
||||
TOOLS %c4 LIBTIFF
|
||||
|
||||
LIBTIFF %c4 PORT
|
||||
|
||||
# Create the port routines
|
||||
PORT %c4 {PORT}Makefile
|
||||
directory {PORT}
|
||||
(make || set status 0) > build.mpw
|
||||
set echo 1
|
||||
execute build.mpw
|
||||
set echo 0
|
||||
{RM} build.mpw || set status 0
|
||||
directory ::
|
||||
|
||||
# Create the port routines
|
||||
LIBTIFF %c4 {LIBTIFF}Makefile
|
||||
directory {LIBTIFF}
|
||||
(make || set status 0) > build.mpw
|
||||
set echo 1
|
||||
execute build.mpw
|
||||
set echo 0
|
||||
{RM} build.mpw || set status 0
|
||||
directory ::
|
||||
|
||||
# Create the tools
|
||||
TOOLS %c4 {TOOLS}Makefile
|
||||
directory {TOOLS}
|
||||
(make || set status 0) > build.mpw
|
||||
set echo 1
|
||||
execute build.mpw
|
||||
set echo 0
|
||||
{RM} build.mpw || set status 0
|
||||
directory ::
|
||||
|
||||
# Makefile dependencies
|
||||
{PORT}Makefile %c4 {CONTRIB}port.make
|
||||
catenate {CONTRIB}port.make | {MACTRANS} > {PORT}Makefile
|
||||
|
||||
{LIBTIFF}Makefile %c4 {CONTRIB}libtiff.make
|
||||
catenate {CONTRIB}libtiff.make | {MACTRANS} > {LIBTIFF}Makefile
|
||||
|
||||
{TOOLS}Makefile %c4 {CONTRIB}tools.make
|
||||
catenate {CONTRIB}tools.make | {MACTRANS} > {TOOLS}Makefile
|
||||
|
||||
|
||||
clean %c4 clean.port clean.contrib clean.libtiff clean.tools clean.make
|
||||
|
||||
clean.port %c4
|
||||
directory {PORT}
|
||||
(make clean || set status 0) > purge
|
||||
purge
|
||||
{RM} purge || set status 0
|
||||
{RM} Makefile || set status 0
|
||||
{RM} build.mpw || set status 0
|
||||
cd ::
|
||||
|
||||
clean.contrib %c4
|
||||
{RM} {MACTRANS} || set status 0
|
||||
|
||||
clean.libtiff %c4
|
||||
directory {LIBTIFF}
|
||||
(make clean || set status 0) > purge
|
||||
purge
|
||||
{RM} purge || set status 0
|
||||
{RM} Makefile || set status 0
|
||||
{RM} build.mpw || set status 0
|
||||
cd ::
|
||||
|
||||
clean.tools %c4
|
||||
directory {TOOLS}
|
||||
(make clean || set status 0) > purge
|
||||
purge
|
||||
{RM} purge || set status 0
|
||||
{RM} Makefile || set status 0
|
||||
{RM} build.mpw || set status 0
|
||||
cd ::
|
||||
|
||||
clean.make %c4
|
||||
{RM} {MAKEFILES} || set status 0
|
||||
{RM} build.mpw || set status 0
|
||||
|
||||
Executable
+579
@@ -0,0 +1,579 @@
|
||||
/*
|
||||
--------------------------------------------------------------------------------
|
||||
- Module : mem_file.c
|
||||
- Description : A general purpose library for manipulating a memory area
|
||||
- as if it were a file.
|
||||
- mfs_ stands for memory file system.
|
||||
- Author : Mike Johnson - Banctec AB 03/07/96
|
||||
-
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
Copyright (c) 1996 Mike Johnson
|
||||
Copyright (c) 1996 BancTec AB
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this software
|
||||
for any purpose is hereby granted without fee, provided
|
||||
that (i) the above copyright notices and this permission notice appear in
|
||||
all copies of the software and related documentation, and (ii) the names of
|
||||
Mike Johnson and BancTec may not be used in any advertising or
|
||||
publicity relating to the software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
IN NO EVENT SHALL MIKE JOHNSON OR BANCTEC BE LIABLE FOR
|
||||
ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
OF THIS SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
--------------------------------------------------------------------------------
|
||||
- Includes
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
--------------------------------------------------------------------------------
|
||||
- Definitions
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define MAX_BUFFS 20
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
/*
|
||||
--------------------------------------------------------------------------------
|
||||
- Globals
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static char *buf[MAX_BUFFS]; /* Memory for each open buf */
|
||||
static long buf_off[MAX_BUFFS]; /* File pointer for each buf */
|
||||
static long buf_size[MAX_BUFFS]; /* Count of bytes allocated for each buf */
|
||||
static long fds[MAX_BUFFS]; /* File descriptor status */
|
||||
static int buf_mode[MAX_BUFFS]; /* Mode of buffer (r, w, a) */
|
||||
|
||||
static int library_init_done = FALSE;
|
||||
|
||||
|
||||
/*
|
||||
--------------------------------------------------------------------------------
|
||||
- Function prototypes
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int mfs_open (void *ptr, int size, char *mode);
|
||||
int mfs_lseek (int fd, int offset, int whence);
|
||||
int mfs_read (int fd, void *buf, int size);
|
||||
int mfs_write (int fd, void *buf, int size);
|
||||
int mfs_size (int fd);
|
||||
int mfs_map (int fd, char **addr, size_t *len);
|
||||
int mfs_unmap (int fd);
|
||||
int mfs_close (int fd);
|
||||
static int extend_mem_file (int fd, int size);
|
||||
static void mem_init ();
|
||||
|
||||
/*
|
||||
--------------------------------------------------------------------------------
|
||||
- Function code
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
--------------------------------------------------------------------------------
|
||||
- Function : mfs_open ()
|
||||
-
|
||||
- Arguments : Pointer to allocated buffer, initial size of buffer,
|
||||
- mode spec (r, w, a)
|
||||
-
|
||||
- Returns : File descriptor or -1 if error.
|
||||
-
|
||||
- Description : Register this area of memory (which has been allocated
|
||||
- and has a file read into it) under the mem_file library.
|
||||
- A file descriptor is returned which can the be passed
|
||||
- back to TIFFClientOpen and used as if it was a disk
|
||||
- based fd.
|
||||
- If the call is for mode 'w' then pass (void *)NULL as
|
||||
- the buffer and zero size and the library will
|
||||
- allocate memory for you.
|
||||
- If the mode is append then pass (void *)NULL and size
|
||||
- zero or with a valid address.
|
||||
-
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int mfs_open (void *buffer, int size, char *mode)
|
||||
{
|
||||
int ret, i;
|
||||
void *tmp;
|
||||
|
||||
if (library_init_done == FALSE)
|
||||
{
|
||||
mem_init ();
|
||||
library_init_done = TRUE;
|
||||
}
|
||||
|
||||
ret = -1;
|
||||
|
||||
/* Find a free fd */
|
||||
|
||||
for (i = 0; i < MAX_BUFFS; i++)
|
||||
{
|
||||
if (fds[i] == -1)
|
||||
{
|
||||
ret = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == MAX_BUFFS) /* No more free descriptors */
|
||||
{
|
||||
ret = -1;
|
||||
errno = EMFILE;
|
||||
}
|
||||
|
||||
if (ret >= 0 && *mode == 'r')
|
||||
{
|
||||
if (buffer == (void *)NULL)
|
||||
{
|
||||
ret = -1;
|
||||
errno = EINVAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf[ret] = (char *)buffer;
|
||||
buf_size[ret] = size;
|
||||
buf_off[ret] = 0;
|
||||
}
|
||||
}
|
||||
else if (ret >= 0 && *mode == 'w')
|
||||
{
|
||||
|
||||
if (buffer != (void *)NULL)
|
||||
{
|
||||
ret = -1;
|
||||
errno = EINVAL;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
tmp = malloc (0); /* Get a pointer */
|
||||
if (tmp == (void *)NULL)
|
||||
{
|
||||
ret = -1;
|
||||
errno = EDQUOT;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf[ret] = (char *)tmp;
|
||||
buf_size[ret] = 0;
|
||||
buf_off[ret] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ret >= 0 && *mode == 'a')
|
||||
{
|
||||
if (buffer == (void *) NULL) /* Create space for client */
|
||||
{
|
||||
tmp = malloc (0); /* Get a pointer */
|
||||
if (tmp == (void *)NULL)
|
||||
{
|
||||
ret = -1;
|
||||
errno = EDQUOT;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf[ret] = (char *)tmp;
|
||||
buf_size[ret] = 0;
|
||||
buf_off[ret] = 0;
|
||||
}
|
||||
}
|
||||
else /* Client has file read in already */
|
||||
{
|
||||
buf[ret] = (char *)buffer;
|
||||
buf_size[ret] = size;
|
||||
buf_off[ret] = 0;
|
||||
}
|
||||
}
|
||||
else /* Some other invalid combination of parameters */
|
||||
{
|
||||
ret = -1;
|
||||
errno = EINVAL;
|
||||
}
|
||||
|
||||
if (ret != -1)
|
||||
{
|
||||
fds[ret] = 0;
|
||||
buf_mode[ret] = *mode;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
--------------------------------------------------------------------------------
|
||||
- Function : mfs_lseek ()
|
||||
-
|
||||
- Arguments : File descriptor, offset, whence
|
||||
-
|
||||
- Returns : as per man lseek (2)
|
||||
-
|
||||
- Description : Does the same as lseek (2) except on a memory based file.
|
||||
- Note: the memory area will be extended if the caller
|
||||
- attempts to seek past the current end of file (memory).
|
||||
-
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int mfs_lseek (int fd, int offset, int whence)
|
||||
{
|
||||
int ret;
|
||||
long test_off;
|
||||
|
||||
if (fds[fd] == -1) /* Not open */
|
||||
{
|
||||
ret = -1;
|
||||
errno = EBADF;
|
||||
}
|
||||
else if (offset < 0 && whence == SEEK_SET)
|
||||
{
|
||||
ret = -1;
|
||||
errno = EINVAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (whence)
|
||||
{
|
||||
case SEEK_SET:
|
||||
if (offset > buf_size[fd])
|
||||
extend_mem_file (fd, offset);
|
||||
buf_off[fd] = offset;
|
||||
ret = offset;
|
||||
break;
|
||||
|
||||
case SEEK_CUR:
|
||||
test_off = buf_off[fd] + offset;
|
||||
|
||||
if (test_off < 0)
|
||||
{
|
||||
ret = -1;
|
||||
errno = EINVAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (test_off > buf_size[fd])
|
||||
extend_mem_file (fd, test_off);
|
||||
buf_off[fd] = test_off;
|
||||
ret = test_off;
|
||||
}
|
||||
break;
|
||||
|
||||
case SEEK_END:
|
||||
test_off = buf_size[fd] + offset;
|
||||
|
||||
if (test_off < 0)
|
||||
{
|
||||
ret = -1;
|
||||
errno = EINVAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (test_off > buf_size[fd])
|
||||
extend_mem_file (fd, test_off);
|
||||
buf_off[fd] = test_off;
|
||||
ret = test_off;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
errno = EINVAL;
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
--------------------------------------------------------------------------------
|
||||
- Function : mfs_read ()
|
||||
-
|
||||
- Arguments : File descriptor, buffer, size
|
||||
-
|
||||
- Returns : as per man read (2)
|
||||
-
|
||||
- Description : Does the same as read (2) except on a memory based file.
|
||||
- Note: An attempt to read past the end of memory currently
|
||||
- allocated to the file will return 0 (End Of File)
|
||||
-
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int mfs_read (int fd, void *clnt_buf, int size)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (fds[fd] == -1 || buf_mode[fd] != 'r')
|
||||
{
|
||||
/* File is either not open, or not opened for read */
|
||||
|
||||
ret = -1;
|
||||
errno = EBADF;
|
||||
}
|
||||
else if (buf_off[fd] + size > buf_size[fd])
|
||||
{
|
||||
ret = 0; /* EOF */
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy (clnt_buf, (void *) (buf[fd] + buf_off[fd]), size);
|
||||
buf_off[fd] = buf_off[fd] + size;
|
||||
ret = size;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
--------------------------------------------------------------------------------
|
||||
- Function : mfs_write ()
|
||||
-
|
||||
- Arguments : File descriptor, buffer, size
|
||||
-
|
||||
- Returns : as per man write (2)
|
||||
-
|
||||
- Description : Does the same as write (2) except on a memory based file.
|
||||
- Note: the memory area will be extended if the caller
|
||||
- attempts to write past the current end of file (memory).
|
||||
-
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int mfs_write (int fd, void *clnt_buf, int size)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (fds[fd] == -1 || buf_mode[fd] == 'r')
|
||||
{
|
||||
/* Either the file is not open or it is opened for reading only */
|
||||
|
||||
ret = -1;
|
||||
errno = EBADF;
|
||||
}
|
||||
else if (buf_mode[fd] == 'w')
|
||||
{
|
||||
/* Write */
|
||||
|
||||
if (buf_off[fd] + size > buf_size[fd])
|
||||
{
|
||||
extend_mem_file (fd, buf_off[fd] + size);
|
||||
buf_size[fd] = (buf_off[fd] + size);
|
||||
}
|
||||
|
||||
memcpy ((buf[fd] + buf_off[fd]), clnt_buf, size);
|
||||
buf_off[fd] = buf_off[fd] + size;
|
||||
|
||||
ret = size;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Append */
|
||||
|
||||
if (buf_off[fd] != buf_size[fd])
|
||||
buf_off[fd] = buf_size[fd];
|
||||
|
||||
extend_mem_file (fd, buf_off[fd] + size);
|
||||
buf_size[fd] += size;
|
||||
|
||||
memcpy ((buf[fd] + buf_off[fd]), clnt_buf, size);
|
||||
buf_off[fd] = buf_off[fd] + size;
|
||||
|
||||
ret = size;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
--------------------------------------------------------------------------------
|
||||
- Function : mfs_size ()
|
||||
-
|
||||
- Arguments : File descriptor
|
||||
-
|
||||
- Returns : integer file size
|
||||
-
|
||||
- Description : This function returns the current size of the file in bytes.
|
||||
-
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int mfs_size (int fd)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (fds[fd] == -1) /* Not open */
|
||||
{
|
||||
ret = -1;
|
||||
errno = EBADF;
|
||||
}
|
||||
else
|
||||
ret = buf_size[fd];
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
--------------------------------------------------------------------------------
|
||||
- Function : mfs_map ()
|
||||
-
|
||||
- Arguments : File descriptor, ptr to address, ptr to length
|
||||
-
|
||||
- Returns : Map status (succeeded or otherwise)
|
||||
-
|
||||
- Description : This function tells the client where the file is mapped
|
||||
- in memory and what size the mapped area is. It is provided
|
||||
- to satisfy the MapProc function in libtiff. It pretends
|
||||
- that the file has been mmap (2)ped.
|
||||
-
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int mfs_map (int fd, char **addr, size_t *len)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (fds[fd] == -1) /* Not open */
|
||||
{
|
||||
ret = -1;
|
||||
errno = EBADF;
|
||||
}
|
||||
else
|
||||
{
|
||||
*addr = buf[fd];
|
||||
*len = buf_size[fd];
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
--------------------------------------------------------------------------------
|
||||
- Function : mfs_unmap ()
|
||||
-
|
||||
- Arguments : File descriptor
|
||||
-
|
||||
- Returns : UnMap status (succeeded or otherwise)
|
||||
-
|
||||
- Description : This function does nothing as the file is always
|
||||
- in memory.
|
||||
-
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int mfs_unmap (int fd)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
--------------------------------------------------------------------------------
|
||||
- Function : mfs_close ()
|
||||
-
|
||||
- Arguments : File descriptor
|
||||
-
|
||||
- Returns : close status (succeeded or otherwise)
|
||||
-
|
||||
- Description : Close the open memory file. (Make fd available again.)
|
||||
-
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int mfs_close (int fd)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (fds[fd] == -1) /* Not open */
|
||||
{
|
||||
ret = -1;
|
||||
errno = EBADF;
|
||||
}
|
||||
else
|
||||
{
|
||||
fds[fd] = -1;
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
--------------------------------------------------------------------------------
|
||||
- Function : extend_mem_file ()
|
||||
-
|
||||
- Arguments : File descriptor, length to extend to.
|
||||
-
|
||||
- Returns : 0 - All OK, -1 - realloc () failed.
|
||||
-
|
||||
- Description : Increase the amount of memory allocated to a file.
|
||||
-
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int extend_mem_file (int fd, int size)
|
||||
{
|
||||
void *new_mem;
|
||||
int ret;
|
||||
|
||||
if ((new_mem = realloc (buf[fd], size)) == (void *) NULL)
|
||||
ret = -1;
|
||||
else
|
||||
{
|
||||
buf[fd] = (char *) new_mem;
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
--------------------------------------------------------------------------------
|
||||
- Function : mem_init ()
|
||||
-
|
||||
- Arguments : None
|
||||
-
|
||||
- Returns : void
|
||||
-
|
||||
- Description : Initialise the library.
|
||||
-
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static void mem_init ()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_BUFFS; i++)
|
||||
{
|
||||
fds[i] = -1;
|
||||
buf[i] = (char *)NULL;
|
||||
buf_size[i] = 0;
|
||||
buf_off[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Executable
+37
@@ -0,0 +1,37 @@
|
||||
Date: Mon, 23 Jun 1997 13:30:48 +0200
|
||||
To: <sam@cthulhu.engr.sgi.com>
|
||||
|
||||
From: "Mike Johnson" <mikehunt@swipnet.se>
|
||||
Subject: libtiff - Thanks
|
||||
|
||||
Return-Path: mikehunt@swipnet.se
|
||||
Delivery-Date: Mon, 23 Jun 1997 06:53:39 -0700
|
||||
|
||||
Hi Sam,
|
||||
|
||||
I noticed in the README from libtiff that you would like to know about
|
||||
what people have done with libtiff, so I thought I would drop you a
|
||||
line.
|
||||
|
||||
We have used libtiff to create and convert TIFF images of financial
|
||||
documents which are sent from and to major document processing systems
|
||||
in Sweden and Denmark.
|
||||
|
||||
I would like to express my deep gratitude to yourself and Sillicon
|
||||
Graphics for making this excellent library available for public use.
|
||||
There is obviously a lot of work that has gone in to libtiff and the
|
||||
quality of the code and documentation is an example to others.
|
||||
|
||||
One thing that libtiff did not do was work on a memory area rather than
|
||||
files. In my applications I had already read a TIFF or other format
|
||||
file in to memory and did not want to waste I/O writing it out again
|
||||
for libtiff's benefit. I therefore constructed a set of functions to
|
||||
pass up to TIFFClientOpen to simulate a file in memory. I have attached
|
||||
my mfs (memory file system) source code for you to use or junk, as you
|
||||
see fit. :-)
|
||||
|
||||
Once again, thanks very much for making my life simpler.
|
||||
|
||||
Best Regards,
|
||||
|
||||
Mike Johnson.
|
||||
Executable
+90
@@ -0,0 +1,90 @@
|
||||
Date: Fri, 01 Aug 1997 20:14:52 MDT
|
||||
To: Sam Leffler <sam@cthulhu.engr.sgi.com>
|
||||
|
||||
From: "Conrad J. Poelman (WSAT)" <poelmanc@plk.af.mil>
|
||||
Subject: Potential TIFF library additions
|
||||
|
||||
Delivery-Date: Fri, 01 Aug 1997 19:21:06 -0700
|
||||
|
||||
Sam,
|
||||
|
||||
You probably don't remember me, but I sent in a couple of bug fixes
|
||||
regarding the TIFF library about a 16 months ago or so...
|
||||
|
||||
I just wanted to send you two other additions that I have made to our
|
||||
local version of the TIFF library in hopes that you will want to
|
||||
incorporate them into your next major release of the TIFF library.
|
||||
(These additions are based on TIFF version 3.4beta31, but they sit on
|
||||
top of the library so they shouldn't be much trouble to incorporate them
|
||||
into any more recent version.) They are internally documented to a
|
||||
reasonable extent and we've been successfully using them in our code
|
||||
here for over a year. If you think they would make good additions to the
|
||||
TIFF library, I'd be happy to clean them up more, document them more,
|
||||
and/or integrate them with the latest version of the TIFF library, but I
|
||||
figured I'd see if you were interested in using them before I went to
|
||||
all that trouble.
|
||||
|
||||
TIFF Image Iterator
|
||||
-------------------
|
||||
Your ReadRGBA() routine works well for reading many different formats
|
||||
(TILED, STIP, compressed or not, etc.) of the most basic types of data
|
||||
(RGB, 8-bit greyscale, 8-bit colormapped) into an SGI-style data array,
|
||||
and serves as a good template for users with other needs. I used it as
|
||||
an exmaple of how to make an iterator which, rather than fill a data
|
||||
array, calls an arbitrary user-supplied callback function for each
|
||||
"chunk" of data - that "chunk" might be a strip or a tile, and might
|
||||
have one sample-per-pixel or two, and might be 8-bit data or 16-bit or
|
||||
24-bit. The callback function can do whatever it wants with the data -
|
||||
store it in a big array, convert it to RGBA, or draw it directly to the
|
||||
screen. I was able to use this iterator to read 16-bit greyscale and 32-
|
||||
and 64-bit floating point data, which wasn't possible with ReadRGBA().
|
||||
|
||||
I have tested this routine with 8- and 16-bit greyscale data as well as
|
||||
with 32- and 64-bit floating point data. I believe nearly all of our
|
||||
data is organized in strips, so actually I'd appreciate it if you had
|
||||
some tiled images that I could test it with.
|
||||
|
||||
It should certainly be possible and would be cleanest to reimplement
|
||||
ReadRGBA() in terms of the image iterator, but I haven't done that.
|
||||
|
||||
|
||||
Private Sub-Directory Read/Write
|
||||
--------------------------------
|
||||
TIFF-PL is a Phillips Laboratory extension to the TIFF tags that allows
|
||||
us to store satellite imaging-specific information in a TIFF format,
|
||||
such as the satellite's trajectory, the imaging time, etc. In order to
|
||||
give us the flexibility to modify the tag definitions without getting
|
||||
approval from the TIFF committee every time, we were given only three
|
||||
TIFF tags - a PL signature, a PL version number, and PL directory
|
||||
offset, which lists the position in the file at which to find a private
|
||||
sub-directory of tags-value pairs. So I wrote two routines:
|
||||
TIFFWritePrivateDataSubDirectory(), which takes a list of tags and a
|
||||
"get" function and writes the tag values into the TIFF file, returning
|
||||
the offset within the file at which it wrote the directory; and
|
||||
TIFFReadPrivateDataSubDirectory(), which takes an offset, a list of
|
||||
tags, and a "set" function and reads all the data from the private
|
||||
directory. The functions themselves are pretty simple. (The files are
|
||||
huge because I had to basically copy all of the tif_dirread.c and
|
||||
tif_dirwrite.c files in order to access the various fetching routines
|
||||
which were all declared static and therefore inaccessible in the TIFF
|
||||
library.)
|
||||
|
||||
|
||||
I'm including the four source files (tif_imgiter.h, tif_imgiter.c,
|
||||
tif_pdsdirread.c, tif_pdsdirwrite.c) in case you want to take a look at
|
||||
them. I can also send you some sample code that uses them if you like.
|
||||
If you're interested in having them incorporated into the standard TIFF
|
||||
library, I'd be happy to do that integration and clean up and document
|
||||
the routines. (For example, I've already realized that instead of
|
||||
limiting the SEP callback function to three bands (R,G,B) it should take
|
||||
an array to enable the handling of n-banded multi-spectral data...) If
|
||||
not, I'll just leave them as they are, since they work fine for us now.
|
||||
|
||||
Holler if you have any questions.
|
||||
|
||||
-- Conrad
|
||||
__________________________________________________________________
|
||||
Capt Conrad J. Poelman PL/WSAT (Phillips Laboratory)
|
||||
505-846-4347 3550 Aberdeen Ave SE
|
||||
(FAX) 505-846-4374 Kirtland AFB, NM 87117-5776
|
||||
|
||||
Executable
+518
@@ -0,0 +1,518 @@
|
||||
/* $Header: /home/cvsroot/libtiff/contrib/pds/tif_imageiter.c,v 1.1.1.1 2000/06/24 19:10:17 tshead Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1991-1996 Sam Leffler
|
||||
* Copyright (c) 1991-1996 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* TIFF Library
|
||||
*
|
||||
* Written by Conrad J. Poelman, PL/WSAT, Kirtland AFB, NM on 26 Mar 96.
|
||||
*
|
||||
* This file contains code to allow a calling program to "iterate" over each
|
||||
* pixels in an image as it is read from the file. The iterator takes care of
|
||||
* reading strips versus (possibly clipped) tiles, decoding the information
|
||||
* according to the decoding method, and so on, so that calling program can
|
||||
* ignore those details. The calling program does, however, need to be
|
||||
* conscious of the type of the pixel data that it is receiving.
|
||||
*
|
||||
* For reasons of efficiency, the callback function actually gets called for
|
||||
* "blocks" of pixels rather than for individual pixels. The format of the
|
||||
* callback arguments is given below.
|
||||
*
|
||||
* This code was taken from TIFFReadRGBAImage() in tif_getimage.c of the original
|
||||
* TIFF distribution, and simplified and generalized to provide this general
|
||||
* iteration capability. Those routines could certainly be re-implemented in terms
|
||||
* of a TIFFImageIter if desired.
|
||||
*
|
||||
*/
|
||||
#include "tiffiop.h"
|
||||
#include "tif_imgiter.h"
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static int gtTileContig(TIFFImageIter*, void *udata, uint32, uint32);
|
||||
static int gtTileSeparate(TIFFImageIter*, void *udata, uint32, uint32);
|
||||
static int gtStripContig(TIFFImageIter*, void *udata, uint32, uint32);
|
||||
static int gtStripSeparate(TIFFImageIter*, void *udata, uint32, uint32);
|
||||
|
||||
static const char photoTag[] = "PhotometricInterpretation";
|
||||
|
||||
static int
|
||||
isCCITTCompression(TIFF* tif)
|
||||
{
|
||||
uint16 compress;
|
||||
TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress);
|
||||
return (compress == COMPRESSION_CCITTFAX3 ||
|
||||
compress == COMPRESSION_CCITTFAX4 ||
|
||||
compress == COMPRESSION_CCITTRLE ||
|
||||
compress == COMPRESSION_CCITTRLEW);
|
||||
}
|
||||
|
||||
int
|
||||
TIFFImageIterBegin(TIFFImageIter* img, TIFF* tif, int stop, char emsg[1024])
|
||||
{
|
||||
uint16* sampleinfo;
|
||||
uint16 extrasamples;
|
||||
uint16 planarconfig;
|
||||
int colorchannels;
|
||||
|
||||
img->tif = tif;
|
||||
img->stoponerr = stop;
|
||||
TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &img->bitspersample);
|
||||
img->alpha = 0;
|
||||
TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &img->samplesperpixel);
|
||||
TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES,
|
||||
&extrasamples, &sampleinfo);
|
||||
if (extrasamples == 1)
|
||||
switch (sampleinfo[0]) {
|
||||
case EXTRASAMPLE_ASSOCALPHA: /* data is pre-multiplied */
|
||||
case EXTRASAMPLE_UNASSALPHA: /* data is not pre-multiplied */
|
||||
img->alpha = sampleinfo[0];
|
||||
break;
|
||||
}
|
||||
colorchannels = img->samplesperpixel - extrasamples;
|
||||
TIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG, &planarconfig);
|
||||
if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric)) {
|
||||
switch (colorchannels) {
|
||||
case 1:
|
||||
if (isCCITTCompression(tif))
|
||||
img->photometric = PHOTOMETRIC_MINISWHITE;
|
||||
else
|
||||
img->photometric = PHOTOMETRIC_MINISBLACK;
|
||||
break;
|
||||
case 3:
|
||||
img->photometric = PHOTOMETRIC_RGB;
|
||||
break;
|
||||
default:
|
||||
sprintf(emsg, "Missing needed %s tag", photoTag);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
switch (img->photometric) {
|
||||
case PHOTOMETRIC_PALETTE:
|
||||
if (!TIFFGetField(tif, TIFFTAG_COLORMAP,
|
||||
&img->redcmap, &img->greencmap, &img->bluecmap)) {
|
||||
TIFFError(TIFFFileName(tif), "Missing required \"Colormap\" tag");
|
||||
return (0);
|
||||
}
|
||||
/* fall thru... */
|
||||
case PHOTOMETRIC_MINISWHITE:
|
||||
case PHOTOMETRIC_MINISBLACK:
|
||||
/* This should work now so skip the check - BSR
|
||||
if (planarconfig == PLANARCONFIG_CONTIG && img->samplesperpixel != 1) {
|
||||
sprintf(emsg,
|
||||
"Sorry, can not handle contiguous data with %s=%d, and %s=%d",
|
||||
photoTag, img->photometric,
|
||||
"Samples/pixel", img->samplesperpixel);
|
||||
return (0);
|
||||
}
|
||||
*/
|
||||
break;
|
||||
case PHOTOMETRIC_YCBCR:
|
||||
if (planarconfig != PLANARCONFIG_CONTIG) {
|
||||
sprintf(emsg, "Sorry, can not handle YCbCr images with %s=%d",
|
||||
"Planarconfiguration", planarconfig);
|
||||
return (0);
|
||||
}
|
||||
/* It would probably be nice to have a reality check here. */
|
||||
{ uint16 compress;
|
||||
TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress);
|
||||
if (compress == COMPRESSION_JPEG && planarconfig == PLANARCONFIG_CONTIG) {
|
||||
/* can rely on libjpeg to convert to RGB */
|
||||
/* XXX should restore current state on exit */
|
||||
TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB);
|
||||
img->photometric = PHOTOMETRIC_RGB;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PHOTOMETRIC_RGB:
|
||||
if (colorchannels < 3) {
|
||||
sprintf(emsg, "Sorry, can not handle RGB image with %s=%d",
|
||||
"Color channels", colorchannels);
|
||||
return (0);
|
||||
}
|
||||
break;
|
||||
case PHOTOMETRIC_SEPARATED: {
|
||||
uint16 inkset;
|
||||
TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset);
|
||||
if (inkset != INKSET_CMYK) {
|
||||
sprintf(emsg, "Sorry, can not handle separated image with %s=%d",
|
||||
"InkSet", inkset);
|
||||
return (0);
|
||||
}
|
||||
if (img->samplesperpixel != 4) {
|
||||
sprintf(emsg, "Sorry, can not handle separated image with %s=%d",
|
||||
"Samples/pixel", img->samplesperpixel);
|
||||
return (0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sprintf(emsg, "Sorry, can not handle image with %s=%d",
|
||||
photoTag, img->photometric);
|
||||
return (0);
|
||||
}
|
||||
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &img->width);
|
||||
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &img->height);
|
||||
|
||||
TIFFGetFieldDefaulted(tif, TIFFTAG_ORIENTATION, &img->orientation);
|
||||
switch (img->orientation) {
|
||||
case ORIENTATION_BOTRIGHT:
|
||||
case ORIENTATION_RIGHTBOT: /* XXX */
|
||||
case ORIENTATION_LEFTBOT: /* XXX */
|
||||
TIFFWarning(TIFFFileName(tif), "using bottom-left orientation");
|
||||
img->orientation = ORIENTATION_BOTLEFT;
|
||||
/* fall thru... */
|
||||
case ORIENTATION_BOTLEFT:
|
||||
break;
|
||||
case ORIENTATION_TOPRIGHT:
|
||||
case ORIENTATION_RIGHTTOP: /* XXX */
|
||||
case ORIENTATION_LEFTTOP: /* XXX */
|
||||
default:
|
||||
TIFFWarning(TIFFFileName(tif), "using top-left orientation");
|
||||
img->orientation = ORIENTATION_TOPLEFT;
|
||||
/* fall thru... */
|
||||
case ORIENTATION_TOPLEFT:
|
||||
break;
|
||||
}
|
||||
|
||||
img->isContig =
|
||||
!(planarconfig == PLANARCONFIG_SEPARATE && colorchannels > 1);
|
||||
if (img->isContig) {
|
||||
img->get = TIFFIsTiled(tif) ? gtTileContig : gtStripContig;
|
||||
} else {
|
||||
img->get = TIFFIsTiled(tif) ? gtTileSeparate : gtStripSeparate;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
int
|
||||
TIFFImageIterGet(TIFFImageIter* img, void *udata, uint32 w, uint32 h)
|
||||
{
|
||||
if (img->get == NULL) {
|
||||
TIFFError(TIFFFileName(img->tif), "No \"get\" routine setup");
|
||||
return (0);
|
||||
}
|
||||
if (img->callback.any == NULL) {
|
||||
TIFFError(TIFFFileName(img->tif),
|
||||
"No \"put\" routine setupl; probably can not handle image format");
|
||||
return (0);
|
||||
}
|
||||
return (*img->get)(img, udata, w, h);
|
||||
}
|
||||
|
||||
TIFFImageIterEnd(TIFFImageIter* img)
|
||||
{
|
||||
/* Nothing to free... ? */
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the specified image into an ABGR-format raster.
|
||||
*/
|
||||
int
|
||||
TIFFReadImageIter(TIFF* tif,
|
||||
uint32 rwidth, uint32 rheight, uint8* raster, int stop)
|
||||
{
|
||||
char emsg[1024];
|
||||
TIFFImageIter img;
|
||||
int ok;
|
||||
|
||||
if (TIFFImageIterBegin(&img, tif, stop, emsg)) {
|
||||
/* XXX verify rwidth and rheight against width and height */
|
||||
ok = TIFFImageIterGet(&img, raster, rwidth, img.height);
|
||||
TIFFImageIterEnd(&img);
|
||||
} else {
|
||||
TIFFError(TIFFFileName(tif), emsg);
|
||||
ok = 0;
|
||||
}
|
||||
return (ok);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get an tile-organized image that has
|
||||
* PlanarConfiguration contiguous if SamplesPerPixel > 1
|
||||
* or
|
||||
* SamplesPerPixel == 1
|
||||
*/
|
||||
static int
|
||||
gtTileContig(TIFFImageIter* img, void *udata, uint32 w, uint32 h)
|
||||
{
|
||||
TIFF* tif = img->tif;
|
||||
ImageIterTileContigRoutine callback = img->callback.contig;
|
||||
uint16 orientation;
|
||||
uint32 col, row;
|
||||
uint32 tw, th;
|
||||
u_char* buf;
|
||||
int32 fromskew;
|
||||
uint32 nrow;
|
||||
|
||||
buf = (u_char*) _TIFFmalloc(TIFFTileSize(tif));
|
||||
if (buf == 0) {
|
||||
TIFFError(TIFFFileName(tif), "No space for tile buffer");
|
||||
return (0);
|
||||
}
|
||||
TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw);
|
||||
TIFFGetField(tif, TIFFTAG_TILELENGTH, &th);
|
||||
orientation = img->orientation;
|
||||
for (row = 0; row < h; row += th) {
|
||||
nrow = (row + th > h ? h - row : th);
|
||||
for (col = 0; col < w; col += tw) {
|
||||
if (TIFFReadTile(tif, buf, col, row, 0, 0) < 0 && img->stoponerr)
|
||||
break;
|
||||
if (col + tw > w) {
|
||||
/*
|
||||
* Tile is clipped horizontally. Calculate
|
||||
* visible portion and skewing factors.
|
||||
*/
|
||||
uint32 npix = w - col;
|
||||
fromskew = tw - npix;
|
||||
(*callback)(img, udata, col, row, npix, nrow, fromskew, buf);
|
||||
} else {
|
||||
(*callback)(img, udata, col, row, tw, nrow, 0, buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
_TIFFfree(buf);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get an tile-organized image that has
|
||||
* SamplesPerPixel > 1
|
||||
* PlanarConfiguration separated
|
||||
* We assume that all such images are RGB.
|
||||
*/
|
||||
static int
|
||||
gtTileSeparate(TIFFImageIter* img, void *udata, uint32 w, uint32 h)
|
||||
{
|
||||
TIFF* tif = img->tif;
|
||||
ImageIterTileSeparateRoutine callback = img->callback.separate;
|
||||
uint16 orientation;
|
||||
uint32 col, row;
|
||||
uint32 tw, th;
|
||||
u_char* buf;
|
||||
u_char* r;
|
||||
u_char* g;
|
||||
u_char* b;
|
||||
u_char* a;
|
||||
tsize_t tilesize;
|
||||
int32 fromskew;
|
||||
int alpha = img->alpha;
|
||||
uint32 nrow;
|
||||
|
||||
tilesize = TIFFTileSize(tif);
|
||||
buf = (u_char*) _TIFFmalloc(4*tilesize);
|
||||
if (buf == 0) {
|
||||
TIFFError(TIFFFileName(tif), "No space for tile buffer");
|
||||
return (0);
|
||||
}
|
||||
r = buf;
|
||||
g = r + tilesize;
|
||||
b = g + tilesize;
|
||||
a = b + tilesize;
|
||||
if (!alpha)
|
||||
memset(a, 0xff, tilesize);
|
||||
TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw);
|
||||
TIFFGetField(tif, TIFFTAG_TILELENGTH, &th);
|
||||
orientation = img->orientation;
|
||||
for (row = 0; row < h; row += th) {
|
||||
nrow = (row + th > h ? h - row : th);
|
||||
for (col = 0; col < w; col += tw) {
|
||||
if (TIFFReadTile(tif, r, col, row,0,0) < 0 && img->stoponerr)
|
||||
break;
|
||||
if (TIFFReadTile(tif, g, col, row,0,1) < 0 && img->stoponerr)
|
||||
break;
|
||||
if (TIFFReadTile(tif, b, col, row,0,2) < 0 && img->stoponerr)
|
||||
break;
|
||||
if (alpha && TIFFReadTile(tif,a,col,row,0,3) < 0 && img->stoponerr)
|
||||
break;
|
||||
if (col + tw > w) {
|
||||
/*
|
||||
* Tile is clipped horizontally. Calculate
|
||||
* visible portion and skewing factors.
|
||||
*/
|
||||
uint32 npix = w - col;
|
||||
fromskew = tw - npix;
|
||||
(*callback)(img, udata, col, row, npix, nrow, fromskew, r, g, b, a);
|
||||
} else {
|
||||
(*callback)(img, udata, col, row, tw, nrow, 0, r, g, b, a);
|
||||
}
|
||||
}
|
||||
}
|
||||
_TIFFfree(buf);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a strip-organized image that has
|
||||
* PlanarConfiguration contiguous if SamplesPerPixel > 1
|
||||
* or
|
||||
* SamplesPerPixel == 1
|
||||
*/
|
||||
static int
|
||||
gtStripContig(TIFFImageIter* img, void *udata, uint32 w, uint32 h)
|
||||
{
|
||||
TIFF* tif = img->tif;
|
||||
ImageIterTileContigRoutine callback = img->callback.contig;
|
||||
uint16 orientation;
|
||||
uint32 row, nrow;
|
||||
u_char* buf;
|
||||
uint32 rowsperstrip;
|
||||
uint32 imagewidth = img->width;
|
||||
tsize_t scanline;
|
||||
int32 fromskew;
|
||||
|
||||
buf = (u_char*) _TIFFmalloc(TIFFStripSize(tif));
|
||||
if (buf == 0) {
|
||||
TIFFError(TIFFFileName(tif), "No space for strip buffer");
|
||||
return (0);
|
||||
}
|
||||
orientation = img->orientation;
|
||||
TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
|
||||
scanline = TIFFScanlineSize(tif);
|
||||
fromskew = (w < imagewidth ? imagewidth - w : 0);
|
||||
for (row = 0; row < h; row += rowsperstrip) {
|
||||
nrow = (row + rowsperstrip > h ? h - row : rowsperstrip);
|
||||
if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 0),
|
||||
buf, nrow*scanline) < 0 && img->stoponerr)
|
||||
break;
|
||||
(*callback)(img, udata, 0, row, w, nrow, fromskew, buf);
|
||||
}
|
||||
_TIFFfree(buf);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a strip-organized image with
|
||||
* SamplesPerPixel > 1
|
||||
* PlanarConfiguration separated
|
||||
* We assume that all such images are RGB.
|
||||
*/
|
||||
static int
|
||||
gtStripSeparate(TIFFImageIter* img, void *udata, uint32 w, uint32 h)
|
||||
{
|
||||
TIFF* tif = img->tif;
|
||||
ImageIterTileSeparateRoutine callback = img->callback.separate;
|
||||
uint16 orientation;
|
||||
u_char *buf;
|
||||
u_char *r, *g, *b, *a;
|
||||
uint32 row, nrow;
|
||||
tsize_t scanline;
|
||||
uint32 rowsperstrip;
|
||||
uint32 imagewidth = img->width;
|
||||
tsize_t stripsize;
|
||||
int32 fromskew;
|
||||
int alpha = img->alpha;
|
||||
|
||||
stripsize = TIFFStripSize(tif);
|
||||
r = buf = (u_char *)_TIFFmalloc(4*stripsize);
|
||||
if (buf == 0) {
|
||||
TIFFError(TIFFFileName(tif), "No space for tile buffer");
|
||||
return (0);
|
||||
}
|
||||
g = r + stripsize;
|
||||
b = g + stripsize;
|
||||
a = b + stripsize;
|
||||
if (!alpha)
|
||||
memset(a, 0xff, stripsize);
|
||||
orientation = img->orientation;
|
||||
TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
|
||||
scanline = TIFFScanlineSize(tif);
|
||||
fromskew = (w < imagewidth ? imagewidth - w : 0);
|
||||
for (row = 0; row < h; row += rowsperstrip) {
|
||||
nrow = (row + rowsperstrip > h ? h - row : rowsperstrip);
|
||||
if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 0),
|
||||
r, nrow*scanline) < 0 && img->stoponerr)
|
||||
break;
|
||||
if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 1),
|
||||
g, nrow*scanline) < 0 && img->stoponerr)
|
||||
break;
|
||||
if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 2),
|
||||
b, nrow*scanline) < 0 && img->stoponerr)
|
||||
break;
|
||||
if (alpha &&
|
||||
(TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 3),
|
||||
a, nrow*scanline) < 0 && img->stoponerr))
|
||||
break;
|
||||
(*callback)(img, udata, 0, row, w, nrow, fromskew, r, g, b, a);
|
||||
}
|
||||
_TIFFfree(buf);
|
||||
return (1);
|
||||
}
|
||||
|
||||
DECLAREContigCallbackFunc(TestContigCallback)
|
||||
{
|
||||
printf("Contig Callback called with x = %d, y = %d, w = %d, h = %d, fromskew = %d\n",
|
||||
x, y, w, h, fromskew);
|
||||
}
|
||||
|
||||
|
||||
DECLARESepCallbackFunc(TestSepCallback)
|
||||
{
|
||||
printf("Sep Callback called with x = %d, y = %d, w = %d, h = %d, fromskew = %d\n",
|
||||
x, y, w, h, fromskew);
|
||||
}
|
||||
|
||||
|
||||
#ifdef MAIN
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char emsg[1024];
|
||||
TIFFImageIter img;
|
||||
int ok;
|
||||
int stop = 1;
|
||||
|
||||
TIFF *tif;
|
||||
unsigned long nx, ny;
|
||||
unsigned short BitsPerSample, SamplesPerPixel;
|
||||
int isColorMapped, isPliFile;
|
||||
unsigned char *ColorMap;
|
||||
unsigned char *data;
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr,"usage: %s tiff_file\n",argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
tif = (TIFF *)PLIGetImage(argv[1], (void *) &data, &ColorMap,
|
||||
&nx, &ny, &BitsPerSample, &SamplesPerPixel,
|
||||
&isColorMapped, &isPliFile);
|
||||
if (tif != NULL) {
|
||||
|
||||
if (TIFFImageIterBegin(&img, tif, stop, emsg)) {
|
||||
/* Here need to set data and callback function! */
|
||||
if (img.isContig) {
|
||||
img.callback = TestContigCallback;
|
||||
} else {
|
||||
img.callback = TestSepCallback;
|
||||
}
|
||||
ok = TIFFImageIterGet(&img, NULL, img.width, img.height);
|
||||
TIFFImageIterEnd(&img);
|
||||
} else {
|
||||
TIFFError(TIFFFileName(tif), emsg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
typedef struct _TIFFImageIter TIFFImageIter;
|
||||
|
||||
/* The callback function is called for each "block" of image pixel data after
|
||||
it has been read from the file and decoded. This image pixel data is in the
|
||||
buffer pp, and this data represents the image pixels from (x,y) to
|
||||
(x+w,y+h). It is stored in pixel format, so each pixel contains
|
||||
img->samplesperpixel consecutive samples each containing img->bitspersample
|
||||
bits of data. The array pp is ordered in h consecutive rows of w+fromskew
|
||||
pixels each. */
|
||||
typedef void (*ImageIterTileContigRoutine)
|
||||
(TIFFImageIter*, void *, uint32, uint32, uint32, uint32, int32,
|
||||
unsigned char*);
|
||||
#define DECLAREContigCallbackFunc(name) \
|
||||
static void name(\
|
||||
TIFFImageIter* img, \
|
||||
void* user_data, \
|
||||
uint32 x, uint32 y, \
|
||||
uint32 w, uint32 h, \
|
||||
int32 fromskew, \
|
||||
u_char* pp \
|
||||
)
|
||||
|
||||
typedef void (*ImageIterTileSeparateRoutine)
|
||||
(TIFFImageIter*, void *, uint32, uint32, uint32, uint32, int32,
|
||||
unsigned char*, unsigned char*, unsigned char*, unsigned char*);
|
||||
#define DECLARESepCallbackFunc(name) \
|
||||
static void name(\
|
||||
TIFFImageIter* img, \
|
||||
void* user_data, \
|
||||
uint32 x, uint32 y, \
|
||||
uint32 w, uint32 h,\
|
||||
int32 fromskew, \
|
||||
u_char* r, u_char* g, u_char* b, u_char* a\
|
||||
)
|
||||
|
||||
struct _TIFFImageIter {
|
||||
TIFF* tif; /* image handle */
|
||||
int stoponerr; /* stop on read error */
|
||||
int isContig; /* data is packed/separate */
|
||||
int alpha; /* type of alpha data present */
|
||||
uint32 width; /* image width */
|
||||
uint32 height; /* image height */
|
||||
uint16 bitspersample; /* image bits/sample */
|
||||
uint16 samplesperpixel; /* image samples/pixel */
|
||||
uint16 orientation; /* image orientation */
|
||||
uint16 photometric; /* image photometric interp */
|
||||
uint16* redcmap; /* colormap pallete */
|
||||
uint16* greencmap;
|
||||
uint16* bluecmap;
|
||||
/* get image data routine */
|
||||
int (*get)(TIFFImageIter*, void *udata, uint32, uint32);
|
||||
union {
|
||||
void (*any)(TIFFImageIter*);
|
||||
ImageIterTileContigRoutine contig;
|
||||
ImageIterTileSeparateRoutine separate;
|
||||
} callback; /* fn to exec for each block */
|
||||
};
|
||||
Executable
+1124
File diff suppressed because it is too large
Load Diff
Executable
+964
@@ -0,0 +1,964 @@
|
||||
/* $Header: /home/cvsroot/libtiff/contrib/pds/tif_pdsdirwrite.c,v 1.1.1.1 2000/06/24 19:10:17 tshead Exp $ */
|
||||
|
||||
/* When writing data to TIFF files, it is often useful to store application-
|
||||
specific data in a private TIFF directory so that the tags don't need to
|
||||
be registered and won't conflict with other people's user-defined tags.
|
||||
One needs to have a registered public tag which contains some amount of
|
||||
raw data. That raw data, however, is interpreted at an independent,
|
||||
separate, private tiff directory. This file provides some routines which
|
||||
will be useful for converting that data from its raw binary form into
|
||||
the proper form for your application.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1996 Sam Leffler
|
||||
* Copyright (c) 1991-1996 Silicon Graphics, Inc.
|
||||
* Copyright (c( 1996 USAF Phillips Laboratory
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* TIFF Library.
|
||||
*
|
||||
* These routines written by Conrad J. Poelman on a single late-night of
|
||||
* March 20-21, 1996.
|
||||
*
|
||||
* The entire purpose of this file is to provide a single external function,
|
||||
* TIFFWritePrivateDataSubDirectory(). This function is intended for use
|
||||
* in writing a private subdirectory structure into a TIFF file. The
|
||||
* actual reading of data from the structure is handled by the getFieldFn(),
|
||||
* which is passed to TIFFWritePrivateDataSubDirectory() as a parameter. The
|
||||
* idea is to enable any application wishing to read private subdirectories to
|
||||
* do so easily using this function, without modifying the TIFF library.
|
||||
*
|
||||
* The astute observer will notice that only two functions are at all different
|
||||
* from the original tif_dirwrite.c file: TIFFWritePrivateDataSubDirectory()and
|
||||
* TIFFWriteNormalSubTag(). All the other stuff that makes this file so huge
|
||||
* is only necessary because all of those functions are declared static in
|
||||
* tif_dirwrite.c, so we have to totally duplicate them in order to use them.
|
||||
*
|
||||
* Oh, also please note the bug-fix in the routine TIFFWriteNormalSubTag(),
|
||||
* which equally should be applied to TIFFWriteNormalTag().
|
||||
*
|
||||
*/
|
||||
#include "tiffiop.h"
|
||||
|
||||
#if HAVE_IEEEFP
|
||||
#define TIFFCvtNativeToIEEEFloat(tif, n, fp)
|
||||
#define TIFFCvtNativeToIEEEDouble(tif, n, dp)
|
||||
#else
|
||||
extern void TIFFCvtNativeToIEEEFloat(TIFF*, uint32, float*);
|
||||
extern void TIFFCvtNativeToIEEEDouble(TIFF*, uint32, double*);
|
||||
#endif
|
||||
|
||||
static int TIFFWriteNormalTag(TIFF*, TIFFDirEntry*, const TIFFFieldInfo*);
|
||||
static int TIFFWriteNormalSubTag(TIFF*, TIFFDirEntry*, const TIFFFieldInfo*,
|
||||
int (*getFieldFn)(TIFF *tif,ttag_t tag,...));
|
||||
static void TIFFSetupShortLong(TIFF*, ttag_t, TIFFDirEntry*, uint32);
|
||||
static int TIFFSetupShortPair(TIFF*, ttag_t, TIFFDirEntry*);
|
||||
static int TIFFWritePerSampleShorts(TIFF*, ttag_t, TIFFDirEntry*);
|
||||
static int TIFFWritePerSampleAnys(TIFF*, TIFFDataType, ttag_t, TIFFDirEntry*);
|
||||
static int TIFFWriteShortTable(TIFF*, ttag_t, TIFFDirEntry*, uint32, uint16**);
|
||||
static int TIFFWriteShortArray(TIFF*,
|
||||
TIFFDataType, ttag_t, TIFFDirEntry*, uint32, uint16*);
|
||||
static int TIFFWriteLongArray(TIFF *,
|
||||
TIFFDataType, ttag_t, TIFFDirEntry*, uint32, uint32*);
|
||||
static int TIFFWriteRationalArray(TIFF *,
|
||||
TIFFDataType, ttag_t, TIFFDirEntry*, uint32, float*);
|
||||
static int TIFFWriteFloatArray(TIFF *,
|
||||
TIFFDataType, ttag_t, TIFFDirEntry*, uint32, float*);
|
||||
static int TIFFWriteDoubleArray(TIFF *,
|
||||
TIFFDataType, ttag_t, TIFFDirEntry*, uint32, double*);
|
||||
static int TIFFWriteByteArray(TIFF*, TIFFDirEntry*, char*);
|
||||
static int TIFFWriteAnyArray(TIFF*,
|
||||
TIFFDataType, ttag_t, TIFFDirEntry*, uint32, double*);
|
||||
#ifdef COLORIMETRY_SUPPORT
|
||||
static int TIFFWriteTransferFunction(TIFF*, TIFFDirEntry*);
|
||||
#endif
|
||||
static int TIFFWriteData(TIFF*, TIFFDirEntry*, char*);
|
||||
static int TIFFLinkDirectory(TIFF*);
|
||||
|
||||
#define WriteRationalPair(type, tag1, v1, tag2, v2) { \
|
||||
if (!TIFFWriteRational(tif, type, tag1, dir, v1)) \
|
||||
goto bad; \
|
||||
if (!TIFFWriteRational(tif, type, tag2, dir+1, v2)) \
|
||||
goto bad; \
|
||||
dir++; \
|
||||
}
|
||||
#define TIFFWriteRational(tif, type, tag, dir, v) \
|
||||
TIFFWriteRationalArray((tif), (type), (tag), (dir), 1, &(v))
|
||||
#ifndef TIFFWriteRational
|
||||
static int TIFFWriteRational(TIFF*,
|
||||
TIFFDataType, ttag_t, TIFFDirEntry*, float);
|
||||
#endif
|
||||
|
||||
/* This function will write an entire directory to the disk, and return the
|
||||
offset value indicating where in the file it wrote the beginning of the
|
||||
directory structure. This is NOT the same as the offset value before
|
||||
calling this function, because some of the fields may have caused various
|
||||
data items to be written out BEFORE writing the directory structure.
|
||||
|
||||
This code was basically written by ripping of the TIFFWriteDirectory()
|
||||
code and generalizing it, using RPS's TIFFWritePliIfd() code for
|
||||
inspiration. My original goal was to make this code general enough that
|
||||
the original TIFFWriteDirectory() could be rewritten to just call this
|
||||
function with the appropriate field and field-accessing arguments.
|
||||
|
||||
However, now I realize that there's a lot of code that gets executed for
|
||||
the main, standard TIFF directories that does not apply to special
|
||||
private subdirectories, so such a reimplementation for the sake of
|
||||
eliminating redundant or duplicate code is probably not possible,
|
||||
unless we also pass in a Main flag to indiciate which type of handling
|
||||
to do, which would be kind of a hack. I've marked those places where I
|
||||
changed or ripped out code which would have to be re-inserted to
|
||||
generalize this function. If it can be done in a clean and graceful way,
|
||||
it would be a great way to generalize the TIFF library. Otherwise, I'll
|
||||
just leave this code here where it duplicates but remains on top of and
|
||||
hopefully mostly independent of the main TIFF library.
|
||||
|
||||
The caller will probably want to free the sub directory structure after
|
||||
returning from this call, since otherwise once written out, the user
|
||||
is likely to forget about it and leave data lying around.
|
||||
*/
|
||||
toff_t
|
||||
TIFFWritePrivateDataSubDirectory(TIFF* tif,
|
||||
uint32 pdir_fieldsset[], int pdir_fields_last,
|
||||
TIFFFieldInfo *field_info,
|
||||
int (*getFieldFn)(TIFF *tif, ttag_t tag, ...))
|
||||
{
|
||||
uint16 dircount;
|
||||
uint32 diroff, nextdiroff;
|
||||
ttag_t tag;
|
||||
uint32 nfields;
|
||||
tsize_t dirsize;
|
||||
char* data;
|
||||
TIFFDirEntry* dir;
|
||||
u_long b, *fields, fields_size;
|
||||
toff_t directory_offset;
|
||||
TIFFFieldInfo* fip;
|
||||
|
||||
/*
|
||||
* Deleted out all of the encoder flushing and such code from here -
|
||||
* not necessary for subdirectories.
|
||||
*/
|
||||
|
||||
/* Finish writing out any image data. */
|
||||
TIFFFlushData(tif);
|
||||
|
||||
/*
|
||||
* Size the directory so that we can calculate
|
||||
* offsets for the data items that aren't kept
|
||||
* in-place in each field.
|
||||
*/
|
||||
nfields = 0;
|
||||
for (b = 0; b <= pdir_fields_last; b++)
|
||||
if (FieldSet(pdir_fieldsset, b))
|
||||
/* Deleted code to make size of first 4 tags 2
|
||||
instead of 1. */
|
||||
nfields += 1;
|
||||
dirsize = nfields * sizeof (TIFFDirEntry);
|
||||
data = (char*) _TIFFmalloc(dirsize);
|
||||
if (data == NULL) {
|
||||
TIFFError(tif->tif_name,
|
||||
"Cannot write private subdirectory, out of space");
|
||||
return (0);
|
||||
}
|
||||
/*
|
||||
* Place directory in data section of the file. If there isn't one
|
||||
* yet, place it at the end of the file. The directory is treated as
|
||||
* data, so we don't link it into the directory structure at all.
|
||||
*/
|
||||
if (tif->tif_dataoff == 0)
|
||||
tif->tif_dataoff =(TIFFSeekFile(tif, (toff_t) 0, SEEK_END)+1) &~ 1;
|
||||
diroff = tif->tif_dataoff;
|
||||
tif->tif_dataoff = (toff_t)(
|
||||
diroff + sizeof (uint16) + dirsize + sizeof (toff_t));
|
||||
if (tif->tif_dataoff & 1)
|
||||
tif->tif_dataoff++;
|
||||
(void) TIFFSeekFile(tif, tif->tif_dataoff, SEEK_SET);
|
||||
/*tif->tif_curdir++;*/
|
||||
dir = (TIFFDirEntry*) data;
|
||||
/*
|
||||
* Setup external form of directory
|
||||
* entries and write data items.
|
||||
*/
|
||||
/*
|
||||
* We make a local copy of the fieldsset here so that we don't mess
|
||||
* up the original one when we call ResetFieldBit(). But I'm not sure
|
||||
* why the original code calls ResetFieldBit(), since we're already
|
||||
* going through the fields in order...
|
||||
*
|
||||
* fields_size is the number of uint32's we will need to hold the
|
||||
* bit-mask for all of the fields. If our highest field number is
|
||||
* 100, then we'll need 100 / (8*4)+1 == 4 uint32's to hold the
|
||||
* fieldset.
|
||||
*
|
||||
* Unlike the original code, we allocate fields dynamically based
|
||||
* on the requested pdir_fields_last value, allowing private
|
||||
* data subdirectories to contain more than the built-in code's limit
|
||||
* of 95 tags in a directory.
|
||||
*/
|
||||
fields_size = pdir_fields_last / (8*sizeof(uint32)) + 1;
|
||||
fields = _TIFFmalloc(fields_size*sizeof(uint32));
|
||||
_TIFFmemcpy(fields, pdir_fieldsset, fields_size * sizeof(uint32));
|
||||
|
||||
/* Deleted "write out extra samples tag" code here. */
|
||||
|
||||
/* Deleted code for checking a billion little special cases for the
|
||||
* standard TIFF tags. Should add a general mechanism for overloading
|
||||
* write function for each field, just like Brian kept telling me!!!
|
||||
*/
|
||||
for (fip = field_info; fip->field_tag; fip++) {
|
||||
/* Deleted code to check for FIELD_IGNORE!! */
|
||||
if (/* fip->field_bit == FIELD_IGNORE || */
|
||||
!FieldSet(fields, fip->field_bit))
|
||||
continue;
|
||||
if (!TIFFWriteNormalSubTag(tif, dir, fip, getFieldFn))
|
||||
goto bad;
|
||||
dir++;
|
||||
ResetFieldBit(fields, fip->field_bit);
|
||||
}
|
||||
|
||||
/* Now we've written all of the referenced data, and are about to
|
||||
write the main directory structure, so grab the tif_dataoff value
|
||||
now so we can remember where we wrote the directory. */
|
||||
directory_offset = tif->tif_dataoff;
|
||||
|
||||
/*
|
||||
* Write directory.
|
||||
*/
|
||||
dircount = (uint16) nfields;
|
||||
/* Deleted code to link to the next directory - we set it to zero! */
|
||||
nextdiroff = 0;
|
||||
if (tif->tif_flags & TIFF_SWAB) {
|
||||
/*
|
||||
* The file's byte order is opposite to the
|
||||
* native machine architecture. We overwrite
|
||||
* the directory information with impunity
|
||||
* because it'll be released below after we
|
||||
* write it to the file. Note that all the
|
||||
* other tag construction routines assume that
|
||||
* we do this byte-swapping; i.e. they only
|
||||
* byte-swap indirect data.
|
||||
*/
|
||||
for (dir = (TIFFDirEntry*) data; dircount; dir++, dircount--) {
|
||||
TIFFSwabArrayOfShort(&dir->tdir_tag, 2);
|
||||
TIFFSwabArrayOfLong(&dir->tdir_count, 2);
|
||||
}
|
||||
dircount = (uint16) nfields;
|
||||
TIFFSwabShort(&dircount);
|
||||
TIFFSwabLong(&nextdiroff);
|
||||
}
|
||||
|
||||
(void) TIFFSeekFile(tif, tif->tif_dataoff, SEEK_SET);
|
||||
if (!WriteOK(tif, &dircount, sizeof (dircount))) {
|
||||
TIFFError(tif->tif_name, "Error writing private subdirectory count");
|
||||
goto bad;
|
||||
}
|
||||
if (!WriteOK(tif, data, dirsize)) {
|
||||
TIFFError(tif->tif_name, "Error writing private subdirectory contents");
|
||||
goto bad;
|
||||
}
|
||||
if (!WriteOK(tif, &nextdiroff, sizeof (nextdiroff))) {
|
||||
TIFFError(tif->tif_name, "Error writing private subdirectory link");
|
||||
goto bad;
|
||||
}
|
||||
tif->tif_dataoff += sizeof(dircount) + dirsize + sizeof(nextdiroff);
|
||||
|
||||
_TIFFfree(data);
|
||||
_TIFFfree(fields);
|
||||
tif->tif_flags &= ~TIFF_DIRTYDIRECT;
|
||||
|
||||
#if (0)
|
||||
/* This stuff commented out because I don't think we want it for
|
||||
subdirectories, but I could be wrong. */
|
||||
(*tif->tif_cleanup)(tif);
|
||||
|
||||
/*
|
||||
* Reset directory-related state for subsequent
|
||||
* directories.
|
||||
*/
|
||||
TIFFDefaultDirectory(tif);
|
||||
tif->tif_curoff = 0;
|
||||
tif->tif_row = (uint32) -1;
|
||||
tif->tif_curstrip = (tstrip_t) -1;
|
||||
#endif
|
||||
|
||||
return (directory_offset);
|
||||
bad:
|
||||
_TIFFfree(data);
|
||||
_TIFFfree(fields);
|
||||
return (0);
|
||||
}
|
||||
#undef WriteRationalPair
|
||||
|
||||
/*
|
||||
* Process tags that are not special cased.
|
||||
*/
|
||||
/* The standard function TIFFWriteNormalTag() could definitely be replaced
|
||||
with a simple call to this function, just adding TIFFGetField() as the
|
||||
last argument. */
|
||||
static int
|
||||
TIFFWriteNormalSubTag(TIFF* tif, TIFFDirEntry* dir, const TIFFFieldInfo* fip,
|
||||
int (*getFieldFn)(TIFF *tif, ttag_t tag, ...))
|
||||
{
|
||||
u_short wc = (u_short) fip->field_writecount;
|
||||
|
||||
dir->tdir_tag = fip->field_tag;
|
||||
dir->tdir_type = (u_short) fip->field_type;
|
||||
dir->tdir_count = wc;
|
||||
#define WRITEF(x,y) x(tif, fip->field_type, fip->field_tag, dir, wc, y)
|
||||
switch (fip->field_type) {
|
||||
case TIFF_SHORT:
|
||||
case TIFF_SSHORT:
|
||||
if (wc > 1) {
|
||||
uint16* wp;
|
||||
if (wc == (u_short) TIFF_VARIABLE) {
|
||||
(*getFieldFn)(tif, fip->field_tag, &wc, &wp);
|
||||
dir->tdir_count = wc;
|
||||
} else
|
||||
(*getFieldFn)(tif, fip->field_tag, &wp);
|
||||
if (!WRITEF(TIFFWriteShortArray, wp))
|
||||
return (0);
|
||||
} else {
|
||||
uint16 sv;
|
||||
(*getFieldFn)(tif, fip->field_tag, &sv);
|
||||
dir->tdir_offset =
|
||||
TIFFInsertData(tif, dir->tdir_type, sv);
|
||||
}
|
||||
break;
|
||||
case TIFF_LONG:
|
||||
case TIFF_SLONG:
|
||||
if (wc > 1) {
|
||||
uint32* lp;
|
||||
if (wc == (u_short) TIFF_VARIABLE) {
|
||||
(*getFieldFn)(tif, fip->field_tag, &wc, &lp);
|
||||
dir->tdir_count = wc;
|
||||
} else
|
||||
(*getFieldFn)(tif, fip->field_tag, &lp);
|
||||
if (!WRITEF(TIFFWriteLongArray, lp))
|
||||
return (0);
|
||||
} else {
|
||||
/* XXX handle LONG->SHORT conversion */
|
||||
(*getFieldFn)(tif, fip->field_tag, &dir->tdir_offset);
|
||||
}
|
||||
break;
|
||||
case TIFF_RATIONAL:
|
||||
case TIFF_SRATIONAL:
|
||||
if (wc > 1) {
|
||||
float* fp;
|
||||
if (wc == (u_short) TIFF_VARIABLE) {
|
||||
(*getFieldFn)(tif, fip->field_tag, &wc, &fp);
|
||||
dir->tdir_count = wc;
|
||||
} else
|
||||
(*getFieldFn)(tif, fip->field_tag, &fp);
|
||||
if (!WRITEF(TIFFWriteRationalArray, fp))
|
||||
return (0);
|
||||
} else {
|
||||
float fv;
|
||||
(*getFieldFn)(tif, fip->field_tag, &fv);
|
||||
if (!WRITEF(TIFFWriteRationalArray, &fv))
|
||||
return (0);
|
||||
}
|
||||
break;
|
||||
case TIFF_FLOAT:
|
||||
if (wc > 1) {
|
||||
float* fp;
|
||||
if (wc == (u_short) TIFF_VARIABLE) {
|
||||
(*getFieldFn)(tif, fip->field_tag, &wc, &fp);
|
||||
dir->tdir_count = wc;
|
||||
} else
|
||||
(*getFieldFn)(tif, fip->field_tag, &fp);
|
||||
if (!WRITEF(TIFFWriteFloatArray, fp))
|
||||
return (0);
|
||||
} else {
|
||||
float fv;
|
||||
(*getFieldFn)(tif, fip->field_tag, &fv);
|
||||
if (!WRITEF(TIFFWriteFloatArray, &fv))
|
||||
return (0);
|
||||
}
|
||||
break;
|
||||
case TIFF_DOUBLE:
|
||||
/* Hey - I think this is a bug, or at least a "gross
|
||||
inconsistency", in the TIFF library. Look at the original
|
||||
TIFF library code below within the "#if (0) ... #else".
|
||||
Just from the type of *dp, you can see that this code
|
||||
expects TIFFGetField() to be handed a double ** for
|
||||
any TIFF_DOUBLE tag, even for the constant wc==1 case.
|
||||
This is totally inconsistent with other fields (like
|
||||
TIFF_FLOAT, above) and is also inconsistent with the
|
||||
TIFFSetField() function for TIFF_DOUBLEs, which expects
|
||||
to be passed a single double by value for the wc==1 case.
|
||||
(See the handling of TIFFFetchNormalTag() in tif_dirread.c
|
||||
for an example.) Maybe this function was written before
|
||||
TIFFWriteDoubleArray() was written, not that that's an
|
||||
excuse. Anyway, the new code below is a trivial modification
|
||||
of the TIFF_FLOAT code above. The fact that even single
|
||||
doubles get written out in the data segment and get an
|
||||
offset value stored is irrelevant here - that is all
|
||||
handled by TIFFWriteDoubleArray(). */
|
||||
#if (0)
|
||||
{ double* dp;
|
||||
if (wc == (u_short) TIFF_VARIABLE) {
|
||||
(*getFieldFn)(tif, fip->field_tag, &wc, &dp);
|
||||
dir->tdir_count = wc;
|
||||
} else
|
||||
(*getFieldFn)(tif, fip->field_tag, &dp);
|
||||
TIFFCvtNativeToIEEEDouble(tif, wc, dp);
|
||||
if (!TIFFWriteData(tif, dir, (char*) dp))
|
||||
return (0);
|
||||
}
|
||||
#else
|
||||
if (wc > 1) {
|
||||
double* dp;
|
||||
if (wc == (u_short) TIFF_VARIABLE) {
|
||||
(*getFieldFn)(tif, fip->field_tag, &wc, &dp);
|
||||
dir->tdir_count = wc;
|
||||
} else
|
||||
(*getFieldFn)(tif, fip->field_tag, &dp);
|
||||
if (!WRITEF(TIFFWriteDoubleArray, dp))
|
||||
return (0);
|
||||
} else {
|
||||
double dv;
|
||||
(*getFieldFn)(tif, fip->field_tag, &dv);
|
||||
if (!WRITEF(TIFFWriteDoubleArray, &dv))
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case TIFF_ASCII:
|
||||
{ char* cp;
|
||||
(*getFieldFn)(tif, fip->field_tag, &cp);
|
||||
dir->tdir_count = (uint32) (strlen(cp) + 1);
|
||||
if (!TIFFWriteByteArray(tif, dir, cp))
|
||||
return (0);
|
||||
}
|
||||
break;
|
||||
case TIFF_UNDEFINED:
|
||||
{ char* cp;
|
||||
if (wc == (u_short) TIFF_VARIABLE) {
|
||||
(*getFieldFn)(tif, fip->field_tag, &wc, &cp);
|
||||
dir->tdir_count = wc;
|
||||
} else
|
||||
(*getFieldFn)(tif, fip->field_tag, &cp);
|
||||
if (!TIFFWriteByteArray(tif, dir, cp))
|
||||
return (0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
#undef WRITEF
|
||||
|
||||
/* Everything after this is exactly duplicated from the standard tif_dirwrite.c
|
||||
file, necessitated by the fact that they are declared static there so
|
||||
we can't call them!
|
||||
*/
|
||||
/*
|
||||
* Setup a directory entry with either a SHORT
|
||||
* or LONG type according to the value.
|
||||
*/
|
||||
static void
|
||||
TIFFSetupShortLong(TIFF* tif, ttag_t tag, TIFFDirEntry* dir, uint32 v)
|
||||
{
|
||||
dir->tdir_tag = tag;
|
||||
dir->tdir_count = 1;
|
||||
if (v > 0xffffL) {
|
||||
dir->tdir_type = (short) TIFF_LONG;
|
||||
dir->tdir_offset = v;
|
||||
} else {
|
||||
dir->tdir_type = (short) TIFF_SHORT;
|
||||
dir->tdir_offset = TIFFInsertData(tif, (int) TIFF_SHORT, v);
|
||||
}
|
||||
}
|
||||
#undef MakeShortDirent
|
||||
|
||||
#ifndef TIFFWriteRational
|
||||
/*
|
||||
* Setup a RATIONAL directory entry and
|
||||
* write the associated indirect value.
|
||||
*/
|
||||
static int
|
||||
TIFFWriteRational(TIFF* tif,
|
||||
TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, float v)
|
||||
{
|
||||
return (TIFFWriteRationalArray(tif, type, tag, dir, 1, &v));
|
||||
}
|
||||
#endif
|
||||
|
||||
#define NITEMS(x) (sizeof (x) / sizeof (x[0]))
|
||||
/*
|
||||
* Setup a directory entry that references a
|
||||
* samples/pixel array of SHORT values and
|
||||
* (potentially) write the associated indirect
|
||||
* values.
|
||||
*/
|
||||
static int
|
||||
TIFFWritePerSampleShorts(TIFF* tif, ttag_t tag, TIFFDirEntry* dir)
|
||||
{
|
||||
uint16 buf[10], v;
|
||||
uint16* w = buf;
|
||||
int i, status, samples = tif->tif_dir.td_samplesperpixel;
|
||||
|
||||
if (samples > NITEMS(buf))
|
||||
w = (uint16*) _TIFFmalloc(samples * sizeof (uint16));
|
||||
TIFFGetField(tif, tag, &v);
|
||||
for (i = 0; i < samples; i++)
|
||||
w[i] = v;
|
||||
status = TIFFWriteShortArray(tif, TIFF_SHORT, tag, dir, samples, w);
|
||||
if (w != buf)
|
||||
_TIFFfree((char*) w);
|
||||
return (status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup a directory entry that references a samples/pixel array of ``type''
|
||||
* values and (potentially) write the associated indirect values. The source
|
||||
* data from TIFFGetField() for the specified tag must be returned as double.
|
||||
*/
|
||||
static int
|
||||
TIFFWritePerSampleAnys(TIFF* tif,
|
||||
TIFFDataType type, ttag_t tag, TIFFDirEntry* dir)
|
||||
{
|
||||
double buf[10], v;
|
||||
double* w = buf;
|
||||
int i, status;
|
||||
int samples = (int) tif->tif_dir.td_samplesperpixel;
|
||||
|
||||
if (samples > NITEMS(buf))
|
||||
w = (double*) _TIFFmalloc(samples * sizeof (double));
|
||||
TIFFGetField(tif, tag, &v);
|
||||
for (i = 0; i < samples; i++)
|
||||
w[i] = v;
|
||||
status = TIFFWriteAnyArray(tif, type, tag, dir, samples, w);
|
||||
if (w != buf)
|
||||
_TIFFfree(w);
|
||||
return (status);
|
||||
}
|
||||
#undef NITEMS
|
||||
|
||||
/*
|
||||
* Setup a pair of shorts that are returned by
|
||||
* value, rather than as a reference to an array.
|
||||
*/
|
||||
static int
|
||||
TIFFSetupShortPair(TIFF* tif, ttag_t tag, TIFFDirEntry* dir)
|
||||
{
|
||||
uint16 v[2];
|
||||
|
||||
TIFFGetField(tif, tag, &v[0], &v[1]);
|
||||
return (TIFFWriteShortArray(tif, TIFF_SHORT, tag, dir, 2, v));
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup a directory entry for an NxM table of shorts,
|
||||
* where M is known to be 2**bitspersample, and write
|
||||
* the associated indirect data.
|
||||
*/
|
||||
static int
|
||||
TIFFWriteShortTable(TIFF* tif,
|
||||
ttag_t tag, TIFFDirEntry* dir, uint32 n, uint16** table)
|
||||
{
|
||||
uint32 i, off;
|
||||
|
||||
dir->tdir_tag = tag;
|
||||
dir->tdir_type = (short) TIFF_SHORT;
|
||||
/* XXX -- yech, fool TIFFWriteData */
|
||||
dir->tdir_count = (uint32) (1L<<tif->tif_dir.td_bitspersample);
|
||||
off = tif->tif_dataoff;
|
||||
for (i = 0; i < n; i++)
|
||||
if (!TIFFWriteData(tif, dir, (char *)table[i]))
|
||||
return (0);
|
||||
dir->tdir_count *= n;
|
||||
dir->tdir_offset = off;
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write/copy data associated with an ASCII or opaque tag value.
|
||||
*/
|
||||
static int
|
||||
TIFFWriteByteArray(TIFF* tif, TIFFDirEntry* dir, char* cp)
|
||||
{
|
||||
if (dir->tdir_count > 4) {
|
||||
if (!TIFFWriteData(tif, dir, cp))
|
||||
return (0);
|
||||
} else
|
||||
_TIFFmemcpy(&dir->tdir_offset, cp, dir->tdir_count);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup a directory entry of an array of SHORT
|
||||
* or SSHORT and write the associated indirect values.
|
||||
*/
|
||||
static int
|
||||
TIFFWriteShortArray(TIFF* tif,
|
||||
TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, uint16* v)
|
||||
{
|
||||
dir->tdir_tag = tag;
|
||||
dir->tdir_type = (short) type;
|
||||
dir->tdir_count = n;
|
||||
if (n <= 2) {
|
||||
if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) {
|
||||
dir->tdir_offset = (uint32) ((long) v[0] << 16);
|
||||
if (n == 2)
|
||||
dir->tdir_offset |= v[1] & 0xffff;
|
||||
} else {
|
||||
dir->tdir_offset = v[0] & 0xffff;
|
||||
if (n == 2)
|
||||
dir->tdir_offset |= (long) v[1] << 16;
|
||||
}
|
||||
return (1);
|
||||
} else
|
||||
return (TIFFWriteData(tif, dir, (char*) v));
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup a directory entry of an array of LONG
|
||||
* or SLONG and write the associated indirect values.
|
||||
*/
|
||||
static int
|
||||
TIFFWriteLongArray(TIFF* tif,
|
||||
TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, uint32* v)
|
||||
{
|
||||
dir->tdir_tag = tag;
|
||||
dir->tdir_type = (short) type;
|
||||
dir->tdir_count = n;
|
||||
if (n == 1) {
|
||||
dir->tdir_offset = v[0];
|
||||
return (1);
|
||||
} else
|
||||
return (TIFFWriteData(tif, dir, (char*) v));
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup a directory entry of an array of RATIONAL
|
||||
* or SRATIONAL and write the associated indirect values.
|
||||
*/
|
||||
static int
|
||||
TIFFWriteRationalArray(TIFF* tif,
|
||||
TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, float* v)
|
||||
{
|
||||
uint32 i;
|
||||
uint32* t;
|
||||
int status;
|
||||
|
||||
dir->tdir_tag = tag;
|
||||
dir->tdir_type = (short) type;
|
||||
dir->tdir_count = n;
|
||||
t = (uint32*) _TIFFmalloc(2*n * sizeof (uint32));
|
||||
for (i = 0; i < n; i++) {
|
||||
float fv = v[i];
|
||||
int sign = 1;
|
||||
uint32 den;
|
||||
|
||||
if (fv < 0) {
|
||||
if (type == TIFF_RATIONAL) {
|
||||
TIFFWarning(tif->tif_name,
|
||||
"\"%s\": Information lost writing value (%g) as (unsigned) RATIONAL",
|
||||
_TIFFFieldWithTag(tif,tag)->field_name, v);
|
||||
fv = 0;
|
||||
} else
|
||||
fv = -fv, sign = -1;
|
||||
}
|
||||
den = 1L;
|
||||
if (fv > 0) {
|
||||
while (fv < 1L<<(31-3) && den < 1L<<(31-3))
|
||||
fv *= 1<<3, den *= 1L<<3;
|
||||
}
|
||||
t[2*i+0] = sign * (fv + 0.5);
|
||||
t[2*i+1] = den;
|
||||
}
|
||||
status = TIFFWriteData(tif, dir, (char *)t);
|
||||
_TIFFfree((char*) t);
|
||||
return (status);
|
||||
}
|
||||
|
||||
static int
|
||||
TIFFWriteFloatArray(TIFF* tif,
|
||||
TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, float* v)
|
||||
{
|
||||
dir->tdir_tag = tag;
|
||||
dir->tdir_type = (short) type;
|
||||
dir->tdir_count = n;
|
||||
TIFFCvtNativeToIEEEFloat(tif, n, v);
|
||||
if (n == 1) {
|
||||
dir->tdir_offset = *(uint32*) &v[0];
|
||||
return (1);
|
||||
} else
|
||||
return (TIFFWriteData(tif, dir, (char*) v));
|
||||
}
|
||||
|
||||
static int
|
||||
TIFFWriteDoubleArray(TIFF* tif,
|
||||
TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, double* v)
|
||||
{
|
||||
dir->tdir_tag = tag;
|
||||
dir->tdir_type = (short) type;
|
||||
dir->tdir_count = n;
|
||||
TIFFCvtNativeToIEEEDouble(tif, n, v);
|
||||
return (TIFFWriteData(tif, dir, (char*) v));
|
||||
}
|
||||
|
||||
/*
|
||||
* Write an array of ``type'' values for a specified tag (i.e. this is a tag
|
||||
* which is allowed to have different types, e.g. SMaxSampleType).
|
||||
* Internally the data values are represented as double since a double can
|
||||
* hold any of the TIFF tag types (yes, this should really be an abstract
|
||||
* type tany_t for portability). The data is converted into the specified
|
||||
* type in a temporary buffer and then handed off to the appropriate array
|
||||
* writer.
|
||||
*/
|
||||
static int
|
||||
TIFFWriteAnyArray(TIFF* tif,
|
||||
TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, double* v)
|
||||
{
|
||||
char buf[10 * sizeof(double)];
|
||||
char* w = buf;
|
||||
int i, status = 0;
|
||||
|
||||
if (n * tiffDataWidth[type] > sizeof buf)
|
||||
w = (char*) _TIFFmalloc(n * tiffDataWidth[type]);
|
||||
switch (type) {
|
||||
case TIFF_BYTE:
|
||||
{ unsigned char* bp = (unsigned char*) w;
|
||||
for (i = 0; i < n; i++)
|
||||
bp[i] = (unsigned char) v[i];
|
||||
dir->tdir_tag = tag;
|
||||
dir->tdir_type = (short) type;
|
||||
dir->tdir_count = n;
|
||||
if (!TIFFWriteByteArray(tif, dir, (char*) bp))
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
case TIFF_SBYTE:
|
||||
{ signed char* bp = (signed char*) w;
|
||||
for (i = 0; i < n; i++)
|
||||
bp[i] = (signed char) v[i];
|
||||
dir->tdir_tag = tag;
|
||||
dir->tdir_type = (short) type;
|
||||
dir->tdir_count = n;
|
||||
if (!TIFFWriteByteArray(tif, dir, (char*) bp))
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
case TIFF_SHORT:
|
||||
{ uint16* bp = (uint16*) w;
|
||||
for (i = 0; i < n; i++)
|
||||
bp[i] = (uint16) v[i];
|
||||
if (!TIFFWriteShortArray(tif, type, tag, dir, n, (uint16*)bp))
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
case TIFF_SSHORT:
|
||||
{ int16* bp = (int16*) w;
|
||||
for (i = 0; i < n; i++)
|
||||
bp[i] = (int16) v[i];
|
||||
if (!TIFFWriteShortArray(tif, type, tag, dir, n, (uint16*)bp))
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
case TIFF_LONG:
|
||||
{ uint32* bp = (uint32*) w;
|
||||
for (i = 0; i < n; i++)
|
||||
bp[i] = (uint32) v[i];
|
||||
if (!TIFFWriteLongArray(tif, type, tag, dir, n, bp))
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
case TIFF_SLONG:
|
||||
{ int32* bp = (int32*) w;
|
||||
for (i = 0; i < n; i++)
|
||||
bp[i] = (int32) v[i];
|
||||
if (!TIFFWriteLongArray(tif, type, tag, dir, n, (uint32*) bp))
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
case TIFF_FLOAT:
|
||||
{ float* bp = (float*) w;
|
||||
for (i = 0; i < n; i++)
|
||||
bp[i] = (float) v[i];
|
||||
if (!TIFFWriteFloatArray(tif, type, tag, dir, n, bp))
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
case TIFF_DOUBLE:
|
||||
return (TIFFWriteDoubleArray(tif, type, tag, dir, n, v));
|
||||
default:
|
||||
/* TIFF_NOTYPE */
|
||||
/* TIFF_ASCII */
|
||||
/* TIFF_UNDEFINED */
|
||||
/* TIFF_RATIONAL */
|
||||
/* TIFF_SRATIONAL */
|
||||
goto out;
|
||||
}
|
||||
status = 1;
|
||||
out:
|
||||
if (w != buf)
|
||||
_TIFFfree(w);
|
||||
return (status);
|
||||
}
|
||||
|
||||
#ifdef COLORIMETRY_SUPPORT
|
||||
static int
|
||||
TIFFWriteTransferFunction(TIFF* tif, TIFFDirEntry* dir)
|
||||
{
|
||||
TIFFDirectory* td = &tif->tif_dir;
|
||||
tsize_t n = (1L<<td->td_bitspersample) * sizeof (uint16);
|
||||
uint16** tf = td->td_transferfunction;
|
||||
int ncols;
|
||||
|
||||
/*
|
||||
* Check if the table can be written as a single column,
|
||||
* or if it must be written as 3 columns. Note that we
|
||||
* write a 3-column tag if there are 2 samples/pixel and
|
||||
* a single column of data won't suffice--hmm.
|
||||
*/
|
||||
switch (td->td_samplesperpixel - td->td_extrasamples) {
|
||||
default: if (_TIFFmemcmp(tf[0], tf[2], n)) { ncols = 3; break; }
|
||||
case 2: if (_TIFFmemcmp(tf[0], tf[1], n)) { ncols = 3; break; }
|
||||
case 1: case 0: ncols = 1;
|
||||
}
|
||||
return (TIFFWriteShortTable(tif,
|
||||
TIFFTAG_TRANSFERFUNCTION, dir, ncols, tf));
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Write a contiguous directory item.
|
||||
*/
|
||||
static int
|
||||
TIFFWriteData(TIFF* tif, TIFFDirEntry* dir, char* cp)
|
||||
{
|
||||
tsize_t cc;
|
||||
|
||||
if (tif->tif_flags & TIFF_SWAB) {
|
||||
switch (dir->tdir_type) {
|
||||
case TIFF_SHORT:
|
||||
case TIFF_SSHORT:
|
||||
TIFFSwabArrayOfShort((uint16*) cp, dir->tdir_count);
|
||||
break;
|
||||
case TIFF_LONG:
|
||||
case TIFF_SLONG:
|
||||
case TIFF_FLOAT:
|
||||
TIFFSwabArrayOfLong((uint32*) cp, dir->tdir_count);
|
||||
break;
|
||||
case TIFF_RATIONAL:
|
||||
case TIFF_SRATIONAL:
|
||||
TIFFSwabArrayOfLong((uint32*) cp, 2*dir->tdir_count);
|
||||
break;
|
||||
case TIFF_DOUBLE:
|
||||
TIFFSwabArrayOfDouble((double*) cp, dir->tdir_count);
|
||||
break;
|
||||
}
|
||||
}
|
||||
dir->tdir_offset = tif->tif_dataoff;
|
||||
cc = dir->tdir_count * tiffDataWidth[dir->tdir_type];
|
||||
if (SeekOK(tif, dir->tdir_offset) &&
|
||||
WriteOK(tif, cp, cc)) {
|
||||
tif->tif_dataoff += (cc + 1) & ~1;
|
||||
return (1);
|
||||
}
|
||||
TIFFError(tif->tif_name, "Error writing data for field \"%s\"",
|
||||
_TIFFFieldWithTag(tif, dir->tdir_tag)->field_name);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Link the current directory into the
|
||||
* directory chain for the file.
|
||||
*/
|
||||
static int
|
||||
TIFFLinkDirectory(TIFF* tif)
|
||||
{
|
||||
static const char module[] = "TIFFLinkDirectory";
|
||||
uint32 nextdir;
|
||||
uint32 diroff;
|
||||
|
||||
tif->tif_diroff = (TIFFSeekFile(tif, (toff_t) 0, SEEK_END)+1) &~ 1;
|
||||
diroff = (uint32) tif->tif_diroff;
|
||||
if (tif->tif_flags & TIFF_SWAB)
|
||||
TIFFSwabLong(&diroff);
|
||||
#if SUBIFD_SUPPORT
|
||||
if (tif->tif_flags & TIFF_INSUBIFD) {
|
||||
(void) TIFFSeekFile(tif, tif->tif_subifdoff, SEEK_SET);
|
||||
if (!WriteOK(tif, &diroff, sizeof (diroff))) {
|
||||
TIFFError(module,
|
||||
"%s: Error writing SubIFD directory link",
|
||||
tif->tif_name);
|
||||
return (0);
|
||||
}
|
||||
/*
|
||||
* Advance to the next SubIFD or, if this is
|
||||
* the last one configured, revert back to the
|
||||
* normal directory linkage.
|
||||
*/
|
||||
if (--tif->tif_nsubifd)
|
||||
tif->tif_subifdoff += sizeof (diroff);
|
||||
else
|
||||
tif->tif_flags &= ~TIFF_INSUBIFD;
|
||||
return (1);
|
||||
}
|
||||
#endif
|
||||
if (tif->tif_header.tiff_diroff == 0) {
|
||||
/*
|
||||
* First directory, overwrite offset in header.
|
||||
*/
|
||||
tif->tif_header.tiff_diroff = (uint32) tif->tif_diroff;
|
||||
#define HDROFF(f) ((toff_t) &(((TIFFHeader*) 0)->f))
|
||||
(void) TIFFSeekFile(tif, HDROFF(tiff_diroff), SEEK_SET);
|
||||
if (!WriteOK(tif, &diroff, sizeof (diroff))) {
|
||||
TIFFError(tif->tif_name, "Error writing TIFF header");
|
||||
return (0);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
/*
|
||||
* Not the first directory, search to the last and append.
|
||||
*/
|
||||
nextdir = tif->tif_header.tiff_diroff;
|
||||
do {
|
||||
uint16 dircount;
|
||||
|
||||
if (!SeekOK(tif, nextdir) ||
|
||||
!ReadOK(tif, &dircount, sizeof (dircount))) {
|
||||
TIFFError(module, "Error fetching directory count");
|
||||
return (0);
|
||||
}
|
||||
if (tif->tif_flags & TIFF_SWAB)
|
||||
TIFFSwabShort(&dircount);
|
||||
(void) TIFFSeekFile(tif,
|
||||
dircount * sizeof (TIFFDirEntry), SEEK_CUR);
|
||||
if (!ReadOK(tif, &nextdir, sizeof (nextdir))) {
|
||||
TIFFError(module, "Error fetching directory link");
|
||||
return (0);
|
||||
}
|
||||
if (tif->tif_flags & TIFF_SWAB)
|
||||
TIFFSwabLong(&nextdir);
|
||||
} while (nextdir != 0);
|
||||
(void) TIFFSeekFile(tif, -(toff_t) sizeof (nextdir), SEEK_CUR);
|
||||
if (!WriteOK(tif, &diroff, sizeof (diroff))) {
|
||||
TIFFError(module, "Error writing directory link");
|
||||
return (0);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
Executable
+247
@@ -0,0 +1,247 @@
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)ras2tif.c 1.2 90/03/06";
|
||||
#endif
|
||||
/*-
|
||||
* ras2tif.c - Converts from a Sun Rasterfile to a Tagged Image File.
|
||||
*
|
||||
* Copyright (c) 1990 by Sun Microsystems, Inc.
|
||||
*
|
||||
* Author: Patrick J. Naughton
|
||||
* naughton@wind.sun.com
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This file is provided AS IS with no warranties of any kind. The author
|
||||
* shall have no liability with respect to the infringement of copyrights,
|
||||
* trade secrets or any patents by this file or any part thereof. In no
|
||||
* event will the author be liable for any lost revenue or profits or
|
||||
* other special, indirect and consequential damages.
|
||||
*
|
||||
* Comments and additions should be sent to the author:
|
||||
*
|
||||
* Patrick J. Naughton
|
||||
* Sun Microsystems
|
||||
* 2550 Garcia Ave, MS 14-40
|
||||
* Mountain View, CA 94043
|
||||
* (415) 336-1080
|
||||
*
|
||||
* Revision History:
|
||||
* 11-Jan-89: Created.
|
||||
* 06-Mar-90: fix bug in SCALE() macro.
|
||||
* got rid of xres and yres, (they weren't working anyways).
|
||||
* fixed bpsl calculation.
|
||||
* 25-Nov-99: y2k fix (year as 1900 + tm_year) <mike@onshore.com>
|
||||
*
|
||||
* Description:
|
||||
* This program takes a Sun Rasterfile [see rasterfile(5)] as input and
|
||||
* writes a MicroSoft/Aldus "Tagged Image File Format" image or "TIFF" file.
|
||||
* The input file may be standard input, but the output TIFF file must be a
|
||||
* real file since seek(2) is used.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
#include <pixrect/pixrect_hs.h>
|
||||
#include "tiffio.h"
|
||||
|
||||
typedef int boolean;
|
||||
#define True (1)
|
||||
#define False (0)
|
||||
#define SCALE(x) (((x)*((1L<<16)-1))/255)
|
||||
|
||||
boolean Verbose = False;
|
||||
boolean dummyinput = False;
|
||||
char *pname; /* program name (used for error messages) */
|
||||
|
||||
void
|
||||
error(s1, s2)
|
||||
char *s1,
|
||||
*s2;
|
||||
{
|
||||
fprintf(stderr, s1, pname, s2);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void
|
||||
usage()
|
||||
{
|
||||
error("usage: %s -[vq] [-|rasterfile] TIFFfile\n", NULL);
|
||||
}
|
||||
|
||||
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
char *inf = NULL;
|
||||
char *outf = NULL;
|
||||
FILE *fp;
|
||||
int depth,
|
||||
i;
|
||||
long row;
|
||||
TIFF *tif;
|
||||
Pixrect *pix; /* The Sun Pixrect */
|
||||
colormap_t Colormap; /* The Pixrect Colormap */
|
||||
u_short red[256],
|
||||
green[256],
|
||||
blue[256];
|
||||
struct tm *ct;
|
||||
struct timeval tv;
|
||||
long width,
|
||||
height;
|
||||
long rowsperstrip;
|
||||
int year;
|
||||
short photometric;
|
||||
short samplesperpixel;
|
||||
short bitspersample;
|
||||
int bpsl;
|
||||
static char *version = "ras2tif 1.0";
|
||||
static char *datetime = "1990:01:01 12:00:00";
|
||||
|
||||
gettimeofday(&tv, (struct timezone *) NULL);
|
||||
ct = localtime(&tv.tv_sec);
|
||||
year=1900 + ct->tm_year;
|
||||
sprintf(datetime, "%04d:%02d:%02d %02d:%02d:%02d",
|
||||
year, ct->tm_mon + 1, ct->tm_mday,
|
||||
ct->tm_hour, ct->tm_min, ct->tm_sec);
|
||||
|
||||
setbuf(stderr, NULL);
|
||||
pname = argv[0];
|
||||
|
||||
while (--argc) {
|
||||
if ((++argv)[0][0] == '-') {
|
||||
switch (argv[0][1]) {
|
||||
case 'v':
|
||||
Verbose = True;
|
||||
break;
|
||||
case 'q':
|
||||
usage();
|
||||
break;
|
||||
case '\0':
|
||||
if (inf == NULL)
|
||||
dummyinput = True;
|
||||
else
|
||||
usage();
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "%s: illegal option -%c.\n", pname,
|
||||
argv[0][1]);
|
||||
exit(1);
|
||||
}
|
||||
} else if (inf == NULL && !dummyinput) {
|
||||
inf = argv[0];
|
||||
} else if (outf == NULL)
|
||||
outf = argv[0];
|
||||
else
|
||||
usage();
|
||||
}
|
||||
|
||||
if (outf == NULL)
|
||||
error("%s: can't write output file to a stream.\n", NULL);
|
||||
|
||||
if (dummyinput || inf == NULL) {
|
||||
inf = "Standard Input";
|
||||
fp = stdin;
|
||||
} else if ((fp = fopen(inf, "r")) == NULL)
|
||||
error("%s: %s couldn't be opened.\n", inf);
|
||||
|
||||
if (Verbose)
|
||||
fprintf(stderr, "Reading rasterfile from %s...", inf);
|
||||
|
||||
pix = pr_load(fp, &Colormap);
|
||||
if (pix == NULL)
|
||||
error("%s: %s is not a raster file.\n", inf);
|
||||
|
||||
if (Verbose)
|
||||
fprintf(stderr, "done.\n");
|
||||
|
||||
if (Verbose)
|
||||
fprintf(stderr, "Writing %s...", outf);
|
||||
|
||||
tif = TIFFOpen(outf, "w");
|
||||
|
||||
if (tif == NULL)
|
||||
error("%s: error opening TIFF file %s", outf);
|
||||
|
||||
width = pix->pr_width;
|
||||
height = pix->pr_height;
|
||||
depth = pix->pr_depth;
|
||||
|
||||
switch (depth) {
|
||||
case 1:
|
||||
samplesperpixel = 1;
|
||||
bitspersample = 1;
|
||||
photometric = PHOTOMETRIC_MINISBLACK;
|
||||
break;
|
||||
case 8:
|
||||
samplesperpixel = 1;
|
||||
bitspersample = 8;
|
||||
photometric = PHOTOMETRIC_PALETTE;
|
||||
break;
|
||||
case 24:
|
||||
samplesperpixel = 3;
|
||||
bitspersample = 8;
|
||||
photometric = PHOTOMETRIC_RGB;
|
||||
break;
|
||||
case 32:
|
||||
samplesperpixel = 4;
|
||||
bitspersample = 8;
|
||||
photometric = PHOTOMETRIC_RGB;
|
||||
break;
|
||||
default:
|
||||
error("%s: bogus depth: %d\n", depth);
|
||||
}
|
||||
|
||||
bpsl = ((depth * width + 15) >> 3) & ~1;
|
||||
rowsperstrip = (8 * 1024) / bpsl;
|
||||
|
||||
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width);
|
||||
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height);
|
||||
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bitspersample);
|
||||
TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
|
||||
TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_LZW);
|
||||
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric);
|
||||
TIFFSetField(tif, TIFFTAG_DOCUMENTNAME, inf);
|
||||
TIFFSetField(tif, TIFFTAG_IMAGEDESCRIPTION, "converted Sun rasterfile");
|
||||
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, samplesperpixel);
|
||||
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
|
||||
TIFFSetField(tif, TIFFTAG_STRIPBYTECOUNTS, height / rowsperstrip);
|
||||
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
|
||||
TIFFSetField(tif, TIFFTAG_SOFTWARE, version);
|
||||
TIFFSetField(tif, TIFFTAG_DATETIME, datetime);
|
||||
|
||||
memset(red, 0, sizeof(red));
|
||||
memset(green, 0, sizeof(green));
|
||||
memset(blue, 0, sizeof(blue));
|
||||
if (depth == 8) {
|
||||
TIFFSetField(tif, TIFFTAG_COLORMAP, red, green, blue);
|
||||
for (i = 0; i < Colormap.length; i++) {
|
||||
red[i] = SCALE(Colormap.map[0][i]);
|
||||
green[i] = SCALE(Colormap.map[1][i]);
|
||||
blue[i] = SCALE(Colormap.map[2][i]);
|
||||
}
|
||||
}
|
||||
if (Verbose)
|
||||
fprintf(stderr, "%dx%dx%d image, ", width, height, depth);
|
||||
|
||||
for (row = 0; row < height; row++)
|
||||
if (TIFFWriteScanline(tif,
|
||||
(u_char *) mprd_addr(mpr_d(pix), 0, row),
|
||||
row, 0) < 0) {
|
||||
fprintf("failed a scanline write (%d)\n", row);
|
||||
break;
|
||||
}
|
||||
TIFFFlushData(tif);
|
||||
TIFFClose(tif);
|
||||
|
||||
if (Verbose)
|
||||
fprintf(stderr, "done.\n");
|
||||
|
||||
pr_destroy(pix);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
Sun May 19 22:28:16 PDT 1991
|
||||
|
||||
These programs are from Patrick Naughton (naughton@wind.sun.com).
|
||||
I've tried to update them to reflect changes to the library, but
|
||||
I am unable to verify that they operate properly, because they
|
||||
require the Sun pixrect library.
|
||||
|
||||
Please contact Patrick directly if you have questions/problems.
|
||||
|
||||
Sam
|
||||
Executable
+337
@@ -0,0 +1,337 @@
|
||||
#ifndef lint
|
||||
static char id[] = "$Id: tif2ras.c,v 1.1.1.1 2000/06/24 19:10:17 tshead Exp $";
|
||||
#endif
|
||||
/*-
|
||||
* tif2ras.c - Converts from a Tagged Image File Format image to a Sun Raster.
|
||||
*
|
||||
* Copyright (c) 1990 by Sun Microsystems, Inc.
|
||||
*
|
||||
* Author: Patrick J. Naughton
|
||||
* naughton@wind.sun.com
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This file is provided AS IS with no warranties of any kind. The author
|
||||
* shall have no liability with respect to the infringement of copyrights,
|
||||
* trade secrets or any patents by this file or any part thereof. In no
|
||||
* event will the author be liable for any lost revenue or profits or
|
||||
* other special, indirect and consequential damages.
|
||||
*
|
||||
* Comments and additions should be sent to the author:
|
||||
*
|
||||
* Patrick J. Naughton
|
||||
* Sun Microsystems
|
||||
* 2550 Garcia Ave, MS 14-40
|
||||
* Mountain View, CA 94043
|
||||
* (415) 336-1080
|
||||
*
|
||||
* Revision History:
|
||||
* 10-Jan-89: Created.
|
||||
* 06-Mar-90: Change to byte encoded rasterfiles.
|
||||
* fix bug in call to ReadScanline().
|
||||
* fix bug in CVT() macro.
|
||||
* fix assignment of td, (missing &).
|
||||
*
|
||||
* Description:
|
||||
* This program takes a MicroSoft/Aldus "Tagged Image File Format" image or
|
||||
* "TIFF" file as input and writes a Sun Rasterfile [see rasterfile(5)]. The
|
||||
* output file may be standard output, but the input TIFF file must be a real
|
||||
* file since seek(2) is used.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <pixrect/pixrect_hs.h>
|
||||
#include "tiffio.h"
|
||||
|
||||
typedef int boolean;
|
||||
#define True (1)
|
||||
#define False (0)
|
||||
#define CVT(x) (((x) * 255) / ((1L<<16)-1))
|
||||
|
||||
boolean Verbose = False;
|
||||
char *pname; /* program name (used for error messages) */
|
||||
|
||||
void
|
||||
error(s1, s2)
|
||||
char *s1,
|
||||
*s2;
|
||||
{
|
||||
fprintf(stderr, s1, pname, s2);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void
|
||||
usage()
|
||||
{
|
||||
error("usage: %s -[vq] TIFFfile [rasterfile]\n", NULL);
|
||||
}
|
||||
|
||||
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
char *inf = NULL;
|
||||
char *outf = NULL;
|
||||
FILE *fp;
|
||||
long width,
|
||||
height;
|
||||
int depth,
|
||||
numcolors;
|
||||
register TIFF *tif;
|
||||
TIFFDirectory *td;
|
||||
register u_char *inp,
|
||||
*outp;
|
||||
register int col,
|
||||
i;
|
||||
register long row;
|
||||
u_char *Map = NULL;
|
||||
u_char *buf;
|
||||
short bitspersample;
|
||||
short samplesperpixel;
|
||||
short photometric;
|
||||
u_short *redcolormap,
|
||||
*bluecolormap,
|
||||
*greencolormap;
|
||||
|
||||
Pixrect *pix; /* The Sun Pixrect */
|
||||
colormap_t Colormap; /* The Pixrect Colormap */
|
||||
u_char red[256],
|
||||
green[256],
|
||||
blue[256];
|
||||
|
||||
setbuf(stderr, NULL);
|
||||
pname = argv[0];
|
||||
|
||||
while (--argc) {
|
||||
if ((++argv)[0][0] == '-')
|
||||
switch (argv[0][1]) {
|
||||
case 'v':
|
||||
Verbose = True;
|
||||
break;
|
||||
case 'q':
|
||||
usage();
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "%s: illegal option -%c.\n", pname,
|
||||
argv[0][1]);
|
||||
exit(1);
|
||||
}
|
||||
else if (inf == NULL)
|
||||
inf = argv[0];
|
||||
else if (outf == NULL)
|
||||
outf = argv[0];
|
||||
else
|
||||
usage();
|
||||
|
||||
}
|
||||
|
||||
if (inf == NULL)
|
||||
error("%s: can't read input file from a stream.\n", NULL);
|
||||
|
||||
if (Verbose)
|
||||
fprintf(stderr, "Reading %s...", inf);
|
||||
|
||||
tif = TIFFOpen(inf, "r");
|
||||
|
||||
if (tif == NULL)
|
||||
error("%s: error opening TIFF file %s", inf);
|
||||
|
||||
if (Verbose)
|
||||
TIFFPrintDirectory(tif, stderr, True, False, False);
|
||||
TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bitspersample);
|
||||
if (bitspersample > 8)
|
||||
error("%s: can't handle more than 8-bits per sample\n", NULL);
|
||||
|
||||
TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel);
|
||||
switch (samplesperpixel) {
|
||||
case 1:
|
||||
if (bitspersample == 1)
|
||||
depth = 1;
|
||||
else
|
||||
depth = 8;
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
depth = 24;
|
||||
break;
|
||||
default:
|
||||
error("%s: only handle 1-channel gray scale or 3-channel color\n");
|
||||
}
|
||||
|
||||
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width);
|
||||
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height);
|
||||
|
||||
if (Verbose)
|
||||
fprintf(stderr, "%dx%dx%d image, ", width, height, depth);
|
||||
if (Verbose)
|
||||
fprintf(stderr, "%d bits/sample, %d samples/pixel, ",
|
||||
bitspersample, samplesperpixel);
|
||||
|
||||
pix = mem_create(width, height, depth);
|
||||
if (pix == (Pixrect *) NULL)
|
||||
error("%s: can't allocate memory for output pixrect...\n", NULL);
|
||||
|
||||
numcolors = (1 << bitspersample);
|
||||
|
||||
TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric);
|
||||
if (numcolors == 2) {
|
||||
if (Verbose)
|
||||
fprintf(stderr, "monochrome ");
|
||||
Colormap.type = RMT_NONE;
|
||||
Colormap.length = 0;
|
||||
Colormap.map[0] = Colormap.map[1] = Colormap.map[2] = NULL;
|
||||
} else {
|
||||
switch (photometric) {
|
||||
case PHOTOMETRIC_MINISBLACK:
|
||||
if (Verbose)
|
||||
fprintf(stderr, "%d graylevels (min=black), ", numcolors);
|
||||
Map = (u_char *) malloc(numcolors * sizeof(u_char));
|
||||
for (i = 0; i < numcolors; i++)
|
||||
Map[i] = (255 * i) / numcolors;
|
||||
Colormap.type = RMT_EQUAL_RGB;
|
||||
Colormap.length = numcolors;
|
||||
Colormap.map[0] = Colormap.map[1] = Colormap.map[2] = Map;
|
||||
break;
|
||||
case PHOTOMETRIC_MINISWHITE:
|
||||
if (Verbose)
|
||||
fprintf(stderr, "%d graylevels (min=white), ", numcolors);
|
||||
Map = (u_char *) malloc(numcolors * sizeof(u_char));
|
||||
for (i = 0; i < numcolors; i++)
|
||||
Map[i] = 255 - ((255 * i) / numcolors);
|
||||
Colormap.type = RMT_EQUAL_RGB;
|
||||
Colormap.length = numcolors;
|
||||
Colormap.map[0] = Colormap.map[1] = Colormap.map[2] = Map;
|
||||
break;
|
||||
case PHOTOMETRIC_RGB:
|
||||
if (Verbose)
|
||||
fprintf(stderr, "truecolor ");
|
||||
Colormap.type = RMT_NONE;
|
||||
Colormap.length = 0;
|
||||
Colormap.map[0] = Colormap.map[1] = Colormap.map[2] = NULL;
|
||||
break;
|
||||
case PHOTOMETRIC_PALETTE:
|
||||
if (Verbose)
|
||||
fprintf(stderr, "colormapped ");
|
||||
Colormap.type = RMT_EQUAL_RGB;
|
||||
Colormap.length = numcolors;
|
||||
memset(red, 0, sizeof(red));
|
||||
memset(green, 0, sizeof(green));
|
||||
memset(blue, 0, sizeof(blue));
|
||||
TIFFGetField(tif, TIFFTAG_COLORMAP,
|
||||
&redcolormap, &greencolormap, &bluecolormap);
|
||||
for (i = 0; i < numcolors; i++) {
|
||||
red[i] = (u_char) CVT(redcolormap[i]);
|
||||
green[i] = (u_char) CVT(greencolormap[i]);
|
||||
blue[i] = (u_char) CVT(bluecolormap[i]);
|
||||
}
|
||||
Colormap.map[0] = red;
|
||||
Colormap.map[1] = green;
|
||||
Colormap.map[2] = blue;
|
||||
break;
|
||||
case PHOTOMETRIC_MASK:
|
||||
error("%s: Don't know how to handle PHOTOMETRIC_MASK\n");
|
||||
break;
|
||||
case PHOTOMETRIC_DEPTH:
|
||||
error("%s: Don't know how to handle PHOTOMETRIC_DEPTH\n");
|
||||
break;
|
||||
default:
|
||||
error("%s: unknown photometric (cmap): %d\n", photometric);
|
||||
}
|
||||
}
|
||||
|
||||
buf = (u_char *) malloc(TIFFScanlineSize(tif));
|
||||
if (buf == NULL)
|
||||
error("%s: can't allocate memory for scanline buffer...\n", NULL);
|
||||
|
||||
for (row = 0; row < height; row++) {
|
||||
if (TIFFReadScanline(tif, buf, row, 0) < 0)
|
||||
error("%s: bad data read on line: %d\n", row);
|
||||
inp = buf;
|
||||
outp = (u_char *) mprd_addr(mpr_d(pix), 0, row);
|
||||
switch (photometric) {
|
||||
case PHOTOMETRIC_RGB:
|
||||
if (samplesperpixel == 4)
|
||||
for (col = 0; col < width; col++) {
|
||||
*outp++ = *inp++; /* Blue */
|
||||
*outp++ = *inp++; /* Green */
|
||||
*outp++ = *inp++; /* Red */
|
||||
inp++; /* skip alpha channel */
|
||||
}
|
||||
else
|
||||
for (col = 0; col < width; col++) {
|
||||
*outp++ = *inp++; /* Blue */
|
||||
*outp++ = *inp++; /* Green */
|
||||
*outp++ = *inp++; /* Red */
|
||||
}
|
||||
break;
|
||||
case PHOTOMETRIC_MINISWHITE:
|
||||
case PHOTOMETRIC_MINISBLACK:
|
||||
switch (bitspersample) {
|
||||
case 1:
|
||||
for (col = 0; col < ((width + 7) / 8); col++)
|
||||
*outp++ = *inp++;
|
||||
break;
|
||||
case 2:
|
||||
for (col = 0; col < ((width + 3) / 4); col++) {
|
||||
*outp++ = (*inp >> 6) & 3;
|
||||
*outp++ = (*inp >> 4) & 3;
|
||||
*outp++ = (*inp >> 2) & 3;
|
||||
*outp++ = *inp++ & 3;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
for (col = 0; col < width / 2; col++) {
|
||||
*outp++ = *inp >> 4;
|
||||
*outp++ = *inp++ & 0xf;
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
for (col = 0; col < width; col++)
|
||||
*outp++ = *inp++;
|
||||
break;
|
||||
default:
|
||||
error("%s: bad bits/sample: %d\n", bitspersample);
|
||||
}
|
||||
break;
|
||||
case PHOTOMETRIC_PALETTE:
|
||||
memcpy(outp, inp, width);
|
||||
break;
|
||||
default:
|
||||
error("%s: unknown photometric (write): %d\n", photometric);
|
||||
}
|
||||
}
|
||||
|
||||
free((char *) buf);
|
||||
|
||||
if (Verbose)
|
||||
fprintf(stderr, "done.\n");
|
||||
|
||||
if (outf == NULL || strcmp(outf, "Standard Output") == 0) {
|
||||
outf = "Standard Output";
|
||||
fp = stdout;
|
||||
} else {
|
||||
if (!(fp = fopen(outf, "w")))
|
||||
error("%s: %s couldn't be opened for writing.\n", outf);
|
||||
}
|
||||
|
||||
if (Verbose)
|
||||
fprintf(stderr, "Writing rasterfile in %s...", outf);
|
||||
|
||||
if (pr_dump(pix, fp, &Colormap, RT_BYTE_ENCODED, 0) == PIX_ERR)
|
||||
error("%s: error writing Sun Rasterfile: %s\n", outf);
|
||||
|
||||
if (Verbose)
|
||||
fprintf(stderr, "done.\n");
|
||||
|
||||
pr_destroy(pix);
|
||||
|
||||
if (fp != stdout)
|
||||
fclose(fp);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
Executable
+229
@@ -0,0 +1,229 @@
|
||||
$!========================================================================
|
||||
$!
|
||||
$! Name : MAKEVMS
|
||||
$!
|
||||
$! Purpose : Compile TIFF library
|
||||
$!
|
||||
$! Arguments : If P1 is DEBUG, compile with debug
|
||||
$!
|
||||
$! Created 1-DEC-1994 Karsten Spang
|
||||
$!
|
||||
$!========================================================================
|
||||
$ CURRENT_DIR=F$ENVIRONMENT("DEFAULT")
|
||||
$ ON CONTROL_Y THEN GOTO EXIT
|
||||
$ ON ERROR THEN GOTO EXIT
|
||||
$!
|
||||
$! Get hold on definitions
|
||||
$!
|
||||
$! Older versions of VMS may not recoqnize the "ARCH_NAME" keyword
|
||||
$! This happens only on VAX
|
||||
$!
|
||||
$ SAVE_MESS=F$ENVIRONMENT("MESSAGE")
|
||||
$ SET MESSAGE/NOID/NOFAC/NOSEV/NOTEXT
|
||||
$ ARCH=F$GETSYI("ARCH_NAME")
|
||||
$ SET MESSAGE 'SAVE_MESS'
|
||||
$ IF F$TYPE(ARCH).EQS."" THEN ARCH="VAX"
|
||||
$ ARCH=F$EDIT(ARCH,"UPCASE")
|
||||
$!
|
||||
$ DEFINE/NOLOG SYS SYS$LIBRARY
|
||||
$ THIS_FILE=F$ENVIRONMENT("PROCEDURE")
|
||||
$ PROC_NAME=F$PARSE(THIS_FILE,,,"NAME","SYNTAX_ONLY")
|
||||
$ THIS_DIR=F$PARSE(THIS_FILE,,,"DEVICE","SYNTAX_ONLY")+ -
|
||||
F$PARSE(THIS_FILE,,,"DIRECTORY","SYNTAX_ONLY")
|
||||
$ SET DEFAULT 'THIS_DIR'
|
||||
$ IF ARCH.EQS."ALPHA"
|
||||
$ THEN
|
||||
$ CONF_FP="HAVE_IEEEFP=1"
|
||||
$ ELSE
|
||||
$ CONF_FP="HAVE_IEEEFP=0"
|
||||
$ ENDIF
|
||||
$ CONF_LIBRARY="BSDTYPES,HAVE_MMAP"
|
||||
$ IF P1.EQS."DEBUG"
|
||||
$ THEN
|
||||
$ DEBUG_OPTIONS="/DEBUG/NOOPTIMIZE"
|
||||
$ CONF_LIBRARY=CONF_LIBRARY+",DEBUG"
|
||||
$ LINK_OPTIONS="/DEBUG"
|
||||
$ ELSE
|
||||
$ DEBUG_OPTIONS=""
|
||||
$ LINK_OPTIONS=""
|
||||
$ ENDIF
|
||||
$ DEFINES="/DEFINE=("+CONF_FP+","+CONF_LIBRARY+")"
|
||||
$ C_COMPILE="CC"+DEBUG_OPTIONS+DEFINES
|
||||
$ IF ARCH.EQS."ALPHA"
|
||||
$ THEN
|
||||
$!
|
||||
$! You may want a different floating point option
|
||||
$!
|
||||
$ C_COMPILE=C_COMPILE+ -
|
||||
"/FLOAT=IEEE_FLOAT/PREFIX_LIBRARY_ENTRIES=ALL_ENTRIES"
|
||||
$ ENDIF
|
||||
$!
|
||||
$ SOURCES="TIF_AUX,TIF_CLOSE,TIF_CODEC,TIF_COMPRESS,"+ -
|
||||
"TIF_DIR,TIF_DIRINFO,TIF_DIRREAD,TIF_DIRWRITE,"+ -
|
||||
"TIF_DUMPMODE,TIF_ERROR,TIF_FAX3,TIF_FAX3SM,TIF_FLUSH,TIF_GETIMAGE,"+ -
|
||||
-! "TIF_JPEG,"+ -
|
||||
"TIF_LZW,TIF_NEXT,TIF_OPEN,TIF_PACKBITS,TIF_PIXARLOG,TIF_PREDICT,"+ -
|
||||
"TIF_PRINT,TIF_READ,TIF_STRIP,TIF_SWAB,TIF_THUNDER,TIF_TILE,"+ -
|
||||
"TIF_VERSION,TIF_VMS,TIF_WARNING,TIF_WRITE"
|
||||
! ",TIF_ZIP"
|
||||
$ LIBFILE="TIFF"
|
||||
$ IF F$SEARCH(LIBFILE+".OLB").EQS."" THEN -
|
||||
LIBRARY/CREATE 'LIBFILE'
|
||||
$!
|
||||
$! Create the port library
|
||||
$!
|
||||
$ LIBPORT="[-.PORT]PORT"
|
||||
$ IF F$SEARCH(LIBPORT+".OLB") .EQS ""
|
||||
$ THEN
|
||||
$ WRITE SYS$OUTPUT "Creating PORT.OLB"
|
||||
$ LIBRARY/CREATE 'LIBPORT'
|
||||
$ CREATE DUM.C
|
||||
main(){getopt();strtoul();strcasecmp();}
|
||||
$ C_COMPILE DUM
|
||||
$ SET MESSAGE/ID/FAC/SEV/TEXT
|
||||
$ DEFINE/USER SYS$OUTPUT LINK.WARNINGS
|
||||
$ DEFINE/USER SYS$ERROR NLA0:
|
||||
$ IF ARCH.EQS."ALPHA"
|
||||
$ THEN
|
||||
$ LINK DUM
|
||||
$ ELSE
|
||||
$ LINK DUM,SYS$INPUT:/OPTIONS
|
||||
SYS$SHARE:VAXCRTL/SHARE
|
||||
$ ENDIF
|
||||
$ DELETE DUM.C;,DUM.OBJ;,DUM.EXE;
|
||||
$ SEARCH/OUT=MISSING.OBJECTS LINK.WARNINGS LINK-I-UDFSYM
|
||||
$ DELETE LINK.WARNINGS;
|
||||
$ OPEN/READ MISSING MISSING.OBJECTS
|
||||
$NEXTMIS:
|
||||
$ READ/END=NOMOREMIS MISSING LINE
|
||||
$ LINE=F$EDIT(LINE,"TRIM,COMPRESS,UPCASE")
|
||||
$ LINE=F$ELEMENT(1," ",LINE)
|
||||
$ IF LINE .EQS. " " THEN GOTO NEXTMIS
|
||||
$ WRITE SYS$OUTPUT " "+LINE
|
||||
$ C_COMPILE/OBJECT=[-.PORT]'LINE' [-.PORT]'LINE'
|
||||
$ LIBRARY 'LIBPORT' [-.PORT]'LINE'
|
||||
$ DELETE [-.PORT]'LINE'.OBJ;
|
||||
$ GOTO NEXTMIS
|
||||
$NOMOREMIS:
|
||||
$ CLOSE MISSING
|
||||
$ DELETE MISSING.OBJECTS;
|
||||
$ ENDIF
|
||||
$!
|
||||
$! Create VERSION.H
|
||||
$!
|
||||
$ IF F$SEARCH("VERSION.H").EQS.""
|
||||
$ THEN
|
||||
$ WRITE SYS$OUTPUT "Creating VERSION.H"
|
||||
$ IF F$SEARCH("MKVERSION.EXE").EQS.""
|
||||
$ THEN
|
||||
$ IF F$SEARCH("MKVERSION.OBJ").EQS.""
|
||||
$ THEN
|
||||
$ C_COMPILE MKVERSION
|
||||
$ ENDIF
|
||||
$ IF ARCH.EQS."ALPHA"
|
||||
$ THEN
|
||||
$ LINK MKVERSION,'LIBPORT'/LIBRARY
|
||||
$ ELSE
|
||||
$ LINK MKVERSION,'LIBPORT'/LIBRARY,SYS$INPUT:/OPTIONS
|
||||
SYS$SHARE:VAXCRTL/SHARE
|
||||
$ ENDIF
|
||||
$ DELETE MKVERSION.OBJ;*
|
||||
$ ENDIF
|
||||
$ MKVERSION:=$'THIS_DIR'MKVERSION
|
||||
$ MKVERSION -V [-]VERSION -A [-.DIST]TIFF.ALPHA VERSION.H
|
||||
$ DELETE MKVERSION.EXE;*
|
||||
$ ENDIF
|
||||
$!
|
||||
$! Create TIF_FAX3SM.C
|
||||
$!
|
||||
$ IF F$SEARCH("TIF_FAX3SM.C").EQS.""
|
||||
$ THEN
|
||||
$ WRITE SYS$OUTPUT "Creating FAX3SM.C"
|
||||
$ IF F$SEARCH("MKG3STATES.EXE").EQS.""
|
||||
$ THEN
|
||||
$ IF F$SEARCH("MKG3STATES.OBJ").EQS.""
|
||||
$ THEN
|
||||
$ C_COMPILE MKG3STATES
|
||||
$ ENDIF
|
||||
$ IF ARCH.EQS."ALPHA"
|
||||
$ THEN
|
||||
$ LINK MKG3STATES,'LIBPORT'/LIBRARY
|
||||
$ ELSE
|
||||
$ LINK MKG3STATES,'LIBPORT'/LIBRARY,SYS$INPUT:/OPTIONS
|
||||
SYS$SHARE:VAXCRTL/SHARE
|
||||
$ ENDIF
|
||||
$ DELETE MKG3STATES.OBJ;*
|
||||
$ ENDIF
|
||||
$ MKG3STATES:=$'THIS_DIR'MKG3STATES
|
||||
$ MKG3STATES -c const TIF_FAX3SM.C
|
||||
$ DELETE MKG3STATES.EXE;*
|
||||
$ ENDIF
|
||||
$!
|
||||
$! Loop over modules
|
||||
$!
|
||||
$ NUMBER=0
|
||||
$COMPILE_LOOP:
|
||||
$ FILE=F$ELEMENT(NUMBER,",",SOURCES)
|
||||
$ IF FILE.EQS."," THEN GOTO END_COMPILE
|
||||
$ C_FILE=F$PARSE(FILE,".C",,,"SYNTAX_ONLY")
|
||||
$ C_FILE=F$SEARCH(C_FILE)
|
||||
$ IF C_FILE.EQS.""
|
||||
$ THEN
|
||||
$ WRITE SYS$OUTPUT "Source file "+FILE+" not found"
|
||||
$ GOTO EXIT
|
||||
$ ENDIF
|
||||
$ C_DATE=F$CVTIME(F$FILE_ATTRIBUTES(C_FILE,"RDT"))
|
||||
$ OBJ_FILE=F$PARSE("",".OBJ",C_FILE,,"SYNTAX_ONLY")
|
||||
$ OBJ_FILE=F$EXTRACT(0,F$LOCATE(";",OBJ_FILE),OBJ_FILE)
|
||||
$ FOUND_OBJ_FILE=F$SEARCH(OBJ_FILE)
|
||||
$ IF FOUND_OBJ_FILE.EQS.""
|
||||
$ THEN
|
||||
$ OBJ_DATE=""
|
||||
$ ELSE
|
||||
$ OBJ_DATE=F$CVTIME(F$FILE_ATTRIBUTES(FOUND_OBJ_FILE,"CDT"))
|
||||
$ ENDIF
|
||||
$ IF OBJ_DATE.LTS.C_DATE
|
||||
$ THEN
|
||||
$ WRITE SYS$OUTPUT "Compiling "+FILE
|
||||
$ ON ERROR THEN CONTINUE
|
||||
$ C_COMPILE/OBJECT='OBJ_FILE' 'C_FILE'
|
||||
$ ON ERROR THEN GOTO EXIT
|
||||
$ LIBRARY 'LIBFILE' 'OBJ_FILE'
|
||||
$
|
||||
$ ENDIF
|
||||
$ NUMBER=NUMBER+1
|
||||
$ GOTO COMPILE_LOOP
|
||||
$END_COMPILE:
|
||||
$ IF ARCH.EQS."ALPHA"
|
||||
$ THEN
|
||||
$ OPT_FILE="TIFFSHRAXP"
|
||||
$ ELSE
|
||||
$ OPT_FILE="TIFFSHRVAX"
|
||||
$ FILE="TIFFVEC"
|
||||
$ MAR_FILE=F$PARSE(FILE,".MAR",,,"SYNTAX_ONLY")
|
||||
$ MAR_FILE=F$SEARCH(MAR_FILE)
|
||||
$ MAR_FILE=F$SEARCH("TIFFVEC.MAR")
|
||||
$ MAR_DATE=F$CVTIME(F$FILE_ATTRIBUTES(MAR_FILE,"RDT"))
|
||||
$ OBJ_FILE=F$PARSE("",".OBJ",MAR_FILE,,"SYNTAX_ONLY")
|
||||
$ OBJ_FILE=F$EXTRACT(0,F$LOCATE(";",OBJ_FILE),OBJ_FILE)
|
||||
$ FOUND_OBJ_FILE=F$SEARCH(OBJ_FILE)
|
||||
$ IF FOUND_OBJ_FILE.EQS.""
|
||||
$ THEN
|
||||
$ OBJ_DATE=""
|
||||
$ ELSE
|
||||
$ OBJ_DATE=F$CVTIME(F$FILE_ATTRIBUTES(FOUND_OBJ_FILE,"CDT"))
|
||||
$ ENDIF
|
||||
$ IF OBJ_DATE.LTS.MAR_DATE
|
||||
$ THEN
|
||||
$ WRITE SYS$OUTPUT "Compiling "+FILE
|
||||
$ MACRO 'MAR_FILE'
|
||||
$ LIBRARY 'LIBFILE' 'OBJ_FILE'
|
||||
$ PURGE 'OBJ_FILE'
|
||||
$ ENDIF
|
||||
$ ENDIF
|
||||
$ WRITE SYS$OUTPUT "Creating shareable library"
|
||||
$ LINK/SHAREABLE='THIS_DIR'TIFFSHR'LINK_OPTIONS' 'OPT_FILE'/OPTIONS
|
||||
$ PURGE/LOG TIFFSHR.EXE
|
||||
$EXIT:
|
||||
$ SET DEFAULT 'CURRENT_DIR'
|
||||
$ EXIT
|
||||
Executable
+131
@@ -0,0 +1,131 @@
|
||||
.TITLE TIFFVEC - Transfer vector for TIFF library
|
||||
.IDENT /LIBTIFF 3.4-002/
|
||||
;
|
||||
.PSECT TIFFVEC,EXE,NOWRT,PIC,SHR,GBL,QUAD
|
||||
;
|
||||
; Macro that defines one entry in the transfer vector
|
||||
;
|
||||
.MACRO VECTOR,NAME
|
||||
.ALIGN QUAD
|
||||
.TRANSFER NAME
|
||||
.MASK NAME
|
||||
JMP L^NAME+2
|
||||
.ENDM
|
||||
;
|
||||
; Here goes the definitions of all public functions in the library, plus
|
||||
; a few extra that are called by the tools.
|
||||
; The sequence MUST NOT be changed, otherwise you will have to relink
|
||||
; all applications. Add new functions at the end.
|
||||
;
|
||||
VECTOR TIFFCheckTile
|
||||
VECTOR TIFFClose
|
||||
VECTOR TIFFComputeStrip
|
||||
VECTOR TIFFComputeTile
|
||||
VECTOR TIFFCurrentDirectory
|
||||
VECTOR TIFFCurrentRow
|
||||
VECTOR TIFFCurrentStrip
|
||||
VECTOR TIFFCurrentTile
|
||||
VECTOR TIFFError
|
||||
VECTOR TIFFFdOpen
|
||||
VECTOR TIFFFileName
|
||||
VECTOR TIFFFileno
|
||||
VECTOR TIFFFlush
|
||||
VECTOR TIFFFlushData
|
||||
VECTOR TIFFGetField
|
||||
VECTOR TIFFGetFieldDefaulted
|
||||
;
|
||||
; TIFFGetFileSize was removed in version 3.2. It has been replaced by a
|
||||
; dummy value that makes the program abort with a privileged instruction
|
||||
; fault, in case an old program calls TIFFGetFileSize.
|
||||
;
|
||||
; VECTOR TIFFGetFileSize
|
||||
.QUAD 0
|
||||
;
|
||||
VECTOR TIFFGetMode
|
||||
VECTOR TIFFIsTiled
|
||||
;
|
||||
; TIFFModeCCITTFax3 gone in 3.3 beta 024
|
||||
; VECTOR TIFFModeCCITTFax3
|
||||
.QUAD 0
|
||||
VECTOR TIFFNumberOfStrips
|
||||
VECTOR TIFFNumberOfTiles
|
||||
VECTOR TIFFOpen
|
||||
VECTOR TIFFPrintDirectory
|
||||
VECTOR TIFFReadBufferSetup
|
||||
VECTOR TIFFReadDirectory
|
||||
VECTOR TIFFReadEncodedStrip
|
||||
VECTOR TIFFReadEncodedTile
|
||||
VECTOR TIFFReadRawStrip
|
||||
VECTOR TIFFReadRawTile
|
||||
VECTOR TIFFReadRGBAImage
|
||||
VECTOR TIFFReadScanline
|
||||
VECTOR TIFFReadTile
|
||||
VECTOR TIFFReverseBits
|
||||
VECTOR TIFFScanlineSize
|
||||
VECTOR TIFFSetDirectory
|
||||
VECTOR TIFFSetErrorHandler
|
||||
VECTOR TIFFSetField
|
||||
VECTOR TIFFSetWarningHandler
|
||||
VECTOR TIFFStripSize
|
||||
VECTOR TIFFSwabShort
|
||||
VECTOR TIFFSwabLong
|
||||
VECTOR TIFFSwabArrayOfShort
|
||||
VECTOR TIFFSwabArrayOfLong
|
||||
VECTOR TIFFTileRowSize
|
||||
VECTOR TIFFTileSize
|
||||
VECTOR TIFFVGetField
|
||||
VECTOR TIFFVGetFieldDefaulted
|
||||
VECTOR TIFFVSetField
|
||||
VECTOR TIFFWarning
|
||||
VECTOR TIFFWriteDirectory
|
||||
VECTOR TIFFWriteEncodedStrip
|
||||
VECTOR TIFFWriteEncodedTile
|
||||
VECTOR TIFFWriteRawStrip
|
||||
VECTOR TIFFWriteRawTile
|
||||
VECTOR TIFFWriteScanline
|
||||
VECTOR TIFFWriteTile
|
||||
;
|
||||
; New entries in version 3.1
|
||||
;
|
||||
VECTOR TIFFClientOpen
|
||||
VECTOR TIFFVStripSize ; For tiffcp
|
||||
;
|
||||
; New entries in version 3.2
|
||||
;
|
||||
VECTOR TIFFGetVersion
|
||||
VECTOR TIFFGetBitRevTable
|
||||
VECTOR _TIFFmalloc ; For fax2tiff
|
||||
;
|
||||
; New entries in version 3.3
|
||||
;
|
||||
VECTOR TIFFIsByteSwapped
|
||||
VECTOR TIFFSetWriteOffset
|
||||
;
|
||||
; New entries in version 3.3 beta 020
|
||||
;
|
||||
VECTOR TIFFSetSubDirectory
|
||||
VECTOR TIFFUnlinkDirectory
|
||||
;
|
||||
; New entries in version 3.3 beta 026 (for the tools)
|
||||
;
|
||||
VECTOR _TIFFfree
|
||||
VECTOR _TIFFrealloc
|
||||
VECTOR _TIFFmemset
|
||||
VECTOR _TIFFmemcpy
|
||||
VECTOR _TIFFmemcmp
|
||||
;
|
||||
; New entries in version 3.4 beta 002
|
||||
;
|
||||
VECTOR TIFFRasterScanlineSize
|
||||
VECTOR TIFFDefaultStripSize
|
||||
VECTOR TIFFDefaultTileSize
|
||||
VECTOR TIFFVTileSize ; not new, but omitted previously
|
||||
VECTOR TIFFSwabDouble
|
||||
VECTOR TIFFSwabArrayOfDouble
|
||||
VECTOR TIFFLastDirectory ; not new either
|
||||
;
|
||||
; New entries in version 3.4 beta 007 through 032
|
||||
;
|
||||
VECTOR TIFFCurrentDirOffset
|
||||
VECTOR TIFFWriteBufferSetup
|
||||
.END
|
||||
Executable
+113
@@ -0,0 +1,113 @@
|
||||
$!========================================================================
|
||||
$!
|
||||
$! Name : MAKEVMS
|
||||
$!
|
||||
$! Purpose : Compile TIFF tools
|
||||
$!
|
||||
$! Arguments :
|
||||
$!
|
||||
$! Created 6-DEC-1991 Karsten Spang
|
||||
$!
|
||||
$!========================================================================
|
||||
$ CURRENT_DIR=F$ENVIRONMENT("DEFAULT")
|
||||
$ ON CONTROL_Y THEN GOTO EXIT
|
||||
$ ON ERROR THEN GOTO EXIT
|
||||
$!
|
||||
$! Get hold on definitions
|
||||
$!
|
||||
$! Older versions of VMS may not recoqnize the "ARCH_NAME" keyword
|
||||
$! This happens only on VAX
|
||||
$!
|
||||
$ SAVE_MESS=F$ENVIRONMENT("MESSAGE")
|
||||
$ SET MESSAGE/NOID/NOFAC/NOSEV/NOTEXT
|
||||
$ ARCH=F$GETSYI("ARCH_NAME")
|
||||
$ SET MESSAGE 'SAVE_MESS'
|
||||
$ IF F$TYPE(ARCH).EQS."" THEN ARCH="VAX"
|
||||
$ ARCH=F$EDIT(ARCH,"UPCASE")
|
||||
$!
|
||||
$ DEFINE SYS SYS$LIBRARY
|
||||
$ THIS_FILE=F$ENVIRONMENT("PROCEDURE")
|
||||
$ PROC_NAME=F$PARSE(THIS_FILE,,,"NAME","SYNTAX_ONLY")
|
||||
$ THIS_DIR=F$PARSE(THIS_FILE,,,"DEVICE","SYNTAX_ONLY")+ -
|
||||
F$PARSE(THIS_FILE,,,"DIRECTORY","SYNTAX_ONLY")
|
||||
$ SET DEFAULT 'THIS_DIR'
|
||||
$ LIB_DIR=F$PARSE("[-.LIBTIFF]")
|
||||
$ LIB_DIR=F$PARSE(LIB_DIR,,,"DEVICE","SYNTAX_ONLY")+ -
|
||||
F$PARSE(LIB_DIR,,,"DIRECTORY","SYNTAX_ONLY")
|
||||
$ DEFINE TIFFSHR 'LIB_DIR'TIFFSHR
|
||||
$ CONF_LIBRARY="USE_VARARGS=0,USE_PROTOTYPES=1,USE_CONST=1,"+ -
|
||||
"BSDTYPES,MMAP_SUPPORT"
|
||||
$ IF ARCH.EQS."ALPHA"
|
||||
$ THEN
|
||||
$!
|
||||
$! You may want a different floating point option
|
||||
$!
|
||||
$ CONF_FP="HAVE_IEEEFP=1"
|
||||
$ ALPHA_OPT="/PREFIX_LIBRARY_ENTRIES=ALL_ENTRIES/FLOAT=IEEE_FLOAT"
|
||||
$ ELSE
|
||||
$ CONF_FP="HAVE_IEEEFP=0"
|
||||
$ ALPHA_OPT=""
|
||||
$ ENDIF
|
||||
$ DEFINES="/DEFINE=("+CONF_LIBRARY+","+CONF_FP+")"
|
||||
$ INCLUDES="/INCLUDE="+LIB_DIR
|
||||
$ IF P1.EQS."DEBUG"
|
||||
$ THEN
|
||||
$ DEBUG_OPTIONS="/DEBUG/NOOPTIMIZE"
|
||||
$ LINK_OPTIONS="/DEBUG"
|
||||
$ ELSE
|
||||
$ DEBUG_OPTIONS=""
|
||||
$ LINK_OPTIONS=""
|
||||
$ ENDIF
|
||||
$ C_COMPILE="CC"+DEBUG_OPTIONS+DEFINES+INCLUDES+ALPHA_OPT
|
||||
$ LIBPORT="[-.PORT]PORT"
|
||||
$!
|
||||
$ SOURCES="FAX2PS,FAX2TIFF,GIF2TIFF,PAL2RGB," + -
|
||||
"PPM2TIFF,RAS2TIFF,RGB2YCBCR," + -
|
||||
"THUMBNAIL,TIFF2BW," + -
|
||||
"TIFF2PS,TIFFCMP,TIFFCP,TIFFDITHER," + -
|
||||
"TIFFDUMP,TIFFINFO,TIFFMEDIAN,TIFFSPLIT,YCBCR"
|
||||
$!
|
||||
$! Loop over programs
|
||||
$!
|
||||
$ NUMBER=0
|
||||
$COMPILE_LOOP:
|
||||
$ FILE=F$ELEMENT(NUMBER,",",SOURCES)
|
||||
$ IF FILE.EQS."," THEN GOTO END_COMPILE
|
||||
$ C_FILE=F$PARSE(FILE,".C",,,"SYNTAX_ONLY")
|
||||
$ C_FILE=F$SEARCH(C_FILE)
|
||||
$ IF C_FILE.EQS.""
|
||||
$ THEN
|
||||
$ WRITE SYS$OUTPUT "Source file "+FILE+" not found"
|
||||
$ GOTO EXIT
|
||||
$ ENDIF
|
||||
$ C_DATE=F$CVTIME(F$FILE_ATTRIBUTES(C_FILE,"RDT"))
|
||||
$ EXE_FILE=F$PARSE("",".EXE",C_FILE,,"SYNTAX_ONLY")
|
||||
$ EXE_FILE=F$EXTRACT(0,F$LOCATE(";",EXE_FILE),EXE_FILE)
|
||||
$ FOUND_EXE_FILE=F$SEARCH(EXE_FILE)
|
||||
$ IF FOUND_EXE_FILE.EQS.""
|
||||
$ THEN
|
||||
$ EXE_DATE=""
|
||||
$ ELSE
|
||||
$ EXE_DATE=F$CVTIME(F$FILE_ATTRIBUTES(FOUND_EXE_FILE,"CDT"))
|
||||
$ ENDIF
|
||||
$ IF EXE_DATE.LTS.C_DATE
|
||||
$ THEN
|
||||
$ WRITE SYS$OUTPUT "Compiling "+FILE
|
||||
$ C_COMPILE 'FILE'
|
||||
$ IF ARCH.EQS."ALPHA"
|
||||
$ THEN
|
||||
$ LINK'LINK_OPTIONS' 'FILE','LIBPORT'/LIB,'LIB_DIR'TIFF/OPTIONS
|
||||
$ ELSE
|
||||
$ LINK'LINK_OPTIONS' 'FILE','LIBPORT'/LIB, -
|
||||
'LIB_DIR'TIFF/OPTIONS,SYS$INPUT:/OPTIONS
|
||||
SYS$SHARE:VAXCRTL/SHAREABLE
|
||||
$ ENDIF
|
||||
$ DELETE 'FILE'.OBJ;*
|
||||
$ PURGE 'EXE_FILE'
|
||||
$ ENDIF
|
||||
$ NUMBER=NUMBER+1
|
||||
$ GOTO COMPILE_LOOP
|
||||
$END_COMPILE:
|
||||
$EXIT:
|
||||
$ SET DEFAULT 'CURRENT_DIR'
|
||||
$ EXIT
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
dllshell.c ---------------------------------------------------------------
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#pragma argsused
|
||||
|
||||
/* DLL has an entry point LibMain || DllEntryPoint and an exit point WEP. */
|
||||
|
||||
#if defined(__FLAT__)
|
||||
|
||||
BOOL WINAPI DllEntryPoint(HINSTANCE hinstDll, DWORD fdwRreason,
|
||||
LPVOID plvReserved)
|
||||
{
|
||||
return 1; /* Indicate that the DLL was initialized successfully. */
|
||||
}
|
||||
|
||||
#else /* not flat model */
|
||||
|
||||
int FAR PASCAL LibMain(HINSTANCE hInstance, WORD wDataSegment, WORD wHeapSize,
|
||||
LPSTR lpszCmdLine)
|
||||
{
|
||||
/* The startup code for the DLL initializes the local heap(if there is one)
|
||||
with a call to LocalInit which locks the data segment. */
|
||||
|
||||
if ( wHeapSize != 0 )
|
||||
UnlockData( 0 );
|
||||
return 1; /* Indicate that the DLL was initialized successfully. */
|
||||
}
|
||||
|
||||
#endif /* __FLAT */
|
||||
|
||||
#pragma argsused
|
||||
|
||||
int FAR PASCAL WEP ( int bSystemExit )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
Executable
+72
@@ -0,0 +1,72 @@
|
||||
LIBRARY LIBTIFF
|
||||
EXETYPE WINDOWS
|
||||
CODE PRELOAD MOVEABLE DISCARDABLE
|
||||
DATA PRELOAD MOVEABLE MULTIPLE
|
||||
HEAPSIZE 4096
|
||||
STACKSIZE 8192
|
||||
EXPORTS
|
||||
_TIFFGetVersion @1
|
||||
_TIFFClose @2
|
||||
_TIFFFlush @3
|
||||
_TIFFFlushData @4
|
||||
_TIFFGetField @5
|
||||
_TIFFVGetField @6
|
||||
_TIFFGetFieldDefaulted @7
|
||||
_TIFFVGetFieldDefaulted @8
|
||||
_TIFFReadDirectory @9
|
||||
_TIFFScanlineSize @10
|
||||
_TIFFStripSize @11
|
||||
_TIFFVStripSize @12
|
||||
_TIFFTileRowSize @13
|
||||
_TIFFTileSize @14
|
||||
_TIFFVTileSize @15
|
||||
_TIFFFileno @16
|
||||
_TIFFGetMode @17
|
||||
_TIFFIsTiled @18
|
||||
_TIFFIsByteSwapped @19
|
||||
_TIFFCurrentRow @20
|
||||
_TIFFCurrentDirectory @21
|
||||
_TIFFCurrentStrip @22
|
||||
_TIFFCurrentTile @23
|
||||
_TIFFReadBufferSetup @24
|
||||
_TIFFLastDirectory @25
|
||||
_TIFFSetDirectory @26
|
||||
_TIFFSetSubDirectory @27
|
||||
_TIFFUnlinkDirectory @28
|
||||
_TIFFSetField @29
|
||||
_TIFFVSetField @30
|
||||
_TIFFWriteDirectory @31
|
||||
_TIFFReadScanline @32
|
||||
_TIFFWriteScanline @33
|
||||
_TIFFReadRGBAImage @34
|
||||
_TIFFOpen @35
|
||||
_TIFFFdOpen @36
|
||||
_TIFFClientOpen @37
|
||||
_TIFFFileName @38
|
||||
_TIFFError @39
|
||||
_TIFFWarning @40
|
||||
_TIFFSetErrorHandler @41
|
||||
_TIFFSetWarningHandler @42
|
||||
_TIFFComputeTile @43
|
||||
_TIFFCheckTile @44
|
||||
_TIFFNumberOfTiles @45
|
||||
_TIFFReadTile @46
|
||||
_TIFFWriteTile @47
|
||||
_TIFFComputeStrip @48
|
||||
_TIFFNumberOfStrips @49
|
||||
_TIFFReadEncodedStrip @50
|
||||
_TIFFReadRawStrip @51
|
||||
_TIFFReadEncodedTile @52
|
||||
_TIFFReadRawTile @53
|
||||
_TIFFWriteEncodedStrip @54
|
||||
_TIFFWriteRawStrip @55
|
||||
_TIFFWriteEncodedTile @56
|
||||
_TIFFWriteRawTile @57
|
||||
_TIFFSetWriteOffset @58
|
||||
_TIFFSwabShort @59
|
||||
_TIFFSwabLong @60
|
||||
_TIFFSwabArrayOfShort @61
|
||||
_TIFFSwabArrayOfLong @62
|
||||
_TIFFReverseBits @63
|
||||
_TIFFGetBitRevTable @64
|
||||
_TIFFModeCCITTFax3 @65
|
||||
Executable
+111
@@ -0,0 +1,111 @@
|
||||
This mail from Scott describes changes to the library that I have
|
||||
not made because I couldn't figure out exactly where they went.
|
||||
Anything not in this file has either been placed in the appropriate
|
||||
directory (e.g. libtiff/tif_win32.c) or applied to the current
|
||||
source code (e.g. libtiff/tiffiop.h).
|
||||
|
||||
Note that the Window NT/Window 95 support is untested; Scott's work
|
||||
was done with an earlier version of the library. Hopefully this'll
|
||||
get cleaned up soon.
|
||||
|
||||
Sam
|
||||
|
||||
Date: Fri, 14 Apr 95 17:01:42 EDT
|
||||
From: wagner@itek.com (scott wagner)
|
||||
Message-Id: <9504142101.AA00764@cyan.>
|
||||
To: sam@cthulhu.engr.sgi.com
|
||||
Subject: Re: Libtiff for Win32 (Windows NT / Windows 95)
|
||||
|
||||
Hi, Sam!
|
||||
|
||||
Enclosed are my libtiff for win32 pieces. They are in the form of 3 files
|
||||
(tif_w32.c, dllshell.c, and libtiff.def), and 2 diffs (for tiffiop.h and
|
||||
tiffio.h).
|
||||
|
||||
Hope this is not too difficult to separate!
|
||||
|
||||
Regards,
|
||||
Scott Wagner (wagner@itek.com)
|
||||
|
||||
tif_w32.c ---------------------------------------------------------------
|
||||
|
||||
tiffiop.h ---------------------------------------------------------------
|
||||
|
||||
tiffio.h ---------------------------------------------------------------
|
||||
38a39
|
||||
> #ifdef _TIFFIOP_
|
||||
39a41,43
|
||||
> #else
|
||||
> typedef void TIFF; /* Avoid ANSI undefined structure warning */
|
||||
> #endif
|
||||
66a71,75
|
||||
> #ifdef WIN32 /* WIN32 identifies Win32 compiles */
|
||||
> #pragma warn -sig /* Turn off Borland warn of long to short int convert */
|
||||
> #pragma warn -par /* Turn off Borland warn "Parameter x is never used" */
|
||||
> DECLARE_HANDLE(thandle_t); /* Win32 file handle */
|
||||
> #else /* if not WIN32_ */
|
||||
67a77
|
||||
> #endif /* defined WIN32 */
|
||||
|
||||
(Message tiff:1396)
|
||||
-- using template mhl.format --
|
||||
Date: Mon, 17 Apr 1995 07:51:03 EDT
|
||||
To: sam@cthulhu.engr.sgi.com
|
||||
|
||||
From: wagner@itek.com (scott wagner)
|
||||
Subject: Libtiff for Win32
|
||||
|
||||
Return-Path: sam@flake.asd.sgi.com
|
||||
Delivery-Date: Mon, 17 Apr 1995 05:36:50 PDT
|
||||
Return-Path: sam@flake.asd.sgi.com
|
||||
|
||||
Hello, Sam!
|
||||
|
||||
> ... libtiff for win32 pieces. They are in the form of 3 files
|
||||
> (tif_w32.c, dllshell.c, and libtiff.def), and 2 diffs (for tiffiop.h and
|
||||
> tiffio.h).
|
||||
>
|
||||
> I don't understand how these pieces fit together. Can you please explain
|
||||
> what dllshell.c and libtiff.def are for?
|
||||
|
||||
Sorry I was short on documentation here ... I was rushing to get home to
|
||||
dinner on Friday and the material for you was the last loose end I had to
|
||||
deal with. Excuses aside ...
|
||||
|
||||
The goal of the adaptation of libtiff to Win32 was to replace only one
|
||||
environment-specific code module and to make minimal changes to header
|
||||
files. tif_win32.c required one addition to tiffio.h (the
|
||||
DECLARE_HANDLE line, which is probably a better way to typedef thandle-t
|
||||
under Windows 3.1 as well); it also required the addition of pv_map_handle
|
||||
to the tiff structure and the conditional definition of the
|
||||
TIFFUnmapFileContents macro in tiffiop.h (this because Win32 uses a handle
|
||||
and a pointer in mapping memory, and I needed to save both).
|
||||
|
||||
Additionally, I made a general style change to tiffio.h. If tiffio.h is
|
||||
included by a client, which does not include tiffiop.h, then ANSI compilers
|
||||
warn about the typedef of TIFF to a non-existent structure. To avoid this,
|
||||
I changed the typedef of TIFF in this case to void.
|
||||
|
||||
I also made a style change in the tiff structure. All references to tif_fd
|
||||
in the library treat it as int, yet the tif_fd member itself is short. I
|
||||
changed this member to int and added the reserved member to maintain
|
||||
32-bit structure member alignment in a 32 bit environment. [ At cost of
|
||||
4 more bytes in an already bloated structure! :-) ] As long as fd's are
|
||||
less than 64k, the old member works; this is not the case in Win32, and is
|
||||
not generally a safe assumption.
|
||||
|
||||
The module dllshell.c and the file libtiff.def are not specific to the
|
||||
functionality of libtiff; they are used to make a Win32 dynamic link
|
||||
library, and would be best packaged with a Win32 makefile, which I have
|
||||
not yet perfected. I will, however, commit to a Borland and Microsoft C
|
||||
makefile for libtiff; perhaps these two could be combined with the
|
||||
makefile for the _next_ (!) release of libtiff when it is ready.
|
||||
|
||||
Once again, sorry for the confused message on Friday. I hope that at
|
||||
least tif_w32 and the tiffio.h and tiffiop.h diffs will be useful for
|
||||
this release.
|
||||
|
||||
Regards,
|
||||
Scott Wagner (wagner@itek.com)
|
||||
Itek Graphix
|
||||
Rochester, NY
|
||||
Executable
+134
@@ -0,0 +1,134 @@
|
||||
# $Header: /usr/people/sam/tiff/libtiff/RCS/Makefile.w95,v 1.2 1994/11/28
|
||||
06:13:31 sam Exp $
|
||||
#
|
||||
# Tag Image File Format Library
|
||||
#
|
||||
# Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler
|
||||
# Copyright (c) 1991, 1992 Silicon Graphics, Inc.
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and
|
||||
# its documentation for any purpose is hereby granted without fee, provided
|
||||
# that (i) the above copyright notices and this permission notice appear in
|
||||
# all copies of the software and related documentation, and (ii) the names of
|
||||
# Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
# publicity relating to the software without the specific, prior written
|
||||
# permission of Sam Leffler and Silicon Graphics.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
# OF THIS SOFTWARE.
|
||||
#
|
||||
# This Makefile is for use with microsoft nmake version 1.50 and
|
||||
# Microsoft 32-bit C/C++ Compiler 9.00
|
||||
#
|
||||
DESTDIR=.
|
||||
#
|
||||
IPATH= -I.
|
||||
CONF_LIBRARY=$(NULL)
|
||||
COPTS= -Oxa -DBSDTYPES -Zd
|
||||
CFLAGS= $(COPTS) $(CONF_LIBRARY)
|
||||
#
|
||||
INCS= tiff.h tiffio.h
|
||||
SRCS= tif_aux.c \
|
||||
tif_close.c \
|
||||
tif_codec.c \
|
||||
tif_compress.c \
|
||||
tif_dir.c \
|
||||
tif_dirinfo.c \
|
||||
tif_dirread.c \
|
||||
tif_dirwrite.c \
|
||||
tif_dumpmode.c \
|
||||
tif_error.c \
|
||||
tif_getimage.c \
|
||||
tif_jpeg.c \
|
||||
tif_flush.c \
|
||||
tif_lzw.c \
|
||||
tif_next.c \
|
||||
tif_open.c \
|
||||
tif_packbits.c \
|
||||
tif_predict \
|
||||
tif_print.c \
|
||||
tif_read.c \
|
||||
tif_swab.c \
|
||||
tif_strip.c \
|
||||
tif_thunder.c \
|
||||
tif_tile.c \
|
||||
tif_version.c \
|
||||
tif_warning.c \
|
||||
tif_write.c \
|
||||
tif_win32.c
|
||||
|
||||
|
||||
OBJS= tif_aux.obj \
|
||||
tif_close.obj \
|
||||
tif_codec.obj \
|
||||
tif_compress.obj \
|
||||
tif_dir.obj \
|
||||
tif_dirinfo.obj \
|
||||
tif_dirread.obj \
|
||||
tif_dirwrite.obj \
|
||||
tif_dumpmode.obj \
|
||||
tif_error.obj \
|
||||
tif_getimage.obj \
|
||||
tif_jpeg.obj \
|
||||
tif_flush.obj \
|
||||
tif_lzw.obj \
|
||||
tif_next.obj \
|
||||
tif_open.obj \
|
||||
tif_packbits.obj \
|
||||
tif_predict.obj \
|
||||
tif_print.obj \
|
||||
tif_read.obj \
|
||||
tif_swab.obj \
|
||||
tif_strip.obj \
|
||||
tif_thunder.obj \
|
||||
tif_tile.obj \
|
||||
tif_version.obj \
|
||||
tif_warning.obj \
|
||||
tif_write.obj \
|
||||
tif_win32.obj
|
||||
|
||||
|
||||
|
||||
ALL= libtiff.lib
|
||||
|
||||
all: $(ALL)
|
||||
|
||||
%.obj : %.c
|
||||
$(CC) $(CFLAGS) -c $*.c
|
||||
|
||||
|
||||
#.INCLUDE .IGNORE : depend
|
||||
|
||||
libtiff.lib: $(OBJS)
|
||||
- del libtiff.lib
|
||||
lib /OUT:libtiff.lib $(OBJS)
|
||||
|
||||
|
||||
#To include fax3 support, you need to modify mkg3states.c so it could run
|
||||
#under windows 95 or NT. This application make the file g3state.h.
|
||||
#after that, you have to add to the build script : tif_fax3.c and tif_fax3.obj
|
||||
#and define CCITT_SUPPORT in the file tifconf.h
|
||||
|
||||
#$(OBJS): tiffio.h tiff.h tiffcomp.h tiffiop.h tiffconf.h
|
||||
#tif_fax3.obj: tif_fax3.c g3states.h t4.h tif_fax3.h
|
||||
|
||||
#g3states.h: mkg3states.c t4.h
|
||||
# $(CC) $(CFLAGS) mkg3states.c
|
||||
# mkg3states -c > g3states.h
|
||||
|
||||
|
||||
clean:
|
||||
del *.obj
|
||||
del mkg3stat
|
||||
del g3states.h
|
||||
|
||||
tags: $(SRCS)
|
||||
$(CTAGS) $(SRCS)
|
||||
Executable
+50
@@ -0,0 +1,50 @@
|
||||
Date: 04 Dec 95 10:34:23 EST
|
||||
From: Philippe <100423.3705@compuserve.com>
|
||||
To: TIFF/sam Leffler <sam@cthulhu.engr.sgi.com>
|
||||
Subject: TIFF library and Windows 95
|
||||
Message-Id: <951204153422_100423.3705_BHG101-1@CompuServe.COM>
|
||||
|
||||
Sam,
|
||||
|
||||
First, let me thanks all of you how have worked
|
||||
on that great TIFF library !
|
||||
|
||||
Here is some information that may help someone.
|
||||
|
||||
I build the library under Windows 95 as a 32-bit library.
|
||||
The contribution of Scott Wagner (tif_win32.c) worked fine, but
|
||||
the makefile "makefile.msc" was unsable because it was
|
||||
written for DOS or Windows 3.1 and all the files names
|
||||
are limited to 8 characters.
|
||||
|
||||
Here is the makefile I used : makefile.w95
|
||||
|
||||
Also, I had to disable fax3 support because I wasn't able
|
||||
to build (as it is) the tool "mkg3states" to generate the include
|
||||
file "g3states.h".
|
||||
This source file must be modify to be build under Windows 95.
|
||||
|
||||
To build the library under Windows 95 with Visual C++ 2.0,
|
||||
I had to :
|
||||
|
||||
- undefine CCITT_SUPPORT in "tiffconf.h"
|
||||
|
||||
- create the file version.h with this line :
|
||||
#define VERSION "3.4beta024"
|
||||
|
||||
- build the makefile "makefile.w95"
|
||||
|
||||
I also join the source file "tif2dib.c" that I created,
|
||||
it contain the function LoadTIFFinDIB that load
|
||||
a TIFF file and build a memory DIB with it and return the
|
||||
HANDLE (HDIB) of the memory bloc containing this DIB.
|
||||
Since DIB is the "natural" bitmap format for Windows 3.1, 95 and NT,
|
||||
this function sould be usefull for some Windows 95 (or NT) developer.
|
||||
|
||||
|
||||
Sorry for my approximate english ...
|
||||
|
||||
Regards,
|
||||
|
||||
Philippe Tenenhaus 100423.3705@compuserve.com
|
||||
Paris
|
||||
Executable
+372
@@ -0,0 +1,372 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* Source file for Windows 95/Win32.
|
||||
*
|
||||
* The function LoadTIFFinDIB in this source file let you load
|
||||
* a TIFF file and build a memory DIB with it and return the
|
||||
* HANDLE (HDIB) of the memory bloc containing the DIB.
|
||||
*
|
||||
* Example :
|
||||
*
|
||||
* HDIB hDIB;
|
||||
* hDIB = LoadTIFFinDIB("sample.tif");
|
||||
*
|
||||
*
|
||||
* To build this source file you must include the TIFF library
|
||||
* in your project.
|
||||
*
|
||||
* 4/12/95 Philippe Tenenhaus 100423.3705@compuserve.com
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
|
||||
#include "tiffio.h"
|
||||
|
||||
#define HDIB HANDLE
|
||||
#define IS_WIN30_DIB(lpbi) ((*(LPDWORD)(lpbi)) == sizeof(BITMAPINFOHEADER))
|
||||
#define CVT(x) (((x) * 255L) / ((1L<<16)-1))
|
||||
|
||||
static HDIB CreateDIB(DWORD dwWidth, DWORD dwHeight, WORD wBitCount);
|
||||
static LPSTR FindDIBBits(LPSTR lpDIB);
|
||||
static WORD PaletteSize(LPSTR lpDIB);
|
||||
static WORD DIBNumColors(LPSTR lpDIB);
|
||||
static int checkcmap(int n, uint16* r, uint16* g, uint16* b);
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* HDIB LoadTIFFinDIB(LPSTR lpFileName)
|
||||
*
|
||||
* Parameter:
|
||||
*
|
||||
* LPSTR lpDIB - File name of a tiff imag
|
||||
*
|
||||
* Return Value:
|
||||
*
|
||||
* LPSTR - HANDLE of a DIB
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* This function load a TIFF file and build a memory DIB with it
|
||||
* and return the HANDLE (HDIB) of the memory bloc containing
|
||||
* the DIB.
|
||||
*
|
||||
* 4/12/95 Philippe Tenenhaus 100423.3705@compuserve.com
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
HDIB LoadTIFFinDIB(LPSTR lpFileName)
|
||||
{
|
||||
TIFF *tif;
|
||||
unsigned long imageLength;
|
||||
unsigned long imageWidth;
|
||||
unsigned int BitsPerSample;
|
||||
unsigned long LineSize;
|
||||
unsigned int SamplePerPixel;
|
||||
unsigned long RowsPerStrip;
|
||||
int PhotometricInterpretation;
|
||||
long nrow;
|
||||
unsigned long row;
|
||||
char *buf;
|
||||
LPBITMAPINFOHEADER lpDIB;
|
||||
HDIB hDIB;
|
||||
char *lpBits;
|
||||
HGLOBAL hStrip;
|
||||
int i,l;
|
||||
int Align;
|
||||
|
||||
tif = TIFFOpen(lpFileName, "r");
|
||||
|
||||
if (!tif)
|
||||
goto TiffOpenError;
|
||||
|
||||
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &imageWidth);
|
||||
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imageLength);
|
||||
TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &BitsPerSample);
|
||||
TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &RowsPerStrip);
|
||||
TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &RowsPerStrip);
|
||||
TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &PhotometricInterpretation);
|
||||
|
||||
LineSize = TIFFScanlineSize(tif); //Number of byte in ine line
|
||||
|
||||
SamplePerPixel = (int) (LineSize/imageWidth);
|
||||
|
||||
//Align = Number of byte to add at the end of each line of the DIB
|
||||
Align = 4 - (LineSize % 4);
|
||||
if (Align == 4) Align = 0;
|
||||
|
||||
|
||||
//Create a new DIB
|
||||
hDIB = CreateDIB((DWORD) imageWidth, (DWORD) imageLength, (WORD)
|
||||
(BitsPerSample*SamplePerPixel));
|
||||
lpDIB = (LPBITMAPINFOHEADER) GlobalLock(hDIB);
|
||||
if (!lpDIB)
|
||||
goto OutOfDIBMemory;
|
||||
|
||||
if (lpDIB)
|
||||
lpBits = FindDIBBits((LPSTR) lpDIB);
|
||||
|
||||
//In the tiff file the lines are save from up to down
|
||||
//In a DIB the lines must be save from down to up
|
||||
if (lpBits)
|
||||
{
|
||||
lpBits = FindDIBBits((LPSTR) lpDIB);
|
||||
lpBits+=((imageWidth*SamplePerPixel)+Align)*(imageLength-1);
|
||||
//now lpBits pointe on the bottom line
|
||||
|
||||
hStrip = GlobalAlloc(GHND,TIFFStripSize(tif));
|
||||
buf = GlobalLock(hStrip);
|
||||
|
||||
if (!buf)
|
||||
goto OutOfBufMemory;
|
||||
|
||||
//PhotometricInterpretation = 2 image is RGB
|
||||
//PhotometricInterpretation = 3 image have a color palette
|
||||
if (PhotometricInterpretation == 3)
|
||||
{
|
||||
uint16* red;
|
||||
uint16* green;
|
||||
uint16* blue;
|
||||
int16 i;
|
||||
LPBITMAPINFO lpbmi;
|
||||
int Palette16Bits;
|
||||
|
||||
TIFFGetField(tif, TIFFTAG_COLORMAP, &red, &green, &blue);
|
||||
|
||||
//Is the palette 16 or 8 bits ?
|
||||
if (checkcmap(1<<BitsPerSample, red, green, blue) == 16)
|
||||
Palette16Bits = TRUE;
|
||||
else
|
||||
Palette16Bits = FALSE;
|
||||
|
||||
lpbmi = (LPBITMAPINFO)lpDIB;
|
||||
|
||||
//load the palette in the DIB
|
||||
for (i = (1<<BitsPerSample)-1; i >= 0; i--)
|
||||
{
|
||||
if (Palette16Bits)
|
||||
{
|
||||
lpbmi->bmiColors[i].rgbRed =(BYTE) CVT(red[i]);
|
||||
lpbmi->bmiColors[i].rgbGreen = (BYTE) CVT(green[i]);
|
||||
lpbmi->bmiColors[i].rgbBlue = (BYTE) CVT(blue[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
lpbmi->bmiColors[i].rgbRed = (BYTE) red[i];
|
||||
lpbmi->bmiColors[i].rgbGreen = (BYTE) green[i];
|
||||
lpbmi->bmiColors[i].rgbBlue = (BYTE) blue[i];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//read the tiff lines and save them in the DIB
|
||||
//with RGB mode, we have to change the order of the 3 samples RGB
|
||||
<=> BGR
|
||||
for (row = 0; row < imageLength; row += RowsPerStrip)
|
||||
{
|
||||
nrow = (row + RowsPerStrip > imageLength ? imageLength - row :
|
||||
RowsPerStrip);
|
||||
if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 0),
|
||||
buf, nrow*LineSize)==-1)
|
||||
{
|
||||
goto TiffReadError;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (l = 0; l < nrow; l++)
|
||||
{
|
||||
if (SamplePerPixel == 3)
|
||||
for (i=0;i< (int) (imageWidth);i++)
|
||||
{
|
||||
lpBits[i*SamplePerPixel+0]=buf[l*LineSize+i*Sample
|
||||
PerPixel+2];
|
||||
lpBits[i*SamplePerPixel+1]=buf[l*LineSize+i*Sample
|
||||
PerPixel+1];
|
||||
lpBits[i*SamplePerPixel+2]=buf[l*LineSize+i*Sample
|
||||
PerPixel+0];
|
||||
}
|
||||
else
|
||||
memcpy(lpBits, &buf[(int) (l*LineSize)], (int)
|
||||
imageWidth*SamplePerPixel);
|
||||
|
||||
lpBits-=imageWidth*SamplePerPixel+Align;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
GlobalUnlock(hStrip);
|
||||
GlobalFree(hStrip);
|
||||
GlobalUnlock(hDIB);
|
||||
TIFFClose(tif);
|
||||
}
|
||||
|
||||
return hDIB;
|
||||
|
||||
OutOfBufMemory:
|
||||
|
||||
TiffReadError:
|
||||
GlobalUnlock(hDIB);
|
||||
GlobalFree(hStrip);
|
||||
OutOfDIBMemory:
|
||||
TIFFClose(tif);
|
||||
TiffOpenError:
|
||||
return (HANDLE) 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
static int checkcmap(int n, uint16* r, uint16* g, uint16* b)
|
||||
{
|
||||
while (n-- > 0)
|
||||
if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256)
|
||||
return (16);
|
||||
|
||||
return (8);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* All the following functions were created by microsoft, they are
|
||||
* parts of the sample project "wincap" given with the SDK Win32.
|
||||
*
|
||||
* Microsoft says that :
|
||||
*
|
||||
* You have a royalty-free right to use, modify, reproduce and
|
||||
* distribute the Sample Files (and/or any modified version) in
|
||||
* any way you find useful, provided that you agree that
|
||||
* Microsoft has no warranty obligations or liability for any
|
||||
* Sample Application Files which are modified.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
HDIB CreateDIB(DWORD dwWidth, DWORD dwHeight, WORD wBitCount)
|
||||
{
|
||||
BITMAPINFOHEADER bi; // bitmap header
|
||||
LPBITMAPINFOHEADER lpbi; // pointer to BITMAPINFOHEADER
|
||||
DWORD dwLen; // size of memory block
|
||||
HDIB hDIB;
|
||||
DWORD dwBytesPerLine; // Number of bytes per scanline
|
||||
|
||||
|
||||
// Make sure bits per pixel is valid
|
||||
if (wBitCount <= 1)
|
||||
wBitCount = 1;
|
||||
else if (wBitCount <= 4)
|
||||
wBitCount = 4;
|
||||
else if (wBitCount <= 8)
|
||||
wBitCount = 8;
|
||||
else if (wBitCount <= 24)
|
||||
wBitCount = 24;
|
||||
else
|
||||
wBitCount = 4; // set default value to 4 if parameter is bogus
|
||||
|
||||
// initialize BITMAPINFOHEADER
|
||||
bi.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bi.biWidth = dwWidth; // fill in width from parameter
|
||||
bi.biHeight = dwHeight; // fill in height from parameter
|
||||
bi.biPlanes = 1; // must be 1
|
||||
bi.biBitCount = wBitCount; // from parameter
|
||||
bi.biCompression = BI_RGB;
|
||||
bi.biSizeImage = (dwWidth*dwHeight*wBitCount)/8; //0; // 0's here
|
||||
mean "default"
|
||||
bi.biXPelsPerMeter = 2834; //0;
|
||||
bi.biYPelsPerMeter = 2834; //0;
|
||||
bi.biClrUsed = 0;
|
||||
bi.biClrImportant = 0;
|
||||
|
||||
// calculate size of memory block required to store the DIB. This
|
||||
// block should be big enough to hold the BITMAPINFOHEADER, the color
|
||||
// table, and the bits
|
||||
|
||||
dwBytesPerLine = (((wBitCount * dwWidth) + 31) / 32 * 4);
|
||||
dwLen = bi.biSize + PaletteSize((LPSTR)&bi) + (dwBytesPerLine * dwHeight);
|
||||
|
||||
// alloc memory block to store our bitmap
|
||||
hDIB = GlobalAlloc(GHND, dwLen);
|
||||
|
||||
// major bummer if we couldn't get memory block
|
||||
if (!hDIB)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// lock memory and get pointer to it
|
||||
lpbi = (VOID FAR *)GlobalLock(hDIB);
|
||||
|
||||
// use our bitmap info structure to fill in first part of
|
||||
// our DIB with the BITMAPINFOHEADER
|
||||
*lpbi = bi;
|
||||
|
||||
// Since we don't know what the colortable and bits should contain,
|
||||
// just leave these blank. Unlock the DIB and return the HDIB.
|
||||
|
||||
GlobalUnlock(hDIB);
|
||||
|
||||
/* return handle to the DIB */
|
||||
return hDIB;
|
||||
}
|
||||
|
||||
|
||||
LPSTR FAR FindDIBBits(LPSTR lpDIB)
|
||||
{
|
||||
return (lpDIB + *(LPDWORD)lpDIB + PaletteSize(lpDIB));
|
||||
}
|
||||
|
||||
|
||||
WORD FAR PaletteSize(LPSTR lpDIB)
|
||||
{
|
||||
/* calculate the size required by the palette */
|
||||
if (IS_WIN30_DIB (lpDIB))
|
||||
return (DIBNumColors(lpDIB) * sizeof(RGBQUAD));
|
||||
else
|
||||
return (DIBNumColors(lpDIB) * sizeof(RGBTRIPLE));
|
||||
}
|
||||
|
||||
|
||||
WORD DIBNumColors(LPSTR lpDIB)
|
||||
{
|
||||
WORD wBitCount; // DIB bit count
|
||||
|
||||
/* If this is a Windows-style DIB, the number of colors in the
|
||||
* color table can be less than the number of bits per pixel
|
||||
* allows for (i.e. lpbi->biClrUsed can be set to some value).
|
||||
* If this is the case, return the appropriate value.
|
||||
*/
|
||||
|
||||
if (IS_WIN30_DIB(lpDIB))
|
||||
{
|
||||
DWORD dwClrUsed;
|
||||
|
||||
dwClrUsed = ((LPBITMAPINFOHEADER)lpDIB)->biClrUsed;
|
||||
if (dwClrUsed)
|
||||
return (WORD)dwClrUsed;
|
||||
}
|
||||
|
||||
/* Calculate the number of colors in the color table based on
|
||||
* the number of bits per pixel for the DIB.
|
||||
*/
|
||||
if (IS_WIN30_DIB(lpDIB))
|
||||
wBitCount = ((LPBITMAPINFOHEADER)lpDIB)->biBitCount;
|
||||
else
|
||||
wBitCount = ((LPBITMAPCOREHEADER)lpDIB)->bcBitCount;
|
||||
|
||||
/* return number of colors based on bits per pixel */
|
||||
switch (wBitCount)
|
||||
{
|
||||
case 1:
|
||||
return 2;
|
||||
|
||||
case 4:
|
||||
return 16;
|
||||
|
||||
case 8:
|
||||
return 256;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Executable
+182
@@ -0,0 +1,182 @@
|
||||
Date: Fri, 18 Apr 1997 09:25:09 EDT
|
||||
To: "'sam@cthulhu.engr.sgi.com'" <sam@cthulhu.engr.sgi.com>
|
||||
cc: "'tiff@sgi.engr.sgi.com'" <tiff@sgi.engr.sgi.com>
|
||||
|
||||
From: xingong chang <xingong@feith1.FEITH.COM>
|
||||
Subject: Contribution: libtiff for Windows-nt console applications
|
||||
|
||||
Return-Path: xingong@feith1.FEITH.COM
|
||||
Delivery-Date: Fri, 18 Apr 1997 06:37:38 -0700
|
||||
Return-Path: xingong@feith1.FEITH.COM
|
||||
MIME-Version: 1.0
|
||||
|
||||
Hi,
|
||||
I built the libtiff under WINNT 4.0 as a 32-bit library for pure
|
||||
console applications. I made the makefile.nt based on Philippe
|
||||
Tenenhaus' makefile.w95 file. Since I want my stuff to be a pure
|
||||
console application running on WinNT, Dave Dyer's makefile for WINNT is
|
||||
not good for me since it is for Windows applications.
|
||||
|
||||
I used the tif_msdos.c file instead of the tif_win32.c in the $(OBJS)
|
||||
list because tif_win32.c is not a pure console program, it includes
|
||||
some function calls such as MessageBox etc which requires windows
|
||||
application library ($winslib as defined in <ntwin32.mak>).
|
||||
|
||||
unlike Philippe Tenenhaus' makefile.w95 file, this makefile.nt does
|
||||
support fax3 stuff. And to make the mkg3states.exe,the getopt.obj is
|
||||
needed. "getopt" package is ATT public domain source for getopt(3).
|
||||
Also you need to inlcude the g3states.h in tif_fax.c fileand modify the
|
||||
tif_fax3.h to delete the external declaration of FFFaxMainTable,
|
||||
TIFFFaxWhileTable and TIFFFaxBlackTable
|
||||
|
||||
|
||||
libtiff version: TIFFLIB_VERSION 19960307
|
||||
|
||||
Hardware you are using: i386
|
||||
|
||||
Operating system you are using: Windows NT 4.0
|
||||
|
||||
C compiler : Microsoft Visual C++ 4.1
|
||||
|
||||
NMAKE : Microsoft nmake 1.61
|
||||
|
||||
|
||||
Here is the makefile.nt I used:
|
||||
---------------------------------------------------------
|
||||
|
||||
# makefile.nt for the tiff library
|
||||
# Tag Image File Format Library
|
||||
#
|
||||
# Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler
|
||||
# Copyright (c) 1991, 1992 Silicon Graphics, Inc.
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and
|
||||
# its documentation for any purpose is hereby granted without fee, provided
|
||||
# that (i) the above copyright notices and this permission notice appear in
|
||||
# all copies of the software and related documentation, and (ii) the names of
|
||||
# Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
# publicity relating to the software without the specific, prior written
|
||||
# permission of Sam Leffler and Silicon Graphics.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
# OF THIS SOFTWARE.
|
||||
#
|
||||
# This Makefile is for use with microsoft nmake version 1.61
|
||||
#
|
||||
|
||||
!include <ntwin32.mak>
|
||||
|
||||
DEFS = -DBSDTYPES -DO_RDONLY=S_IREAD -DO_RDWR=S_IWRITE
|
||||
|
||||
INCS= tiff.h tiffio.h
|
||||
SRCS= tif_aux.c \
|
||||
tif_close.c \
|
||||
tif_codec.c \
|
||||
tif_compress.c \
|
||||
tif_dir.c \
|
||||
tif_dirinfo.c \
|
||||
tif_dirread.c \
|
||||
tif_dirwrite.c \
|
||||
tif_dumpmode.c \
|
||||
tif_error.c \
|
||||
tif_getimage.c \
|
||||
tif_jpeg.c \
|
||||
tif_flush.c \
|
||||
tif_lzw.c \
|
||||
tif_next.c \
|
||||
tif_open.c \
|
||||
tif_packbits.c \
|
||||
tif_predict \
|
||||
tif_print.c \
|
||||
tif_read.c \
|
||||
tif_swab.c \
|
||||
tif_strip.c \
|
||||
tif_thunder.c \
|
||||
tif_tile.c \
|
||||
tif_version.c \
|
||||
tif_warning.c \
|
||||
tif_write.c \
|
||||
tif_msdos.c \
|
||||
tif_fax3.c
|
||||
|
||||
|
||||
OBJS= tif_aux.obj \
|
||||
tif_close.obj \
|
||||
tif_codec.obj \
|
||||
tif_compress.obj \
|
||||
tif_dir.obj \
|
||||
tif_dirinfo.obj \
|
||||
tif_dirread.obj \
|
||||
tif_dirwrite.obj \
|
||||
tif_dumpmode.obj \
|
||||
tif_error.obj \
|
||||
tif_getimage.obj \
|
||||
tif_jpeg.obj \
|
||||
tif_flush.obj \
|
||||
tif_lzw.obj \
|
||||
tif_next.obj \
|
||||
tif_open.obj \
|
||||
tif_packbits.obj \
|
||||
tif_predict.obj \
|
||||
tif_print.obj \
|
||||
tif_read.obj \
|
||||
tif_swab.obj \
|
||||
tif_strip.obj \
|
||||
tif_thunder.obj \
|
||||
tif_tile.obj \
|
||||
tif_version.obj \
|
||||
tif_warning.obj \
|
||||
tif_write.obj \
|
||||
tif_msdos.obj \
|
||||
tif_fax3.obj
|
||||
|
||||
#To make the mkg3states.exe,the getopt.obj is needed. getopt package is
|
||||
# ATT public domain source for getopt(3).
|
||||
EXTRA_OBJS = getopt.obj
|
||||
|
||||
all: libtiff.lib
|
||||
|
||||
libtiff.lib: $(OBJS)
|
||||
del libtiff.lib
|
||||
lib -out:libtiff.lib $(OBJS)
|
||||
|
||||
.c.obj:
|
||||
$(cc) $(DEFS) $(cdebug) $(cflags) $(cvarsmt) $*.c
|
||||
|
||||
|
||||
#To include fax3 support, we did this modification
|
||||
#add to the build script : tif_fax3.c and tif_fax3.obj
|
||||
#define CCITT_SUPPORT in the file tifconf.h
|
||||
#inlcude the g3states.h in tif_fax.c file
|
||||
#modify the tif_fax3.h to delete the TIFFFaxMainTable,TIFFFaxWhileTable
|
||||
# TIFFFaxBlackTable etc external declaration
|
||||
#mkg3states.exe without any command line options will produce the g3states.h
|
||||
|
||||
$(OBJS): tiffio.h tiff.h tiffcomp.h tiffiop.h tiffconf.h
|
||||
tif_fax3.obj: tif_fax3.c g3states.h t4.h tif_fax3.h
|
||||
|
||||
g3states.h: mkg3states.obj t4.h
|
||||
$(link) $(ldebug) $(conslflags) -out:mkg3states.exe mkg3states.obj \
|
||||
$(EXTRA_OBJS)
|
||||
mkg3states.exe
|
||||
|
||||
clean:
|
||||
del *.obj
|
||||
del g3states.h
|
||||
|
||||
clobber:
|
||||
del libtiff.lib
|
||||
del *.obj
|
||||
del g3states.h
|
||||
|
||||
|
||||
|
||||
[60;1H[K
|
||||
Executable
+1046
File diff suppressed because it is too large
Load Diff
Executable
+72
@@ -0,0 +1,72 @@
|
||||
LIBRARY libtiff
|
||||
EXPORTS TIFFOpen
|
||||
TIFFGetVersion
|
||||
TIFFClose
|
||||
TIFFFlush
|
||||
TIFFFlushData
|
||||
TIFFFlushdata1
|
||||
TIFFGetField
|
||||
TIFFVGetField
|
||||
TIFFGetFieldDefaulted
|
||||
TIFFVGetFieldDefaulted
|
||||
TIFFReadDirectory
|
||||
TIFFScanlineSize
|
||||
TIFFStripSize
|
||||
TIFFVStripSize
|
||||
TIFFTileRowSize
|
||||
TIFFTileSize
|
||||
TIFFVTileSize
|
||||
TIFFFileno
|
||||
TIFFGetMode
|
||||
TIFFIsTiled
|
||||
TIFFIsByteSwapped
|
||||
TIFFCurrentRow
|
||||
TIFFCurrentDirectory
|
||||
TIFFCurrentStrip
|
||||
TIFFCurrentTile
|
||||
TIFFReadBufferSetup
|
||||
TIFFLastDirectory
|
||||
TIFFSetDirectory
|
||||
TIFFSetSubDirectory
|
||||
TIFFUnlinkDirectory
|
||||
TIFFSetField
|
||||
TIFFVSetField
|
||||
TIFFWriteDirectory
|
||||
TIFFPrintDirectory
|
||||
TIFFReadScanline
|
||||
TIFFWriteScanline
|
||||
TIFFReadRGBAImage
|
||||
TIFFPrintDirectory
|
||||
TIFFReadScanline
|
||||
TIFFWriteScanline
|
||||
TIFFReadRGBAImage
|
||||
TIFFFdOpen
|
||||
TIFFClientOpen
|
||||
TIFFFileName
|
||||
TIFFError
|
||||
TIFFWarning
|
||||
TIFFSetErrorHandler
|
||||
TIFFSetWarningHandler
|
||||
TIFFComputeTile
|
||||
TIFFCheckTile
|
||||
TIFFNumberOfTiles
|
||||
TIFFReadTile
|
||||
TIFFWriteTile
|
||||
TIFFComputeStrip
|
||||
TIFFNumberOfStrips
|
||||
TIFFReadEncodedStrip
|
||||
TIFFReadRawStrip
|
||||
TIFFReadEncodedTile
|
||||
TIFFReadRawTile
|
||||
TIFFWriteEncodedStrip
|
||||
TIFFWriteRawStrip
|
||||
TIFFWriteEncodedTile
|
||||
TIFFWriteRawTile
|
||||
TIFFSetWriteOffset
|
||||
TIFFSwabShort
|
||||
TIFFSwabLong
|
||||
TIFFSwabArrayOfShort
|
||||
TIFFSwabArrayOfLong
|
||||
TIFFReverseBits
|
||||
TIFFGetBitRevTable
|
||||
TIFFModeCCITTFax3
|
||||
Executable
+1947
File diff suppressed because it is too large
Load Diff
Executable
BIN
Binary file not shown.
Executable
+26
@@ -0,0 +1,26 @@
|
||||
Date: Fri, 10 Nov 1995 13:02:33 -0800
|
||||
Message-Id: <199511102102.NAA07993@lido>
|
||||
To: tiff@sgi.engr.sgi.com
|
||||
Subject: Contribution: libtiff for Windows-nt
|
||||
Reply-To: Dave Dyer <ddyer@triple-i.com>
|
||||
Sender: owner-tiff@sgi.engr.sgi.com
|
||||
Precedence: bulk
|
||||
|
||||
|
||||
Since I needed it, and the support for windows-nt versions of libtiff
|
||||
is sketchy at best, I packaged up my port of libtiff v3.4beta024
|
||||
to windows-nt.
|
||||
|
||||
ftp://torii.triple-i.com/pub/ddyer/libtiff.tar.gz
|
||||
|
||||
this contains "libtiff.mak", a makefile for microsoft visual c++,
|
||||
a couple of hand-built .h and .c files (corresponding to those which
|
||||
are automatically constructed by unix makefiles) and static libraries
|
||||
compiled for intel and dec alpha.
|
||||
|
||||
As customary, I make no claims regarding the completeness or
|
||||
correctness of these libraries, and accept no responsibily for any
|
||||
mishaps you may have as a result of using them. They work for me.
|
||||
|
||||
I hope Sam will copy and incorporate this into the "contrib" section
|
||||
of the next libtiff release.
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
#define VERSION "LIBTIFF, Version 3.4beta024\nCopyright (c) 1988-1995 Sam Leffler\nCopyright (c) 1991-1995 Silicon Graphics, Inc."
|
||||
Reference in New Issue
Block a user