Fixing missing files from repo.

This commit is contained in:
Scott Duensing 2023-11-08 17:57:52 -06:00
parent 6802761e49
commit 42f2b7003c
781 changed files with 123374 additions and 118335 deletions

1
.gitattributes vendored
View file

@ -23,6 +23,7 @@
# Other Binary
#
*.exe filter=lfs diff=lfs merge=lfs -text
*.dll filter=lfs diff=lfs merge=lfs -text
*.dat filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text

2
.gitignore vendored
View file

@ -1,5 +1,5 @@
*~
**/build/
**/.builddir/
**/.git-hidden/
**/.github/
cmake-build-debug/

View file

@ -34,38 +34,6 @@ subdirectory that was generated during installation. (You really shouldn't
be changing things in there!) Delete the Singe subdirectory and run the new
Singe binary with no command line arguments to generate the new files.
Games are available on the Internet Archive:
Gun Games:
- https://archive.org/details/singe-actionmax
- https://archive.org/details/singe-crime-patrol
- https://archive.org/details/singe-crime-patrol-2
- https://archive.org/details/singe-last-bounty-hunter
- https://archive.org/details/singe-mad-dog-mccree
- https://archive.org/details/singe-mad-dog-mccree-2
- https://archive.org/details/singe-platoon
- https://archive.org/details/singe-space-pirates
- https://archive.org/details/singe-who-shot-johnny-rock
QTE Games:
- https://archive.org/details/singe-cliff-hanger
- https://archive.org/details/singe-conan
- https://archive.org/details/singe-daitarn-3
- https://archive.org/details/singe-dl-2e
- https://archive.org/details/singe-dl-tv
- https://archive.org/details/singe-dragon-english
- https://archive.org/details/singe-dragon-italian
- https://archive.org/details/singe-fire-and-ice
- https://archive.org/details/singe-jack-english
- https://archive.org/details/singe-jack-italian
- https://archive.org/details/singe-puss-in-boots-english
- https://archive.org/details/singe-puss-in-boots-italian
- https://archive.org/details/singe-time-traveler
- https://archive.org/details/singe-timegal
- https://archive.org/details/singe-titan-ae
Know of a game we don't have listed? Let us know!
COMMAND LINE
============

View file

@ -21,6 +21,7 @@
G_BUILDROOT=${PWD}
G_BUILDDIR=.builddir
G_TARGET=
G_GENERATED=
@ -86,7 +87,7 @@ function buildAll() {
esac
G_TARGET=${G_BUILDROOT}/build/${OS}/${ARCH}
G_TARGET=${G_BUILDROOT}/${G_BUILDDIR}/${OS}/${ARCH}
G_GENERATED=${G_TARGET}/generated
TOOLCHAIN=${G_BUILDROOT}/../toolchains/cmake/${TRIPLE}.cmake
COMMON="-DCMAKE_INSTALL_PREFIX=${G_TARGET} -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN}"
@ -285,9 +286,9 @@ UNUSED
function clearAndEnterBuild() {
[[ -d build ]] && rm -rf build
mkdir -p build
cd build
[[ -d ${G_BUILDDIR} ]] && rm -rf ${G_BUILDDIR}
mkdir -p ${G_BUILDDIR}
cd ${G_BUILDDIR}
}
@ -409,8 +410,8 @@ function outputLicense() {
#buildAll linux x86
#buildAll linux x86_64
buildAll macos aarch64
buildAll linux x86_64
#buildAll macos aarch64
#buildAll macos x86 #***TODO*** Needs older SDL2
#buildAll macos x86_64 #***TODO*** Needs older SDL2
#buildAll windows x86

View file

@ -1,32 +0,0 @@
[submodule "external/jpeg"]
path = external/jpeg
url = https://github.com/libsdl-org/jpeg.git
branch = v9e-SDL
[submodule "external/libpng"]
path = external/libpng
url = https://github.com/libsdl-org/libpng.git
branch = v1.6.40-SDL
[submodule "external/libwebp"]
path = external/libwebp
url = https://github.com/libsdl-org/libwebp.git
branch = 1.0.3-SDL
[submodule "external/libtiff"]
path = external/libtiff
url = https://github.com/libsdl-org/libtiff.git
branch = v4.5.1-SDL
[submodule "external/zlib"]
path = external/zlib
url = https://github.com/libsdl-org/zlib.git
branch = v1.3-SDL
[submodule "external/libjxl"]
path = external/libjxl
url = https://github.com/libsdl-org/libjxl.git
branch = v0.6.1-SDL
[submodule "external/libavif"]
path = external/libavif
url = https://github.com/libsdl-org/libavif.git
branch = v1.0.1-SDL
[submodule "external/dav1d"]
path = external/dav1d
url = https://github.com/libsdl-org/dav1d.git
branch = 1.2.1-SDL

View file

@ -619,8 +619,6 @@ if(SDL2IMAGE_TIF)
target_compile_definitions(SDL2_image PRIVATE LOAD_TIF)
if(SDL2IMAGE_TIF_VENDORED)
message(STATUS "${PROJECT_NAME}: Using vendored libtiff")
# tiff-tests variable is used by vendored libtiff
set(tiff-tests OFF CACHE BOOL "libtiff: tests" FORCE)
# jpeg variable is used by vendored libtiff
set(jpeg OFF CACHE BOOL "libtiff: jpeg option" FORCE)
# libdeflate variable is used by vendored libtiff

View file

@ -108,7 +108,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(ProjectDir)\..\include;external\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>DLL_EXPORT;_DEBUG;WIN32;_WINDOWS;USE_STBIMAGE;LOAD_AVIF;LOAD_AVIF_DYNAMIC="libavif-16.dll";LOAD_BMP;LOAD_GIF;LOAD_JPG;LOAD_LBM;LOAD_PCX;LOAD_PNG;LOAD_PNM;LOAD_QOI;LOAD_SVG;LOAD_TGA;LOAD_TIF;LOAD_TIF_DYNAMIC="libtiff-6.dll";LOAD_WEBP;LOAD_WEBP_DYNAMIC="libwebp-7.dll";LOAD_WEBPDEMUX_DYNAMIC="libwebpdemux-2.dll";LOAD_XCF;LOAD_XPM;LOAD_XV;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>DLL_EXPORT;_DEBUG;WIN32;_WINDOWS;USE_STBIMAGE;LOAD_AVIF;LOAD_AVIF_DYNAMIC="libavif-16.dll";LOAD_BMP;LOAD_GIF;LOAD_JPG;LOAD_LBM;LOAD_PCX;LOAD_PNG;LOAD_PNM;LOAD_QOI;LOAD_SVG;LOAD_TGA;LOAD_TIF;LOAD_TIF_DYNAMIC="libtiff-5.dll";LOAD_WEBP;LOAD_WEBP_DYNAMIC="libwebp-7.dll";LOAD_WEBPDEMUX_DYNAMIC="libwebpdemux-2.dll";LOAD_XCF;LOAD_XPM;LOAD_XV;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
@ -136,7 +136,7 @@
</Midl>
<ClCompile>
<AdditionalIncludeDirectories>$(ProjectDir)\..\include;external\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>DLL_EXPORT;_DEBUG;WIN32;_WINDOWS;USE_STBIMAGE;LOAD_AVIF;LOAD_AVIF_DYNAMIC="libavif-16.dll";LOAD_BMP;LOAD_GIF;LOAD_JPG;LOAD_LBM;LOAD_PCX;LOAD_PNG;LOAD_PNM;LOAD_QOI;LOAD_SVG;LOAD_TGA;LOAD_TIF;LOAD_TIF_DYNAMIC="libtiff-6.dll";LOAD_WEBP;LOAD_WEBP_DYNAMIC="libwebp-7.dll";LOAD_WEBPDEMUX_DYNAMIC="libwebpdemux-2.dll";LOAD_XCF;LOAD_XPM;LOAD_XV;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>DLL_EXPORT;_DEBUG;WIN32;_WINDOWS;USE_STBIMAGE;LOAD_AVIF;LOAD_AVIF_DYNAMIC="libavif-16.dll";LOAD_BMP;LOAD_GIF;LOAD_JPG;LOAD_LBM;LOAD_PCX;LOAD_PNG;LOAD_PNM;LOAD_QOI;LOAD_SVG;LOAD_TGA;LOAD_TIF;LOAD_TIF_DYNAMIC="libtiff-5.dll";LOAD_WEBP;LOAD_WEBP_DYNAMIC="libwebp-7.dll";LOAD_WEBPDEMUX_DYNAMIC="libwebpdemux-2.dll";LOAD_XCF;LOAD_XPM;LOAD_XV;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
@ -165,7 +165,7 @@
</Midl>
<ClCompile>
<AdditionalIncludeDirectories>$(ProjectDir)\..\include;external\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>DLL_EXPORT;NDEBUG;WIN32;_WINDOWS;USE_STBIMAGE;LOAD_AVIF;LOAD_AVIF_DYNAMIC="libavif-16.dll";LOAD_BMP;LOAD_GIF;LOAD_JPG;LOAD_LBM;LOAD_PCX;LOAD_PNG;LOAD_PNM;LOAD_QOI;LOAD_SVG;LOAD_TGA;LOAD_TIF;LOAD_TIF_DYNAMIC="libtiff-6.dll";LOAD_WEBP;LOAD_WEBP_DYNAMIC="libwebp-7.dll";LOAD_WEBPDEMUX_DYNAMIC="libwebpdemux-2.dll";LOAD_XCF;LOAD_XPM;LOAD_XV;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>DLL_EXPORT;NDEBUG;WIN32;_WINDOWS;USE_STBIMAGE;LOAD_AVIF;LOAD_AVIF_DYNAMIC="libavif-16.dll";LOAD_BMP;LOAD_GIF;LOAD_JPG;LOAD_LBM;LOAD_PCX;LOAD_PNG;LOAD_PNM;LOAD_QOI;LOAD_SVG;LOAD_TGA;LOAD_TIF;LOAD_TIF_DYNAMIC="libtiff-5.dll";LOAD_WEBP;LOAD_WEBP_DYNAMIC="libwebp-7.dll";LOAD_WEBPDEMUX_DYNAMIC="libwebpdemux-2.dll";LOAD_XCF;LOAD_XPM;LOAD_XV;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
@ -191,7 +191,7 @@
</Midl>
<ClCompile>
<AdditionalIncludeDirectories>$(ProjectDir)\..\include;external\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>DLL_EXPORT;NDEBUG;WIN32;_WINDOWS;USE_STBIMAGE;LOAD_AVIF;LOAD_AVIF_DYNAMIC="libavif-16.dll";LOAD_BMP;LOAD_GIF;LOAD_JPG;LOAD_LBM;LOAD_PCX;LOAD_PNG;LOAD_PNM;LOAD_QOI;LOAD_SVG;LOAD_TGA;LOAD_TIF;LOAD_TIF_DYNAMIC="libtiff-6.dll";LOAD_WEBP;LOAD_WEBP_DYNAMIC="libwebp-7.dll";LOAD_WEBPDEMUX_DYNAMIC="libwebpdemux-2.dll";LOAD_XCF;LOAD_XPM;LOAD_XV;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>DLL_EXPORT;NDEBUG;WIN32;_WINDOWS;USE_STBIMAGE;LOAD_AVIF;LOAD_AVIF_DYNAMIC="libavif-16.dll";LOAD_BMP;LOAD_GIF;LOAD_JPG;LOAD_LBM;LOAD_PCX;LOAD_PNG;LOAD_PNM;LOAD_QOI;LOAD_SVG;LOAD_TGA;LOAD_TIF;LOAD_TIF_DYNAMIC="libtiff-5.dll";LOAD_WEBP;LOAD_WEBP_DYNAMIC="libwebp-7.dll";LOAD_WEBPDEMUX_DYNAMIC="libwebpdemux-2.dll";LOAD_XCF;LOAD_XPM;LOAD_XV;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>

File diff suppressed because it is too large Load diff

View file

@ -5,68 +5,50 @@
from this file in your programs.
*/
/* clang-format off */
/* clang-format disabled because CMake scripts are very sensitive to the
* formatting of this file. configure_file variables of type "@VAR@" are
* modified by clang-format and won't be substituted.
*/
#ifndef _TIFFCONF_
#define _TIFFCONF_
#include <stddef.h>
#include <stdint.h>
#include <inttypes.h>
/* Signed 16-bit type */
/* #undef TIFF_INT16_T */
#define TIFF_INT16_T signed short
/* Signed 32-bit type */
/* #undef TIFF_INT32_T */
#define TIFF_INT32_T signed int
/* Signed 64-bit type */
/* #undef TIFF_INT64_T */
#define TIFF_INT64_T signed long long
/* Signed 8-bit type */
/* #undef TIFF_INT8_T */
#define TIFF_INT8_T signed char
/* Unsigned 16-bit type */
/* #undef TIFF_UINT16_T */
#define TIFF_UINT16_T unsigned short
/* Unsigned 32-bit type */
/* #undef TIFF_UINT32_T */
#define TIFF_UINT32_T unsigned int
/* Unsigned 64-bit type */
/* #undef TIFF_UINT64_T */
#define TIFF_UINT64_T unsigned long long
/* Unsigned 8-bit type */
/* #undef TIFF_UINT8_T */
#define TIFF_UINT8_T unsigned char
/* Signed size type */
#if defined _WIN64
#define TIFF_SSIZE_T int64_t
#define TIFF_SSIZE_T signed long long
#else
#define TIFF_SSIZE_T int32_t
#define TIFF_SSIZE_T signed int
#endif
/* Pointer difference type */
#define TIFF_PTRDIFF_T ptrdiff_t
/* Compatibility stuff. */
/* Define as 0 or 1 according to the floating point format supported by the
/* Define as 0 or 1 according to the floating point format suported by the
machine */
#define HAVE_IEEEFP 1
/* The concept of HOST_FILLORDER is broken. Since libtiff 4.5.1
* this macro will always be hardcoded to FILLORDER_LSB2MSB on all
* architectures, to reflect past long behavior of doing so on x86 architecture.
* Note however that the default FillOrder used by libtiff is FILLORDER_MSB2LSB,
* as mandated per the TIFF specification.
* The influence of HOST_FILLORDER is only when passing the 'H' mode in
* TIFFOpen().
* You should NOT rely on this macro to decide the CPU endianness!
* This macro will be removed in libtiff 4.6
*/
/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */
#define HOST_FILLORDER FILLORDER_LSB2MSB
/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian
@ -82,9 +64,6 @@
/* Support JBIG compression (requires JBIG-KIT library) */
/* #undef JBIG_SUPPORT */
/* Support LERC compression */
/* #undef LERC_SUPPORT */
/* Support LogLuv high dynamic range encoding */
#define LOGLUV_SUPPORT 1
@ -114,7 +93,7 @@
/* #undef LIBDEFLATE_SUPPORT */
/* Support strip chopping (whether or not to convert single-strip uncompressed
images to multiple strips of ~8Kb to reduce memory usage) */
images to mutiple strips of ~8Kb to reduce memory usage) */
#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP
/* Enable SubIFD tag (330) support */
@ -127,7 +106,7 @@
/* Pick up YCbCr subsampling info from the JPEG data stream to support files
lacking the tag (default enabled). */
#define CHECK_JPEG_YCBCR_SUBSAMPLING 1
/* #undef CHECK_JPEG_YCBCR_SUBSAMPLING */
/* Support MS MDI magic number files as TIFF */
#define MDI_SUPPORT 1
@ -145,5 +124,3 @@
#define IPTC_SUPPORT
#endif /* _TIFFCONF_ */
/* clang-format on */

View file

@ -23,7 +23,7 @@
*/
#ifndef _TIFFIO_
#define _TIFFIO_
#define _TIFFIO_
/*
* TIFF I/O Library Definitions.
@ -60,22 +60,20 @@ typedef struct tiff TIFF;
*/
/*
* this is the machine addressing size type, only it's signed, so make it
* int32_t on 32bit machines, int64_t on 64bit machines
* int32 on 32bit machines, int64 on 64bit machines
*/
typedef TIFF_SSIZE_T tmsize_t;
#define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1)
typedef uint64_t toff_t; /* file offset */
typedef uint64 toff_t; /* file offset */
/* the following are deprecated and should be replaced by their defining
counterparts */
typedef uint32_t ttag_t; /* directory tag */
typedef uint32_t tdir_t; /* directory index */
typedef uint16_t tsample_t; /* sample number */
typedef uint32_t tstrile_t; /* strip or tile number */
typedef tstrile_t tstrip_t; /* strip number */
typedef tstrile_t ttile_t; /* tile number */
typedef tmsize_t tsize_t; /* i/o size in bytes */
typedef void *tdata_t; /* image data ref */
typedef uint32 ttag_t; /* directory tag */
typedef uint16 tdir_t; /* directory index */
typedef uint16 tsample_t; /* sample number */
typedef uint32 tstrile_t; /* strip or tile number */
typedef tstrile_t tstrip_t; /* strip number */
typedef tstrile_t ttile_t; /* tile number */
typedef tmsize_t tsize_t; /* i/o size in bytes */
typedef void* tdata_t; /* image data ref */
#if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32))
#define __WIN32__
@ -89,22 +87,21 @@ typedef void *tdata_t; /* image data ref */
*/
#if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows)
#if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && \
!defined(USE_WIN32_FILEIO)
#define AVOID_WIN32_FILEIO
#endif
# if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && !defined(USE_WIN32_FILEIO)
# define AVOID_WIN32_FILEIO
# endif
#endif
#if defined(USE_WIN32_FILEIO)
#define VC_EXTRALEAN
#include <windows.h>
#ifdef __WIN32__
DECLARE_HANDLE(thandle_t); /* Win32 file handle */
# define VC_EXTRALEAN
# include <windows.h>
# ifdef __WIN32__
DECLARE_HANDLE(thandle_t); /* Win32 file handle */
# else
typedef HFILE thandle_t; /* client data handle */
# endif /* __WIN32__ */
#else
typedef HFILE thandle_t; /* client data handle */
#endif /* __WIN32__ */
#else
typedef void *thandle_t; /* client data handle */
typedef void* thandle_t; /* client data handle */
#endif /* USE_WIN32_FILEIO */
/*
@ -113,15 +110,15 @@ typedef void *thandle_t; /* client data handle */
* very large. Bit-or these flags to enable printing
* multiple items.
*/
#define TIFFPRINT_NONE 0x0 /* no extra info */
#define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */
#define TIFFPRINT_CURVES 0x2 /* color/gray response curves */
#define TIFFPRINT_COLORMAP 0x4 /* colormap */
#define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */
#define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */
#define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */
#define TIFFPRINT_NONE 0x0 /* no extra info */
#define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */
#define TIFFPRINT_CURVES 0x2 /* color/gray response curves */
#define TIFFPRINT_COLORMAP 0x4 /* colormap */
#define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */
#define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */
#define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */
/*
/*
* Colour conversion stuff
*/
@ -136,45 +133,42 @@ typedef void *thandle_t; /* client data handle */
/* Structure for holding information about a display device. */
typedef unsigned char TIFFRGBValue; /* 8-bit samples */
typedef unsigned char TIFFRGBValue; /* 8-bit samples */
typedef struct
{
float d_mat[3][3]; /* XYZ -> luminance matrix */
float d_YCR; /* Light o/p for reference white */
float d_YCG;
float d_YCB;
uint32_t d_Vrwr; /* Pixel values for ref. white */
uint32_t d_Vrwg;
uint32_t d_Vrwb;
float d_Y0R; /* Residual light for black pixel */
float d_Y0G;
float d_Y0B;
float d_gammaR; /* Gamma values for the three guns */
float d_gammaG;
float d_gammaB;
typedef struct {
float d_mat[3][3]; /* XYZ -> luminance matrix */
float d_YCR; /* Light o/p for reference white */
float d_YCG;
float d_YCB;
uint32 d_Vrwr; /* Pixel values for ref. white */
uint32 d_Vrwg;
uint32 d_Vrwb;
float d_Y0R; /* Residual light for black pixel */
float d_Y0G;
float d_Y0B;
float d_gammaR; /* Gamma values for the three guns */
float d_gammaG;
float d_gammaB;
} TIFFDisplay;
typedef struct
{ /* YCbCr->RGB support */
TIFFRGBValue *clamptab; /* range clamping table */
int *Cr_r_tab;
int *Cb_b_tab;
int32_t *Cr_g_tab;
int32_t *Cb_g_tab;
int32_t *Y_tab;
typedef struct { /* YCbCr->RGB support */
TIFFRGBValue* clamptab; /* range clamping table */
int* Cr_r_tab;
int* Cb_b_tab;
int32* Cr_g_tab;
int32* Cb_g_tab;
int32* Y_tab;
} TIFFYCbCrToRGB;
typedef struct
{ /* CIE Lab 1976->RGB support */
int range; /* Size of conversion table */
typedef struct { /* CIE Lab 1976->RGB support */
int range; /* Size of conversion table */
#define CIELABTORGB_TABLE_RANGE 1500
float rstep, gstep, bstep;
float X0, Y0, Z0; /* Reference white point */
TIFFDisplay display;
float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */
float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */
float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */
float rstep, gstep, bstep;
float X0, Y0, Z0; /* Reference white point */
TIFFDisplay display;
float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */
float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */
float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */
} TIFFCIELabToRGB;
/*
@ -184,66 +178,63 @@ typedef struct _TIFFRGBAImage TIFFRGBAImage;
/*
* The image reading and conversion routines invoke
* ``put routines'' to copy/image/whatever tiles of
* raw image data. A default set of routines are
* raw image data. A default set of routines are
* provided to convert/copy raw image data to 8-bit
* packed ABGR format rasters. Applications can supply
* alternate routines that unpack the data into a
* different format or, for example, unpack the data
* and draw the unpacked raster on the display.
*/
typedef void (*tileContigRoutine)(TIFFRGBAImage *, uint32_t *, uint32_t,
uint32_t, uint32_t, uint32_t, int32_t,
int32_t, unsigned char *);
typedef void (*tileSeparateRoutine)(TIFFRGBAImage *, uint32_t *, uint32_t,
uint32_t, uint32_t, uint32_t, int32_t,
int32_t, unsigned char *, unsigned char *,
unsigned char *, unsigned char *);
typedef void (*tileContigRoutine)
(TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32,
unsigned char*);
typedef void (*tileSeparateRoutine)
(TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32,
unsigned char*, unsigned char*, unsigned char*, unsigned char*);
/*
* RGBA-reader state.
*/
struct _TIFFRGBAImage
{
TIFF *tif; /* image handle */
int stoponerr; /* stop on read error */
int isContig; /* data is packed/separate */
int alpha; /* type of alpha data present */
uint32_t width; /* image width */
uint32_t height; /* image height */
uint16_t bitspersample; /* image bits/sample */
uint16_t samplesperpixel; /* image samples/pixel */
uint16_t orientation; /* image orientation */
uint16_t req_orientation; /* requested orientation */
uint16_t photometric; /* image photometric interp */
uint16_t *redcmap; /* colormap palette */
uint16_t *greencmap;
uint16_t *bluecmap;
/* get image data routine */
int (*get)(TIFFRGBAImage *, uint32_t *, uint32_t, uint32_t);
/* put decoded strip/tile */
union
{
void (*any)(TIFFRGBAImage *);
tileContigRoutine contig;
tileSeparateRoutine separate;
} put;
TIFFRGBValue *Map; /* sample mapping array */
uint32_t **BWmap; /* black&white map */
uint32_t **PALmap; /* palette image map */
TIFFYCbCrToRGB *ycbcr; /* YCbCr conversion state */
TIFFCIELabToRGB *cielab; /* CIE L*a*b conversion state */
struct _TIFFRGBAImage {
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 req_orientation; /* requested orientation */
uint16 photometric; /* image photometric interp */
uint16* redcmap; /* colormap palette */
uint16* greencmap;
uint16* bluecmap;
/* get image data routine */
int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32);
/* put decoded strip/tile */
union {
void (*any)(TIFFRGBAImage*);
tileContigRoutine contig;
tileSeparateRoutine separate;
} put;
TIFFRGBValue* Map; /* sample mapping array */
uint32** BWmap; /* black&white map */
uint32** PALmap; /* palette image map */
TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */
TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */
uint8_t *UaToAa; /* Unassociated alpha to associated alpha conversion LUT */
uint8_t *Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */
uint8* UaToAa; /* Unassociated alpha to associated alpha conversion LUT */
uint8* Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */
int row_offset;
int col_offset;
int row_offset;
int col_offset;
};
/*
* Macros for extracting components from the
* packed ABGR form returned by TIFFReadRGBAImage.
*/
#define TIFFGetR(abgr) ((abgr)&0xff)
#define TIFFGetR(abgr) ((abgr) & 0xff)
#define TIFFGetG(abgr) (((abgr) >> 8) & 0xff)
#define TIFFGetB(abgr) (((abgr) >> 16) & 0xff)
#define TIFFGetA(abgr) (((abgr) >> 24) & 0xff)
@ -255,399 +246,327 @@ struct _TIFFRGBAImage
* More codecs may be registered through calls to the library
* and/or the builtin implementations may be overridden.
*/
typedef int (*TIFFInitMethod)(TIFF *, int);
typedef struct
{
char *name;
uint16_t scheme;
TIFFInitMethod init;
typedef int (*TIFFInitMethod)(TIFF*, int);
typedef struct {
char* name;
uint16 scheme;
TIFFInitMethod init;
} TIFFCodec;
typedef struct
{
uint32_t uNum;
uint32_t uDenom;
} TIFFRational_t;
#include <stdarg.h>
#include <stdio.h>
#include <stdarg.h>
/* share internal LogLuv conversion routines? */
#ifndef LOGLUV_PUBLIC
#define LOGLUV_PUBLIC 1
#endif
#if defined(__GNUC__) || defined(__attribute__)
#define TIFF_ATTRIBUTE(x) __attribute__(x)
#if defined(__GNUC__) || defined(__clang__) || defined(__attribute__)
# define TIFF_ATTRIBUTE(x) __attribute__(x)
#else
#define TIFF_ATTRIBUTE(x) /*nothing*/
# define TIFF_ATTRIBUTE(x) /*nothing*/
#endif
#if defined(c_plusplus) || defined(__cplusplus)
extern "C"
{
extern "C" {
#endif
typedef void (*TIFFErrorHandler)(const char *, const char *, va_list);
typedef void (*TIFFErrorHandlerExt)(thandle_t, const char *, const char *,
va_list);
typedef int (*TIFFErrorHandlerExtR)(TIFF *, void *user_data, const char *,
const char *, va_list);
typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void *, tmsize_t);
typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);
typedef int (*TIFFCloseProc)(thandle_t);
typedef toff_t (*TIFFSizeProc)(thandle_t);
typedef int (*TIFFMapFileProc)(thandle_t, void **base, toff_t *size);
typedef void (*TIFFUnmapFileProc)(thandle_t, void *base, toff_t size);
typedef void (*TIFFExtendProc)(TIFF *);
typedef void (*TIFFErrorHandler)(const char*, const char*, va_list);
typedef void (*TIFFErrorHandlerExt)(thandle_t, const char*, const char*, va_list);
typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void*, tmsize_t);
typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);
typedef int (*TIFFCloseProc)(thandle_t);
typedef toff_t (*TIFFSizeProc)(thandle_t);
typedef int (*TIFFMapFileProc)(thandle_t, void** base, toff_t* size);
typedef void (*TIFFUnmapFileProc)(thandle_t, void* base, toff_t size);
typedef void (*TIFFExtendProc)(TIFF*);
extern const char *TIFFGetVersion(void);
extern const char* TIFFGetVersion(void);
extern const TIFFCodec *TIFFFindCODEC(uint16_t);
extern TIFFCodec *TIFFRegisterCODEC(uint16_t, const char *, TIFFInitMethod);
extern void TIFFUnRegisterCODEC(TIFFCodec *);
extern int TIFFIsCODECConfigured(uint16_t);
extern TIFFCodec *TIFFGetConfiguredCODECs(void);
extern const TIFFCodec* TIFFFindCODEC(uint16);
extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod);
extern void TIFFUnRegisterCODEC(TIFFCodec*);
extern int TIFFIsCODECConfigured(uint16);
extern TIFFCodec* TIFFGetConfiguredCODECs(void);
/*
* Auxiliary functions.
*/
/*
* Auxiliary functions.
*/
extern void *_TIFFmalloc(tmsize_t s);
extern void *_TIFFcalloc(tmsize_t nmemb, tmsize_t siz);
extern void *_TIFFrealloc(void *p, tmsize_t s);
extern void _TIFFmemset(void *p, int v, tmsize_t c);
extern void _TIFFmemcpy(void *d, const void *s, tmsize_t c);
extern int _TIFFmemcmp(const void *p1, const void *p2, tmsize_t c);
extern void _TIFFfree(void *p);
extern void* _TIFFmalloc(tmsize_t s);
extern void* _TIFFcalloc(tmsize_t nmemb, tmsize_t siz);
extern void* _TIFFrealloc(void* p, tmsize_t s);
extern void _TIFFmemset(void* p, int v, tmsize_t c);
extern void _TIFFmemcpy(void* d, const void* s, tmsize_t c);
extern int _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c);
extern void _TIFFfree(void* p);
/*
** Stuff, related to tag handling and creating custom tags.
*/
extern int TIFFGetTagListCount(TIFF *);
extern uint32_t TIFFGetTagListEntry(TIFF *, int tag_index);
/*
** Stuff, related to tag handling and creating custom tags.
*/
extern int TIFFGetTagListCount( TIFF * );
extern uint32 TIFFGetTagListEntry( TIFF *, int tag_index );
#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
#define TIFF_VARIABLE -1 /* marker for variable length tags */
#define TIFF_SPP -2 /* marker for SamplesPerPixel tags */
#define TIFF_VARIABLE2 -3 /* marker for uint32 var-length tags */
#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
#define TIFF_VARIABLE -1 /* marker for variable length tags */
#define TIFF_SPP -2 /* marker for SamplesPerPixel tags */
#define TIFF_VARIABLE2 -3 /* marker for uint32_t var-length tags */
#define FIELD_CUSTOM 65
#define FIELD_CUSTOM 65
typedef struct _TIFFField TIFFField;
typedef struct _TIFFFieldArray TIFFFieldArray;
typedef struct _TIFFField TIFFField;
typedef struct _TIFFFieldArray TIFFFieldArray;
extern const TIFFField* TIFFFindField(TIFF *, uint32, TIFFDataType);
extern const TIFFField* TIFFFieldWithTag(TIFF*, uint32);
extern const TIFFField* TIFFFieldWithName(TIFF*, const char *);
extern const TIFFField *TIFFFindField(TIFF *, uint32_t, TIFFDataType);
extern const TIFFField *TIFFFieldWithTag(TIFF *, uint32_t);
extern const TIFFField *TIFFFieldWithName(TIFF *, const char *);
extern uint32 TIFFFieldTag(const TIFFField*);
extern const char* TIFFFieldName(const TIFFField*);
extern TIFFDataType TIFFFieldDataType(const TIFFField*);
extern int TIFFFieldPassCount(const TIFFField*);
extern int TIFFFieldReadCount(const TIFFField*);
extern int TIFFFieldWriteCount(const TIFFField*);
extern uint32_t TIFFFieldTag(const TIFFField *);
extern const char *TIFFFieldName(const TIFFField *);
extern TIFFDataType TIFFFieldDataType(const TIFFField *);
extern int TIFFFieldPassCount(const TIFFField *);
extern int TIFFFieldReadCount(const TIFFField *);
extern int TIFFFieldWriteCount(const TIFFField *);
extern int
TIFFFieldSetGetSize(const TIFFField *); /* returns internal storage size of
TIFFSetGetFieldType in bytes. */
extern int TIFFFieldSetGetCountSize(
const TIFFField *); /* returns size of count parameter 0=none,
2=uint16_t, 4=uint32_t */
extern int TIFFFieldIsAnonymous(const TIFFField *);
typedef int (*TIFFVSetMethod)(TIFF*, uint32, va_list);
typedef int (*TIFFVGetMethod)(TIFF*, uint32, va_list);
typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long);
typedef int (*TIFFVSetMethod)(TIFF *, uint32_t, va_list);
typedef int (*TIFFVGetMethod)(TIFF *, uint32_t, va_list);
typedef void (*TIFFPrintMethod)(TIFF *, FILE *, long);
typedef struct {
TIFFVSetMethod vsetfield; /* tag set routine */
TIFFVGetMethod vgetfield; /* tag get routine */
TIFFPrintMethod printdir; /* directory print routine */
} TIFFTagMethods;
typedef struct
{
TIFFVSetMethod vsetfield; /* tag set routine */
TIFFVGetMethod vgetfield; /* tag get routine */
TIFFPrintMethod printdir; /* directory print routine */
} TIFFTagMethods;
extern TIFFTagMethods *TIFFAccessTagMethods(TIFF *);
extern void *TIFFGetClientInfo(TIFF *, const char *);
extern void TIFFSetClientInfo(TIFF *, void *, const char *);
extern TIFFTagMethods *TIFFAccessTagMethods(TIFF *);
extern void *TIFFGetClientInfo(TIFF *, const char *);
extern void TIFFSetClientInfo(TIFF *, void *, const char *);
extern void TIFFCleanup(TIFF *tif);
extern void TIFFClose(TIFF *tif);
extern int TIFFFlush(TIFF *tif);
extern int TIFFFlushData(TIFF *tif);
extern int TIFFGetField(TIFF *tif, uint32_t tag, ...);
extern int TIFFVGetField(TIFF *tif, uint32_t tag, va_list ap);
extern int TIFFGetFieldDefaulted(TIFF *tif, uint32_t tag, ...);
extern int TIFFVGetFieldDefaulted(TIFF *tif, uint32_t tag, va_list ap);
extern int TIFFReadDirectory(TIFF *tif);
extern int TIFFReadCustomDirectory(TIFF *tif, toff_t diroff,
const TIFFFieldArray *infoarray);
extern int TIFFReadEXIFDirectory(TIFF *tif, toff_t diroff);
extern int TIFFReadGPSDirectory(TIFF *tif, toff_t diroff);
extern uint64_t TIFFScanlineSize64(TIFF *tif);
extern tmsize_t TIFFScanlineSize(TIFF *tif);
extern uint64_t TIFFRasterScanlineSize64(TIFF *tif);
extern tmsize_t TIFFRasterScanlineSize(TIFF *tif);
extern uint64_t TIFFStripSize64(TIFF *tif);
extern tmsize_t TIFFStripSize(TIFF *tif);
extern uint64_t TIFFRawStripSize64(TIFF *tif, uint32_t strip);
extern tmsize_t TIFFRawStripSize(TIFF *tif, uint32_t strip);
extern uint64_t TIFFVStripSize64(TIFF *tif, uint32_t nrows);
extern tmsize_t TIFFVStripSize(TIFF *tif, uint32_t nrows);
extern uint64_t TIFFTileRowSize64(TIFF *tif);
extern tmsize_t TIFFTileRowSize(TIFF *tif);
extern uint64_t TIFFTileSize64(TIFF *tif);
extern tmsize_t TIFFTileSize(TIFF *tif);
extern uint64_t TIFFVTileSize64(TIFF *tif, uint32_t nrows);
extern tmsize_t TIFFVTileSize(TIFF *tif, uint32_t nrows);
extern uint32_t TIFFDefaultStripSize(TIFF *tif, uint32_t request);
extern void TIFFDefaultTileSize(TIFF *, uint32_t *, uint32_t *);
extern int TIFFFileno(TIFF *);
extern int TIFFSetFileno(TIFF *, int);
extern thandle_t TIFFClientdata(TIFF *);
extern thandle_t TIFFSetClientdata(TIFF *, thandle_t);
extern int TIFFGetMode(TIFF *);
extern int TIFFSetMode(TIFF *, int);
extern int TIFFIsTiled(TIFF *);
extern int TIFFIsByteSwapped(TIFF *);
extern int TIFFIsUpSampled(TIFF *);
extern int TIFFIsMSB2LSB(TIFF *);
extern int TIFFIsBigEndian(TIFF *);
extern int TIFFIsBigTIFF(TIFF *);
extern TIFFReadWriteProc TIFFGetReadProc(TIFF *);
extern TIFFReadWriteProc TIFFGetWriteProc(TIFF *);
extern TIFFSeekProc TIFFGetSeekProc(TIFF *);
extern TIFFCloseProc TIFFGetCloseProc(TIFF *);
extern TIFFSizeProc TIFFGetSizeProc(TIFF *);
extern TIFFMapFileProc TIFFGetMapFileProc(TIFF *);
extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF *);
extern uint32_t TIFFCurrentRow(TIFF *);
extern tdir_t TIFFCurrentDirectory(TIFF *);
extern tdir_t TIFFNumberOfDirectories(TIFF *);
extern uint64_t TIFFCurrentDirOffset(TIFF *);
extern uint32_t TIFFCurrentStrip(TIFF *);
extern uint32_t TIFFCurrentTile(TIFF *tif);
extern int TIFFReadBufferSetup(TIFF *tif, void *bp, tmsize_t size);
extern int TIFFWriteBufferSetup(TIFF *tif, void *bp, tmsize_t size);
extern int TIFFSetupStrips(TIFF *);
extern int TIFFWriteCheck(TIFF *, int, const char *);
extern void TIFFFreeDirectory(TIFF *);
extern int TIFFCreateDirectory(TIFF *);
extern int TIFFCreateCustomDirectory(TIFF *, const TIFFFieldArray *);
extern int TIFFCreateEXIFDirectory(TIFF *);
extern int TIFFCreateGPSDirectory(TIFF *);
extern int TIFFLastDirectory(TIFF *);
extern int TIFFSetDirectory(TIFF *, tdir_t);
extern int TIFFSetSubDirectory(TIFF *, uint64_t);
extern int TIFFUnlinkDirectory(TIFF *, tdir_t);
extern int TIFFSetField(TIFF *, uint32_t, ...);
extern int TIFFVSetField(TIFF *, uint32_t, va_list);
extern int TIFFUnsetField(TIFF *, uint32_t);
extern int TIFFWriteDirectory(TIFF *);
extern int TIFFWriteCustomDirectory(TIFF *, uint64_t *);
extern int TIFFCheckpointDirectory(TIFF *);
extern int TIFFRewriteDirectory(TIFF *);
extern int TIFFDeferStrileArrayWriting(TIFF *);
extern int TIFFForceStrileArrayWriting(TIFF *);
extern void TIFFCleanup(TIFF* tif);
extern void TIFFClose(TIFF* tif);
extern int TIFFFlush(TIFF* tif);
extern int TIFFFlushData(TIFF* tif);
extern int TIFFGetField(TIFF* tif, uint32 tag, ...);
extern int TIFFVGetField(TIFF* tif, uint32 tag, va_list ap);
extern int TIFFGetFieldDefaulted(TIFF* tif, uint32 tag, ...);
extern int TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap);
extern int TIFFReadDirectory(TIFF* tif);
extern int TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, const TIFFFieldArray* infoarray);
extern int TIFFReadEXIFDirectory(TIFF* tif, toff_t diroff);
extern int TIFFReadGPSDirectory(TIFF* tif, toff_t diroff);
extern uint64 TIFFScanlineSize64(TIFF* tif);
extern tmsize_t TIFFScanlineSize(TIFF* tif);
extern uint64 TIFFRasterScanlineSize64(TIFF* tif);
extern tmsize_t TIFFRasterScanlineSize(TIFF* tif);
extern uint64 TIFFStripSize64(TIFF* tif);
extern tmsize_t TIFFStripSize(TIFF* tif);
extern uint64 TIFFRawStripSize64(TIFF* tif, uint32 strip);
extern tmsize_t TIFFRawStripSize(TIFF* tif, uint32 strip);
extern uint64 TIFFVStripSize64(TIFF* tif, uint32 nrows);
extern tmsize_t TIFFVStripSize(TIFF* tif, uint32 nrows);
extern uint64 TIFFTileRowSize64(TIFF* tif);
extern tmsize_t TIFFTileRowSize(TIFF* tif);
extern uint64 TIFFTileSize64(TIFF* tif);
extern tmsize_t TIFFTileSize(TIFF* tif);
extern uint64 TIFFVTileSize64(TIFF* tif, uint32 nrows);
extern tmsize_t TIFFVTileSize(TIFF* tif, uint32 nrows);
extern uint32 TIFFDefaultStripSize(TIFF* tif, uint32 request);
extern void TIFFDefaultTileSize(TIFF*, uint32*, uint32*);
extern int TIFFFileno(TIFF*);
extern int TIFFSetFileno(TIFF*, int);
extern thandle_t TIFFClientdata(TIFF*);
extern thandle_t TIFFSetClientdata(TIFF*, thandle_t);
extern int TIFFGetMode(TIFF*);
extern int TIFFSetMode(TIFF*, int);
extern int TIFFIsTiled(TIFF*);
extern int TIFFIsByteSwapped(TIFF*);
extern int TIFFIsUpSampled(TIFF*);
extern int TIFFIsMSB2LSB(TIFF*);
extern int TIFFIsBigEndian(TIFF*);
extern TIFFReadWriteProc TIFFGetReadProc(TIFF*);
extern TIFFReadWriteProc TIFFGetWriteProc(TIFF*);
extern TIFFSeekProc TIFFGetSeekProc(TIFF*);
extern TIFFCloseProc TIFFGetCloseProc(TIFF*);
extern TIFFSizeProc TIFFGetSizeProc(TIFF*);
extern TIFFMapFileProc TIFFGetMapFileProc(TIFF*);
extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF*);
extern uint32 TIFFCurrentRow(TIFF*);
extern uint16 TIFFCurrentDirectory(TIFF*);
extern uint16 TIFFNumberOfDirectories(TIFF*);
extern uint64 TIFFCurrentDirOffset(TIFF*);
extern uint32 TIFFCurrentStrip(TIFF*);
extern uint32 TIFFCurrentTile(TIFF* tif);
extern int TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size);
extern int TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size);
extern int TIFFSetupStrips(TIFF *);
extern int TIFFWriteCheck(TIFF*, int, const char *);
extern void TIFFFreeDirectory(TIFF*);
extern int TIFFCreateDirectory(TIFF*);
extern int TIFFCreateCustomDirectory(TIFF*,const TIFFFieldArray*);
extern int TIFFCreateEXIFDirectory(TIFF*);
extern int TIFFCreateGPSDirectory(TIFF*);
extern int TIFFLastDirectory(TIFF*);
extern int TIFFSetDirectory(TIFF*, uint16);
extern int TIFFSetSubDirectory(TIFF*, uint64);
extern int TIFFUnlinkDirectory(TIFF*, uint16);
extern int TIFFSetField(TIFF*, uint32, ...);
extern int TIFFVSetField(TIFF*, uint32, va_list);
extern int TIFFUnsetField(TIFF*, uint32);
extern int TIFFWriteDirectory(TIFF *);
extern int TIFFWriteCustomDirectory(TIFF *, uint64 *);
extern int TIFFCheckpointDirectory(TIFF *);
extern int TIFFRewriteDirectory(TIFF *);
extern int TIFFDeferStrileArrayWriting(TIFF *);
extern int TIFFForceStrileArrayWriting(TIFF* );
#if defined(c_plusplus) || defined(__cplusplus)
extern void TIFFPrintDirectory(TIFF *, FILE *, long = 0);
extern int TIFFReadScanline(TIFF *tif, void *buf, uint32_t row,
uint16_t sample = 0);
extern int TIFFWriteScanline(TIFF *tif, void *buf, uint32_t row,
uint16_t sample = 0);
extern int TIFFReadRGBAImage(TIFF *, uint32_t, uint32_t, uint32_t *,
int = 0);
extern int TIFFReadRGBAImageOriented(TIFF *, uint32_t, uint32_t, uint32_t *,
int = ORIENTATION_BOTLEFT, int = 0);
extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0);
extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0);
extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0);
extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0);
extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*,
int = ORIENTATION_BOTLEFT, int = 0);
#else
extern void TIFFPrintDirectory(TIFF *, FILE *, long);
extern int TIFFReadScanline(TIFF *tif, void *buf, uint32_t row,
uint16_t sample);
extern int TIFFWriteScanline(TIFF *tif, void *buf, uint32_t row,
uint16_t sample);
extern int TIFFReadRGBAImage(TIFF *, uint32_t, uint32_t, uint32_t *, int);
extern int TIFFReadRGBAImageOriented(TIFF *, uint32_t, uint32_t, uint32_t *,
int, int);
extern void TIFFPrintDirectory(TIFF*, FILE*, long);
extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample);
extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample);
extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int);
extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int);
#endif
extern int TIFFReadRGBAStrip(TIFF *, uint32_t, uint32_t *);
extern int TIFFReadRGBATile(TIFF *, uint32_t, uint32_t, uint32_t *);
extern int TIFFReadRGBAStripExt(TIFF *, uint32_t, uint32_t *,
int stop_on_error);
extern int TIFFReadRGBATileExt(TIFF *, uint32_t, uint32_t, uint32_t *,
int stop_on_error);
extern int TIFFRGBAImageOK(TIFF *, char[1024]);
extern int TIFFRGBAImageBegin(TIFFRGBAImage *, TIFF *, int, char[1024]);
extern int TIFFRGBAImageGet(TIFFRGBAImage *, uint32_t *, uint32_t,
uint32_t);
extern void TIFFRGBAImageEnd(TIFFRGBAImage *);
extern int TIFFReadRGBAStrip(TIFF*, uint32, uint32 * );
extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * );
extern int TIFFReadRGBAStripExt(TIFF*, uint32, uint32 *, int stop_on_error );
extern int TIFFReadRGBATileExt(TIFF*, uint32, uint32, uint32 *, int stop_on_error );
extern int TIFFRGBAImageOK(TIFF*, char [1024]);
extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]);
extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32);
extern void TIFFRGBAImageEnd(TIFFRGBAImage*);
extern TIFF* TIFFOpen(const char*, const char*);
# ifdef __WIN32__
extern TIFF* TIFFOpenW(const wchar_t*, const char*);
# endif /* __WIN32__ */
extern TIFF* TIFFFdOpen(int, const char*, const char*);
extern TIFF* TIFFClientOpen(const char*, const char*,
thandle_t,
TIFFReadWriteProc, TIFFReadWriteProc,
TIFFSeekProc, TIFFCloseProc,
TIFFSizeProc,
TIFFMapFileProc, TIFFUnmapFileProc);
extern const char* TIFFFileName(TIFF*);
extern const char* TIFFSetFileName(TIFF*, const char *);
extern void TIFFError(const char*, const char*, ...) TIFF_ATTRIBUTE((__format__ (__printf__,2,3)));
extern void TIFFErrorExt(thandle_t, const char*, const char*, ...) TIFF_ATTRIBUTE((__format__ (__printf__,3,4)));
extern void TIFFWarning(const char*, const char*, ...) TIFF_ATTRIBUTE((__format__ (__printf__,2,3)));
extern void TIFFWarningExt(thandle_t, const char*, const char*, ...) TIFF_ATTRIBUTE((__format__ (__printf__,3,4)));
extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler);
extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt);
extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler);
extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt);
extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc);
extern uint32 TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s);
extern int TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s);
extern uint32 TIFFNumberOfTiles(TIFF*);
extern tmsize_t TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s);
extern tmsize_t TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s);
extern uint32 TIFFComputeStrip(TIFF*, uint32, uint16);
extern uint32 TIFFNumberOfStrips(TIFF*);
extern tmsize_t TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size);
extern tmsize_t TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size);
extern tmsize_t TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size);
extern tmsize_t TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size);
extern int TIFFReadFromUserBuffer(TIFF* tif, uint32 strile,
void* inbuf, tmsize_t insize,
void* outbuf, tmsize_t outsize);
extern tmsize_t TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc);
extern tmsize_t TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc);
extern tmsize_t TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc);
extern tmsize_t TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc);
extern int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths */
extern void TIFFSetWriteOffset(TIFF* tif, toff_t off);
extern void TIFFSwabShort(uint16*);
extern void TIFFSwabLong(uint32*);
extern void TIFFSwabLong8(uint64*);
extern void TIFFSwabFloat(float*);
extern void TIFFSwabDouble(double*);
extern void TIFFSwabArrayOfShort(uint16* wp, tmsize_t n);
extern void TIFFSwabArrayOfTriples(uint8* tp, tmsize_t n);
extern void TIFFSwabArrayOfLong(uint32* lp, tmsize_t n);
extern void TIFFSwabArrayOfLong8(uint64* lp, tmsize_t n);
extern void TIFFSwabArrayOfFloat(float* fp, tmsize_t n);
extern void TIFFSwabArrayOfDouble(double* dp, tmsize_t n);
extern void TIFFReverseBits(uint8* cp, tmsize_t n);
extern const unsigned char* TIFFGetBitRevTable(int);
extern const char *TIFFFileName(TIFF *);
extern const char *TIFFSetFileName(TIFF *, const char *);
extern void TIFFError(const char *, const char *, ...)
TIFF_ATTRIBUTE((__format__(__printf__, 2, 3)));
extern void TIFFErrorExt(thandle_t, const char *, const char *, ...)
TIFF_ATTRIBUTE((__format__(__printf__, 3, 4)));
extern void TIFFWarning(const char *, const char *, ...)
TIFF_ATTRIBUTE((__format__(__printf__, 2, 3)));
extern void TIFFWarningExt(thandle_t, const char *, const char *, ...)
TIFF_ATTRIBUTE((__format__(__printf__, 3, 4)));
extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler);
extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt);
extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler);
extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt);
extern void TIFFWarningExtR(TIFF *, const char *, const char *, ...)
TIFF_ATTRIBUTE((__format__(__printf__, 3, 4)));
extern void TIFFErrorExtR(TIFF *, const char *, const char *, ...)
TIFF_ATTRIBUTE((__format__(__printf__, 3, 4)));
typedef struct TIFFOpenOptions TIFFOpenOptions;
extern TIFFOpenOptions *TIFFOpenOptionsAlloc(void);
extern void TIFFOpenOptionsFree(TIFFOpenOptions *);
extern void
TIFFOpenOptionsSetMaxSingleMemAlloc(TIFFOpenOptions *opts,
tmsize_t max_single_mem_alloc);
extern void
TIFFOpenOptionsSetErrorHandlerExtR(TIFFOpenOptions *opts,
TIFFErrorHandlerExtR handler,
void *errorhandler_user_data);
extern void
TIFFOpenOptionsSetWarningHandlerExtR(TIFFOpenOptions *opts,
TIFFErrorHandlerExtR handler,
void *warnhandler_user_data);
extern TIFF *TIFFOpen(const char *, const char *);
extern TIFF *TIFFOpenExt(const char *, const char *, TIFFOpenOptions *opts);
#ifdef __WIN32__
extern TIFF *TIFFOpenW(const wchar_t *, const char *);
extern TIFF *TIFFOpenWExt(const wchar_t *, const char *,
TIFFOpenOptions *opts);
#endif /* __WIN32__ */
extern TIFF *TIFFFdOpen(int, const char *, const char *);
extern TIFF *TIFFFdOpenExt(int, const char *, const char *,
TIFFOpenOptions *opts);
extern TIFF *TIFFClientOpen(const char *, const char *, thandle_t,
TIFFReadWriteProc, TIFFReadWriteProc,
TIFFSeekProc, TIFFCloseProc, TIFFSizeProc,
TIFFMapFileProc, TIFFUnmapFileProc);
extern TIFF *TIFFClientOpenExt(const char *, const char *, thandle_t,
TIFFReadWriteProc, TIFFReadWriteProc,
TIFFSeekProc, TIFFCloseProc, TIFFSizeProc,
TIFFMapFileProc, TIFFUnmapFileProc,
TIFFOpenOptions *opts);
extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc);
extern uint32_t TIFFComputeTile(TIFF *tif, uint32_t x, uint32_t y,
uint32_t z, uint16_t s);
extern int TIFFCheckTile(TIFF *tif, uint32_t x, uint32_t y, uint32_t z,
uint16_t s);
extern uint32_t TIFFNumberOfTiles(TIFF *);
extern tmsize_t TIFFReadTile(TIFF *tif, void *buf, uint32_t x, uint32_t y,
uint32_t z, uint16_t s);
extern tmsize_t TIFFWriteTile(TIFF *tif, void *buf, uint32_t x, uint32_t y,
uint32_t z, uint16_t s);
extern uint32_t TIFFComputeStrip(TIFF *, uint32_t, uint16_t);
extern uint32_t TIFFNumberOfStrips(TIFF *);
extern tmsize_t TIFFReadEncodedStrip(TIFF *tif, uint32_t strip, void *buf,
tmsize_t size);
extern tmsize_t TIFFReadRawStrip(TIFF *tif, uint32_t strip, void *buf,
tmsize_t size);
extern tmsize_t TIFFReadEncodedTile(TIFF *tif, uint32_t tile, void *buf,
tmsize_t size);
extern tmsize_t TIFFReadRawTile(TIFF *tif, uint32_t tile, void *buf,
tmsize_t size);
extern int TIFFReadFromUserBuffer(TIFF *tif, uint32_t strile, void *inbuf,
tmsize_t insize, void *outbuf,
tmsize_t outsize);
extern tmsize_t TIFFWriteEncodedStrip(TIFF *tif, uint32_t strip, void *data,
tmsize_t cc);
extern tmsize_t TIFFWriteRawStrip(TIFF *tif, uint32_t strip, void *data,
tmsize_t cc);
extern tmsize_t TIFFWriteEncodedTile(TIFF *tif, uint32_t tile, void *data,
tmsize_t cc);
extern tmsize_t TIFFWriteRawTile(TIFF *tif, uint32_t tile, void *data,
tmsize_t cc);
extern int TIFFDataWidth(
TIFFDataType); /* table of tag datatype widths within TIFF file. */
extern void TIFFSetWriteOffset(TIFF *tif, toff_t off);
extern void TIFFSwabShort(uint16_t *);
extern void TIFFSwabLong(uint32_t *);
extern void TIFFSwabLong8(uint64_t *);
extern void TIFFSwabFloat(float *);
extern void TIFFSwabDouble(double *);
extern void TIFFSwabArrayOfShort(uint16_t *wp, tmsize_t n);
extern void TIFFSwabArrayOfTriples(uint8_t *tp, tmsize_t n);
extern void TIFFSwabArrayOfLong(uint32_t *lp, tmsize_t n);
extern void TIFFSwabArrayOfLong8(uint64_t *lp, tmsize_t n);
extern void TIFFSwabArrayOfFloat(float *fp, tmsize_t n);
extern void TIFFSwabArrayOfDouble(double *dp, tmsize_t n);
extern void TIFFReverseBits(uint8_t *cp, tmsize_t n);
extern const unsigned char *TIFFGetBitRevTable(int);
extern uint64_t TIFFGetStrileOffset(TIFF *tif, uint32_t strile);
extern uint64_t TIFFGetStrileByteCount(TIFF *tif, uint32_t strile);
extern uint64_t TIFFGetStrileOffsetWithErr(TIFF *tif, uint32_t strile,
int *pbErr);
extern uint64_t TIFFGetStrileByteCountWithErr(TIFF *tif, uint32_t strile,
int *pbErr);
extern uint64 TIFFGetStrileOffset(TIFF *tif, uint32 strile);
extern uint64 TIFFGetStrileByteCount(TIFF *tif, uint32 strile);
extern uint64 TIFFGetStrileOffsetWithErr(TIFF *tif, uint32 strile, int *pbErr);
extern uint64 TIFFGetStrileByteCountWithErr(TIFF *tif, uint32 strile, int *pbErr);
#ifdef LOGLUV_PUBLIC
#define U_NEU 0.210526316
#define V_NEU 0.473684211
#define UVSCALE 410.
extern double LogL16toY(int);
extern double LogL10toY(int);
extern void XYZtoRGB24(float *, uint8_t *);
extern int uv_decode(double *, double *, int);
extern void LogLuv24toXYZ(uint32_t, float *);
extern void LogLuv32toXYZ(uint32_t, float *);
#define U_NEU 0.210526316
#define V_NEU 0.473684211
#define UVSCALE 410.
extern double LogL16toY(int);
extern double LogL10toY(int);
extern void XYZtoRGB24(float*, uint8*);
extern int uv_decode(double*, double*, int);
extern void LogLuv24toXYZ(uint32, float*);
extern void LogLuv32toXYZ(uint32, float*);
#if defined(c_plusplus) || defined(__cplusplus)
extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER);
extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER);
extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER);
extern uint32_t LogLuv24fromXYZ(float *, int = SGILOGENCODE_NODITHER);
extern uint32_t LogLuv32fromXYZ(float *, int = SGILOGENCODE_NODITHER);
extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER);
extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER);
extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER);
extern uint32 LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER);
extern uint32 LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER);
#else
extern int LogL16fromY(double, int);
extern int LogL10fromY(double, int);
extern int uv_encode(double, double, int);
extern uint32_t LogLuv24fromXYZ(float *, int);
extern uint32_t LogLuv32fromXYZ(float *, int);
extern int LogL16fromY(double, int);
extern int LogL10fromY(double, int);
extern int uv_encode(double, double, int);
extern uint32 LogLuv24fromXYZ(float*, int);
extern uint32 LogLuv32fromXYZ(float*, int);
#endif
#endif /* LOGLUV_PUBLIC */
extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB *, const TIFFDisplay *,
float *);
extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32_t, int32_t, int32_t,
float *, float *, float *);
extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float, uint32_t *,
uint32_t *, uint32_t *);
extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, const TIFFDisplay *, float*);
extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32, int32, int32,
float *, float *, float *);
extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float,
uint32 *, uint32 *, uint32 *);
extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB *, float *, float *);
extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32_t, int32_t, int32_t,
uint32_t *, uint32_t *, uint32_t *);
extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*);
extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32,
uint32 *, uint32 *, uint32 *);
/****************************************************************************
* O B S O L E T E D I N T E R F A C E S
*
* Don't use this stuff in your applications, it may be removed in the
*future libtiff versions.
****************************************************************************/
typedef struct
{
ttag_t field_tag; /* field's tag */
short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */
short field_writecount; /* write count/TIFF_VARIABLE */
TIFFDataType field_type; /* type of associated data */
unsigned short field_bit; /* bit in fieldsset bit vector */
unsigned char field_oktochange; /* if true, can change while writing */
unsigned char field_passcount; /* if true, pass dir count on set */
char *field_name; /* ASCII name */
} TIFFFieldInfo;
extern int TIFFMergeFieldInfo(TIFF *, const TIFFFieldInfo[], uint32_t);
/****************************************************************************
* O B S O L E T E D I N T E R F A C E S
*
* Don't use this stuff in your applications, it may be removed in the future
* libtiff versions.
****************************************************************************/
typedef struct {
ttag_t field_tag; /* field's tag */
short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */
short field_writecount; /* write count/TIFF_VARIABLE */
TIFFDataType field_type; /* type of associated data */
unsigned short field_bit; /* bit in fieldsset bit vector */
unsigned char field_oktochange; /* if true, can change while writing */
unsigned char field_passcount; /* if true, pass dir count on set */
char *field_name; /* ASCII name */
} TIFFFieldInfo;
extern int TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], uint32);
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif /* _TIFFIO_ */
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,9 +1,4 @@
/* clang-format off */
/* clang-format disabled because FindTIFF.cmake is very sensitive to the
* formatting of below line being a single line.
*/
#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.5.1\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.2.0\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
/*
* This define can be used in code that requires
* compilation-related definitions specific to a
@ -11,20 +6,4 @@
* version checking should be done based on the
* string returned by TIFFGetVersion.
*/
#define TIFFLIB_VERSION 20230609
/* The following defines have been added in 4.5.0 */
#define TIFFLIB_MAJOR_VERSION 4
#define TIFFLIB_MINOR_VERSION 5
#define TIFFLIB_MICRO_VERSION 1
/* Macro added in 4.5.0. Returns TRUE if the current libtiff version is
* greater or equal to major.minor.micro
*/
#define TIFFLIB_AT_LEAST(major, minor, micro) \
(TIFFLIB_MAJOR_VERSION > (major) || \
(TIFFLIB_MAJOR_VERSION == (major) && TIFFLIB_MINOR_VERSION > (minor)) || \
(TIFFLIB_MAJOR_VERSION == (major) && TIFFLIB_MINOR_VERSION == (minor) && \
TIFFLIB_MICRO_VERSION >= (micro)))
/* clang-format on */
#define TIFFLIB_VERSION 20201219

BIN
thirdparty/SDL2_image/VisualC/external/optional/x64/libtiff-5.dll (Stored with Git LFS) vendored Normal file

Binary file not shown.

BIN
thirdparty/SDL2_image/VisualC/external/optional/x86/libtiff-5.dll (Stored with Git LFS) vendored Normal file

Binary file not shown.

View file

@ -14503,10 +14503,16 @@ fi
case "$host" in
*-*-darwin*)
avif_lib=`find_lib libavif.dylib`
avif_lib=`find_lib "libavif.[0-9]*.dylib"`
if test x$avif_lib = x; then
avif_lib=`find_lib "libavif*.dylib"`
fi
;;
*-*-cygwin* | *-*-mingw*)
avif_lib=`find_lib "libavif*.dll"`
avif_lib=`find_lib "libavif-[0-9]*.dll"`
if test x$avif_lib = x; then
avif_lib=`find_lib "libavif*.dll"`
fi
;;
*)
avif_lib=`find_lib "libavif[0-9]*.so.*"`
@ -14726,7 +14732,10 @@ fi
case "$host" in
*-*-darwin*)
jpg_lib=`find_lib libjpeg.dylib`
jpg_lib=`find_lib "libjpeg.[0-9]*.dylib"`
if test x$jpg_lib = x; then
jpg_lib=`find_lib libjpeg.dylib`
fi
;;
*-*-cygwin* | *-*-mingw*)
jpg_lib=`find_lib "libjpeg*.dll"`
@ -14938,10 +14947,16 @@ fi
case "$host" in
*-*-darwin*)
jxl_lib=`find_lib libjxl.dylib`
jxl_lib=`find_lib "libjxl.[0-9]*.dylib"`
if test x$jxl_lib = x; then
jxl_lib=`find_lib libjxl.dylib`
fi
;;
*-*-cygwin* | *-*-mingw*)
jxl_lib=`find_lib "libjxl.dll"`
jxl_lib=`find_lib "libjxl-[0-9]*.dll"`
if test x$jxl_lib = x; then
jxl_lib=`find_lib "libjxl.dll"`
fi
;;
*)
jxl_lib=`find_lib "libjxl[0-9]*.so.*"`
@ -15158,7 +15173,10 @@ fi
case "$host" in
*-*-darwin*)
png_lib=`find_lib libpng.dylib`
png_lib=`find_lib "libpng[0-9]*.dylib"`
if test x$png_lib = x; then
png_lib=`find_lib libpng.dylib`
fi
;;
*-*-cygwin* | *-*-mingw*)
png_lib=`find_lib "libpng*.dll"`
@ -15368,7 +15386,10 @@ fi
case "$host" in
*-*-darwin*)
tif_lib=`find_lib libtiff.dylib`
tif_lib=`find_lib "libtiff.[0-9]*.dylib"`
if test x$tif_lib = x; then
tif_lib=`find_lib libtiff.dylib`
fi
;;
*-*-cygwin* | *-*-mingw*)
tif_lib=`find_lib "libtiff-*.dll"`
@ -15754,8 +15775,12 @@ fi
case "$host" in
*-*-darwin*)
webpdemux_lib=`find_lib libwebpdemux.dylib`
webp_lib=`find_lib libwebp.dylib`
webpdemux_lib=`find_lib "libwebpdemux.[0-9]*.dylib"`
webp_lib=`find_lib "libwebp.[0-9]*.dylib"`
if test x$webp_lib = x; then
webpdemux_lib=`find_lib libwebpdemux.dylib`
webp_lib=`find_lib libwebp.dylib`
fi
;;
*-*-cygwin* | *-*-mingw*)
webpdemux_lib=`find_lib "libwebpdemux-*.dll"`

View file

@ -339,10 +339,16 @@ if test x$enable_avif = xyes; then
case "$host" in
*-*-darwin*)
avif_lib=[`find_lib libavif.dylib`]
avif_lib=[`find_lib "libavif.[0-9]*.dylib"`]
if test x$avif_lib = x; then
avif_lib=[`find_lib "libavif*.dylib"`]
fi
;;
*-*-cygwin* | *-*-mingw*)
avif_lib=[`find_lib "libavif*.dll"`]
avif_lib=[`find_lib "libavif-[0-9]*.dll"`]
if test x$avif_lib = x; then
avif_lib=[`find_lib "libavif*.dll"`]
fi
;;
*)
avif_lib=[`find_lib "libavif[0-9]*.so.*"`]
@ -391,7 +397,10 @@ if test x$enable_jpg = xyes; then
case "$host" in
*-*-darwin*)
jpg_lib=[`find_lib libjpeg.dylib`]
jpg_lib=[`find_lib "libjpeg.[0-9]*.dylib"`]
if test x$jpg_lib = x; then
jpg_lib=[`find_lib libjpeg.dylib`]
fi
;;
*-*-cygwin* | *-*-mingw*)
jpg_lib=[`find_lib "libjpeg*.dll"`]
@ -435,10 +444,16 @@ if test x$enable_jxl = xyes; then
case "$host" in
*-*-darwin*)
jxl_lib=[`find_lib libjxl.dylib`]
jxl_lib=[`find_lib "libjxl.[0-9]*.dylib"`]
if test x$jxl_lib = x; then
jxl_lib=[`find_lib libjxl.dylib`]
fi
;;
*-*-cygwin* | *-*-mingw*)
jxl_lib=[`find_lib "libjxl.dll"`]
jxl_lib=[`find_lib "libjxl-[0-9]*.dll"`]
if test x$jxl_lib = x; then
jxl_lib=[`find_lib "libjxl.dll"`]
fi
;;
*)
jxl_lib=[`find_lib "libjxl[0-9]*.so.*"`]
@ -484,7 +499,10 @@ if test x$enable_png = xyes; then
case "$host" in
*-*-darwin*)
png_lib=[`find_lib libpng.dylib`]
png_lib=[`find_lib "libpng[0-9]*.dylib"`]
if test x$png_lib = x; then
png_lib=[`find_lib libpng.dylib`]
fi
;;
*-*-cygwin* | *-*-mingw*)
png_lib=[`find_lib "libpng*.dll"`]
@ -526,7 +544,10 @@ if test x$enable_tif = xyes -a x$enable_imageio != xyes; then
case "$host" in
*-*-darwin*)
tif_lib=[`find_lib libtiff.dylib`]
tif_lib=[`find_lib "libtiff.[0-9]*.dylib"`]
if test x$tif_lib = x; then
tif_lib=[`find_lib libtiff.dylib`]
fi
;;
*-*-cygwin* | *-*-mingw*)
tif_lib=[`find_lib "libtiff-*.dll"`]
@ -580,8 +601,12 @@ if test x$enable_webp = xyes; then
case "$host" in
*-*-darwin*)
webpdemux_lib=[`find_lib libwebpdemux.dylib`]
webp_lib=[`find_lib libwebp.dylib`]
webpdemux_lib=[`find_lib "libwebpdemux.[0-9]*.dylib"`]
webp_lib=[`find_lib "libwebp.[0-9]*.dylib"`]
if test x$webp_lib = x; then
webpdemux_lib=[`find_lib libwebpdemux.dylib`]
webp_lib=[`find_lib libwebp.dylib`]
fi
;;
*-*-cygwin* | *-*-mingw*)
webpdemux_lib=[`find_lib "libwebpdemux-*.dll"`]

View file

@ -0,0 +1,36 @@
<#
.SYNOPSIS
Downloads the Git modules specified in ../.gitmodules
.DESCRIPTION
Parses and downloads the Github repositories specified in the .gitmodules file
.EXAMPLE
PS> .\Get-GitModules.ps1
< Downloads and parses the repositories in the .gitmodules file. >
#>
#------- Variables -------------------------------------------------------------
[String] $PathRegex = "path\s*=\s*(?<path>.*)"
[String] $URLRegex = "url\s*=\s*(?<url>.*)"
[String] $BranchRegex = "branch\s*=\s*(?<Branch>.*)"
#------- Script ----------------------------------------------------------------
foreach ($Line in Get-Content $PSScriptRoot\..\.gitmodules) {
if ($Line -match $PathRegex) {
$Match = Select-String -InputObject $Line -Pattern $PathRegex
$Path = $Match.Matches[0].Groups[1].Value
}
elseif ($Line -match $URLRegex) {
$Match = Select-String -InputObject $Line -Pattern $URLRegex
$URL = $Match.Matches[0].Groups[1].Value
}
elseif ($Line -match $BranchRegex) {
$Match = Select-String -InputObject $Line -Pattern $BranchRegex
$Branch = $Match.Matches[0].Groups[1].Value
Write-Host "git clone $URL $Path -b $Branch --recursive" `
-ForegroundColor Blue
git clone $URL $PSScriptRoot/../$Path -b $Branch --recursive
}
}

View file

@ -1,23 +0,0 @@
[submodule "third_party/lodepng"]
path = third_party/lodepng
url = https://github.com/lvandeve/lodepng
[submodule "third_party/lcms"]
path = third_party/lcms
url = https://github.com/mm2/Little-CMS
[submodule "third_party/googletest"]
path = third_party/googletest
url = https://github.com/google/googletest
[submodule "third_party/sjpeg"]
path = third_party/sjpeg
url = https://github.com/webmproject/sjpeg.git
[submodule "third_party/skcms"]
path = third_party/skcms
url = https://skia.googlesource.com/skcms
[submodule "third_party/brotli"]
path = third_party/brotli
url = https://github.com/libsdl-org/brotli.git
branch = v1.0.9-SDL
[submodule "third_party/highway"]
path = third_party/highway
url = https://github.com/libsdl-org/highway.git
branch = 0.15.0-SDL

View file

@ -1,6 +0,0 @@
[submodule "research/esaxx"]
path = research/esaxx
url = https://github.com/hillbig/esaxx
[submodule "research/libdivsufsort"]
path = research/libdivsufsort
url = https://github.com/y-256/libdivsufsort.git

View file

@ -0,0 +1,18 @@
ndk = ../ndk
cc = $ndk/toolchains/llvm/prebuilt/*/bin/aarch64-linux-android24-clang
cxx = $ndk/toolchains/llvm/prebuilt/*/bin/aarch64-linux-android24-clang++
cflags = -fcolor-diagnostics -Weverything
ldflags = -pie -fuse-ld=lld -static-libstdc++
out = out/android$mode
rule run
command = if which adb >/dev/null && adb get-state >/dev/null 2>/dev/null; $
then $
adb push --sync profiles /data/local/tmp >/dev/null; $
adb push $in /data/local/tmp/$in >/dev/null; $
adb shell "cd /data/local/tmp; taskset f ./$in" > $out; $
else touch $out; fi
description = run $in
include build/common

View file

@ -0,0 +1,18 @@
ndk = ../ndk
cc = $ndk/toolchains/llvm/prebuilt/*/bin/armv7a-linux-androideabi24-clang
cxx = $ndk/toolchains/llvm/prebuilt/*/bin/armv7a-linux-androideabi24-clang++
cflags = -fcolor-diagnostics -Weverything -mthumb
ldflags = -pie -fuse-ld=lld -static-libstdc++
out = out/android-arm$mode
rule run
command = if which adb >/dev/null && adb get-state >/dev/null 2>/dev/null; $
then $
adb push --sync profiles /data/local/tmp >/dev/null; $
adb push $in /data/local/tmp/$in >/dev/null; $
adb shell "cd /data/local/tmp; taskset f ./$in" > $out; $
else touch $out; fi
description = run $in
include build/common

View file

@ -0,0 +1,4 @@
mode = .lsan
extra_cflags = -fsanitize=leak
extra_ldflags = -fsanitize=leak
include build/android-arm

View file

@ -0,0 +1,3 @@
mode = .neon-vfpv4
extra_cflags = -mfpu=neon-vfpv4
include build/android-arm

View file

@ -0,0 +1,3 @@
mode = .neon-vfpv4-O3
extra_cflags = -mfpu=neon-vfpv4 -O3
include build/android-arm

View file

@ -0,0 +1,3 @@
mode = .portable
extra_cflags = -DSKCMS_PORTABLE
include build/android-arm

View file

@ -0,0 +1,3 @@
mode = .tiny
extra_cflags = -g0 -DNDEBUG -fno-unwind-tables -fno-asynchronous-unwind-tables
include build/android-arm

View file

@ -0,0 +1,3 @@
mode = .vfpv2
extra_cflags = -mfpu=vfpv2
include build/android-arm

View file

@ -0,0 +1,3 @@
mode = .fp16
extra_cflags = -march=armv8.2a+fp16 -DSKCMS_OPT_INTO_NEON_FP16
include build/android

View file

@ -0,0 +1,4 @@
mode = .lsan
extra_cflags = -fsanitize=leak
extra_ldflags = -fsanitize=leak
include build/android

View file

@ -0,0 +1,3 @@
mode = .nofp16
extra_cflags = -march=armv8.2a+fp16
include build/android

View file

@ -0,0 +1,3 @@
mode = .portable
extra_cflags = -DSKCMS_PORTABLE
include build/android

View file

@ -0,0 +1,3 @@
mode = .tiny
extra_cflags = -g0 -DNDEBUG -fno-unwind-tables -fno-asynchronous-unwind-tables
include build/android

View file

@ -0,0 +1,7 @@
cc = clang
cxx = clang++
cflags = -fcolor-diagnostics -Weverything
out = out/clang$mode
include build/local
include build/common

View file

@ -0,0 +1,3 @@
mode = .O0
extra_cflags = -O0
include build/clang

View file

@ -0,0 +1,5 @@
mode = .avx512
extra_cflags = -march=skylake-avx512
include build/clang
disabled = (uname | grep -q Darwin && sysctl machdep.cpu.leaf7_features | grep -qv AVX512F || grep flags /proc/cpuinfo | grep -vq avx512f)

View file

@ -0,0 +1,4 @@
mode = .lsan
extra_cflags = -fsanitize=leak
extra_ldflags = -fsanitize=leak
include build/clang

View file

@ -0,0 +1,6 @@
mode = .m32
extra_cflags = -m32 -msse2
extra_ldflags = -m32
include build/clang
disabled = (uname | grep -qv Linux)

View file

@ -0,0 +1,7 @@
mode = .m32-O0
extra_cflags = -m32 -msse2 -O0
extra_ldflags = -m32
include build/clang
disabled = (uname | grep -qv Linux)

View file

@ -0,0 +1,6 @@
mode = .msan
extra_cflags = -fsanitize=memory
extra_ldflags = -fsanitize=memory
include build/clang
disabled = (uname | grep -qv Linux)

View file

@ -0,0 +1,3 @@
mode = .native
extra_cflags = -march=native
include build/clang

View file

@ -0,0 +1,3 @@
mode = .portable
extra_cflags = -DSKCMS_PORTABLE
include build/clang

View file

@ -0,0 +1,4 @@
mode = .sse2
extra_cflags = -msse2 -mno-sse3 -mno-ssse3 -mno-sse4.1 -DSKCMS_NO_RUNTIME_CPU_DETECTION
include build/clang

View file

@ -0,0 +1,4 @@
mode = .sse41
extra_cflags = -msse4.1 -DSKCMS_NO_RUNTIME_CPU_DETECTION
include build/clang

View file

@ -0,0 +1,3 @@
mode = .tiny
extra_cflags = -g0 -DNDEBUG -fno-unwind-tables -fno-asynchronous-unwind-tables
include build/clang

View file

@ -0,0 +1,4 @@
mode = .xsan
extra_cflags = -fsanitize=address,integer,undefined -fno-sanitize-recover=all
extra_ldflags = -fsanitize=address,integer,undefined
include build/clang

View file

@ -0,0 +1,4 @@
mode = .xsan-portable
extra_cflags = -fsanitize=address,integer,undefined -fno-sanitize-recover=all -DSKCMS_PORTABLE
extra_ldflags = -fsanitize=address,integer,undefined
include build/clang

View file

@ -0,0 +1,35 @@
builddir = $out
disabled = false
# Each compiler has enabled all the warnings it can.
# Here we make them errors, and disable a few we don't want bothering us.
warnings = -Werror $
-Wno-double-promotion $
-Wno-float-equal $
-Wno-padded $
warnings_cc = $warnings $
-Wno-c++98-compat-pedantic $
-Wno-gnu-anonymous-struct $
-Wno-old-style-cast $
rule compile_c
command = $disabled && touch $out || $cc -std=c11 -g -Os $warnings $cflags $extra_cflags $
-MD -MF $out.d -c $in -o $out
depfile = $out.d
deps = gcc
description = compile $out
rule compile_cc
command = $disabled && touch $out || $cxx -std=c++11 -g -Os $warnings_cc $cflags $extra_cflags $
-MD -MF $out.d -c $in -o $out
depfile = $out.d
deps = gcc
description = compile $out
rule link
command = $disabled && touch $out || $cxx $ldflags $extra_ldflags $in -ldl -o $out
description = link $out
include build/targets

View file

@ -0,0 +1,19 @@
cc = emcc
cxx = em++
cflags = -g3 -s WASM=1 -s ENVIRONMENT=node
ldflags = -g3 -s WASM=1 -s ENVIRONMENT=node --embed-file profiles
exe = .js
out = out/emscripten$mode
node = 'node'
rule run
command = if which $node >/dev/null; $
then $
$node $in > $out; $
else touch $out; fi
description = run $in
include build/common
disabled = (uname | grep -qv Linux)

View file

@ -0,0 +1,5 @@
mode = .simd
extra_cflags = -s SIMD=1
extra_ldflags = -s SIMD=1
include build/emscripten

View file

@ -0,0 +1,9 @@
cc = gcc
cxx = g++
cflags = -fdiagnostics-color -Wall -Wextra -ffp-contract=off -fstack-usage
out = out/gcc$mode
include build/local
include build/common
disabled = (uname | grep -qv Linux)

View file

@ -0,0 +1,3 @@
mode = .O0
extra_cflags = -O0
include build/gcc

View file

@ -0,0 +1,4 @@
mode = .m32
extra_cflags = -m32 -msse2 -mfpmath=sse
extra_ldflags = -m32
include build/gcc

View file

@ -0,0 +1,4 @@
mode = .m32-O0
extra_cflags = -m32 -msse2 -mfpmath=sse -O0
extra_ldflags = -m32
include build/gcc

View file

@ -0,0 +1,16 @@
mode = .mips64el
_toolchain = ../mips64el_toolchain_linux
_env = env LD_LIBRARY_PATH=$_toolchain/lib/x86_64-linux-gnu
out = out/gcc$mode
cflags = -fdiagnostics-color -Wall -Wextra -ffp-contract=off -fstack-usage
cc = $_env $_toolchain/bin/mips64el-linux-gnuabi64-gcc-7
cxx = $_env $_toolchain/bin/mips64el-linux-gnuabi64-g++-7
rule run
command = touch $out
description = skipping $in
include build/common
disabled = (uname | grep -qv Linux)

View file

@ -0,0 +1,16 @@
mode = .mips64el-O3
_toolchain = ../mips64el_toolchain_linux
_env = env LD_LIBRARY_PATH=$_toolchain/lib/x86_64-linux-gnu
out = out/gcc$mode
cflags = -fdiagnostics-color -Wall -Wextra -ffp-contract=off -fstack-usage -O3
cc = $_env $_toolchain/bin/mips64el-linux-gnuabi64-gcc-7
cxx = $_env $_toolchain/bin/mips64el-linux-gnuabi64-g++-7
rule run
command = touch $out
description = skipping $in
include build/common
disabled = (uname | grep -qv Linux)

View file

@ -0,0 +1,6 @@
mode = .musl
extra_ldflags = -static
include build/gcc
cc = env REALGCC=gcc musl-gcc
cxx = env REALGCC=g++ musl-gcc

View file

@ -0,0 +1,3 @@
mode = .native
extra_cflags = -march=native
include build/gcc

View file

@ -0,0 +1,3 @@
mode = .portable
extra_cflags = -DSKCMS_PORTABLE
include build/gcc

View file

@ -0,0 +1,3 @@
mode = .tiny
extra_cflags = -g0 -DNDEBUG -fno-unwind-tables -fno-asynchronous-unwind-tables
include build/gcc

View file

@ -0,0 +1,4 @@
mode = .xsan
extra_cflags = -fsanitize=address,undefined -fno-sanitize-recover=all
extra_ldflags = -fsanitize=address,undefined
include build/gcc

View file

@ -0,0 +1,11 @@
cc = clang -arch arm64 -isysroot `xcrun --sdk iphoneos --show-sdk-path`
cxx = clang++ -arch arm64 -isysroot `xcrun --sdk iphoneos --show-sdk-path`
cflags = -fcolor-diagnostics -Weverything
out = out/ios$mode
rule run
command = touch $out
description = skipping $in
include build/common
disabled = (uname | grep -qv Darwin)

View file

@ -0,0 +1,3 @@
mode = .portable
extra_cflags = -DSKCMS_PORTABLE
include build/ios

View file

@ -0,0 +1,3 @@
mode = .tiny
extra_cflags = -g0 -DNDEBUG -fno-unwind-tables -fno-asynchronous-unwind-tables
include build/ios

View file

@ -0,0 +1,7 @@
mode = .xsan
extra_cflags = -fsanitize=address,integer,undefined -fno-sanitize-recover=all
extra_ldflags = -fsanitize=address,integer,undefined
include build/ios
cc = /usr/bin/clang
cxx = /usr/bin/clang++

View file

@ -0,0 +1,3 @@
rule run
command = $disabled && touch $out || ./$in > $out
description = run $in

View file

@ -0,0 +1,27 @@
cl = cl.exe
cflags = /W4 /wd"4200" /wd"4201" /wd"4204" /wd"4221"
out = out/msvs$mode
exe = .exe
builddir = $out
rule run
command = cmd /c ""$in" > "$out""
description = run $in
rule compile_c
command = $cl /c /showIncludes /nologo /Zi /WX /MT /Fo"$out" /Fd"$out.pdb" $
$cflags $extra_cflags $in
deps = msvc
description = compile $out
rule compile_cc
command = $cl /c /showIncludes /nologo /Zi /WX /MT /Fo"$out" /Fd"$out.pdb" $
$cflags $extra_cflags $in
deps = msvc
description = compile $out
rule link
command = link.exe /nologo /DEBUG $extra_ldflags $in /OUT:"$out" /PDB:"$out.pdb"
description = link $out
include build/targets

View file

@ -0,0 +1,4 @@
mode = .analyze
extra_cflags = /analyze /RTCcsu /guard:cf
extra_ldflags = /guard:cf
include build/msvs

View file

@ -0,0 +1,5 @@
mode = .clang
include build/msvs
cl = "../clang_win/bin/clang-cl.exe"

View file

@ -0,0 +1,6 @@
mode = .clang-fast
extra_cflags = /O2 /Zc:inline
include build/msvs
cl = "../clang_win/bin/clang-cl.exe"

View file

@ -0,0 +1,3 @@
mode = .fast
extra_cflags = /O2 /Zc:inline
include build/msvs

View file

@ -0,0 +1,30 @@
build $out/skcms.o: compile_cc skcms.cc
build $out/test_only.o: compile_c test_only.c
build $out/tests.o: compile_c tests.c
build $out/tests$exe: link $out/skcms.o $out/tests.o $out/test_only.o
build $out/tests.ok: run $out/tests$exe
build $out/bench.o: compile_c bench.c
build $out/bench$exe: link $out/skcms.o $out/bench.o
build $out/iccdump.o: compile_c iccdump.c
build $out/iccdump$exe: link $out/skcms.o $out/iccdump.o $out/test_only.o
build $out/fuzz/fuzz_main.o: compile_c fuzz/fuzz_main.c
build $out/fuzz/fuzz_iccprofile_atf.o: compile_c fuzz/fuzz_iccprofile_atf.c
build $out/fuzz_iccprofile_atf$exe: link $out/fuzz/fuzz_iccprofile_atf.o $
$out/fuzz/fuzz_main.o $
$out/skcms.o
build $out/fuzz/fuzz_iccprofile_info.o: compile_c fuzz/fuzz_iccprofile_info.c
build $out/fuzz_iccprofile_info$exe: link $out/fuzz/fuzz_iccprofile_info.o $
$out/fuzz/fuzz_main.o $
$out/skcms.o
build $out/fuzz/fuzz_iccprofile_transform.o: compile_c fuzz/fuzz_iccprofile_transform.c
build $out/fuzz_iccprofile_transform$exe: link $out/fuzz/fuzz_iccprofile_transform.o $
$out/fuzz/fuzz_main.o $
$out/skcms.o

View file

@ -24,14 +24,14 @@ environment:
shared: OFF
- compiler: vc14-cmake
configuration: Release
arch: x64
generator: Visual Studio 16 2019
shared: ON
- compiler: vc14-cmake
configuration: Debug
arch: Win32
generator: Visual Studio 16 2019
shared: OFF
- compiler: vc14-nmake
configuration: Release
cache:
@ -50,34 +50,51 @@ init:
- git config --global core.autocrlf input
before_build:
- 'FOR /F "tokens=* USEBACKQ" %%F IN (`C:\cygwin64\bin\cygpath -u %AV_TIFF_SOURCE%`) DO SET AV_TIFF_CYG_SOURCE=%%F'
- 'FOR /F "tokens=* USEBACKQ" %%F IN (`C:\cygwin64\bin\cygpath -u %AV_TIFF_INSTALL%`) DO SET AV_TIFF_CYG_INSTALL=%%F'
- 'if %compiler%==cygwin-cmake C:\cygwin64\setup-x86_64 -q -R C:\cygwin64 -s http://cygwin.mirror.constant.com -l %AV_TIFF_DOWNLOAD%\cygwin -P cmake,libjpeg-devel,zlib-devel'
- 'if %compiler%==cygwin-cmake set "PATH=C:\cygwin64\bin;%PATH%"'
- 'FOR /F "tokens=* USEBACKQ" %%F IN (`C:\Cygwin64\bin\cygpath -u %AV_TIFF_SOURCE%`) DO SET AV_TIFF_CYG_SOURCE=%%F'
- 'FOR /F "tokens=* USEBACKQ" %%F IN (`C:\Cygwin64\bin\cygpath -u %AV_TIFF_INSTALL%`) DO SET AV_TIFF_CYG_INSTALL=%%F'
- 'if %compiler%==cygwin-cmake C:\Cygwin64\setup-x86_64 -q -R C:\Cygwin64 -s http://cygwin.mirror.constant.com -l %AV_TIFF_DOWNLOAD%\cygwin -P cmake,libjpeg-devel,zlib-devel'
- 'if %compiler%==cygwin-cmake set "PATH=C:\Cygwin64\bin;%PATH%"'
- set
- 'if %compiler%==cygwin-cmake dir C:\Cygwin64\bin'
- 'if %compiler%==cygwin-cmake dir C:\Cygwin64\bin\cmake.exe'
- 'if %compiler%==cygwin-cmake C:\Cygwin64\bin\cmake.exe --version || echo CMake not found'
- 'if %compiler%==cygwin-cmake C:\Cygwin64\bin\cmake --version || echo CMake not found'
- 'if %compiler%==cygwin-cmake cygpath --version || echo cygpath not found'
- 'if %compiler%==cygwin-cmake cmake --version || echo CMake not found'
- set "AV_CMAKE_ARGS=-DBUILD_SHARED_LIBS:BOOL=%shared%"
- 'if %compiler%==cygwin-cmake set "AV_CMAKE_ARGS=%AV_CMAKE_ARGS% -Dfatal-warnings=ON"'
- 'if %compiler%==mingw32-cmake set "AV_CMAKE_ARGS=%AV_CMAKE_ARGS% -Dfatal-warnings=ON"'
- set "AV_CMAKE_ARGS=-DBUILD_SHARED_LIBS:BOOL=%shared%"
- set "AV_TIFF_CMAKE_SOURCE=%AV_TIFF_SOURCE%"
- set "AV_TIFF_CMAKE_INSTALL=%AV_TIFF_INSTALL%"
- 'if %compiler%==cygwin-cmake set "AV_TIFF_CMAKE_SOURCE=%AV_TIFF_CYG_SOURCE%'
- 'if %compiler%==cygwin-cmake set "AV_TIFF_CMAKE_INSTALL=%AV_TIFF_CYG_INSTALL%'
- 'if %compiler%==mingw-cmake set "PATH=C:\MinGW\bin;%PATH%"'
- 'if %compiler%==vc14-nmake call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" %platform%'
- mkdir %AV_TIFF_BUILD%
- cd %AV_TIFF_BUILD%
- echo Running cmake -G "%generator%" -DCMAKE_INSTALL_PREFIX=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_TIFF_CMAKE_SOURCE%
- if NOT %compiler%==vc14-nmake echo Running cmake -G "%generator%" -DCMAKE_INSTALL_PREFIX=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_TIFF_CMAKE_SOURCE%
- 'if %compiler%==cygwin-cmake bash -c "cmake -G \"%generator%\" -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%"'
- 'if %compiler%==mingw-cmake cmake -G "%generator%" -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%'
- 'if %compiler%==vc14-cmake cmake -G "%generator%" -A %arch% -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%'
- 'if %compiler%==vc14-cmake cmake -G "%generator%" -A x64 -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%'
build_script:
- cd %AV_TIFF_BUILD%
- if NOT %compiler%==vc14-nmake cd %AV_TIFF_BUILD%
- if %compiler%==vc14-nmake cd %AV_TIFF_SOURCE%
- 'if %compiler%==cygwin-cmake bash -c "cmake --build . --config %configuration% --target install"'
- 'if %compiler%==mingw-cmake cmake --build . --config %configuration% --target install'
- 'if %compiler%==vc14-cmake cmake --build . --config %configuration% --target install'
- 'if %compiler%==vc9-cmake cmake --build . --config %configuration% --target install'
- 'if %compiler%==vc14-nmake nmake /f Makefile.vc EXTRAFLAGS=/DHAVE_SNPRINTF=1'
- 'if %compiler%==vc14-nmake mkdir %AV_TIFF_INSTALL%'
- 'if %compiler%==vc14-nmake mkdir %AV_TIFF_INSTALL%\bin'
- 'if %compiler%==vc14-nmake mkdir %AV_TIFF_INSTALL%\lib'
- 'if %compiler%==vc14-nmake mkdir %AV_TIFF_INSTALL%\include'
- 'if %compiler%==vc14-nmake copy tools\*.exe %AV_TIFF_INSTALL%\bin'
- 'if %compiler%==vc14-nmake copy port\*.lib %AV_TIFF_INSTALL%\lib'
- 'if %compiler%==vc14-nmake copy libtiff\tiff.h %AV_TIFF_INSTALL%\include'
- 'if %compiler%==vc14-nmake copy libtiff\tiffio.h %AV_TIFF_INSTALL%\include'
- 'if %compiler%==vc14-nmake copy libtiff\tiffvers.h %AV_TIFF_INSTALL%\include'
- 'if %compiler%==vc14-nmake copy libtiff\tiffconf.h %AV_TIFF_INSTALL%\include'
- 'if %compiler%==vc14-nmake copy libtiff\tiffio.hxx %AV_TIFF_INSTALL%\include'
# scripts to run after build
after_build:
@ -92,6 +109,7 @@ before_test:
- 'if %compiler%==mingw-cmake ctest -V -C %configuration%'
- 'if %compiler%==vc14-cmake ctest -V -C %configuration%'
- 'if %compiler%==vc9-cmake ctest -V -C %configuration%'
# vc14-nmake does not support unit tests
# AppVeyor don't yet have a configurable retention policy, so this will
# eventually use up all the storage allowance.

View file

@ -1,6 +0,0 @@
---
BasedOnStyle: llvm
IndentWidth: 4
ColumnLimit: 80
BreakBeforeBraces: Allman
IndentCaseLabels: true

View file

@ -1,4 +0,0 @@
42173d6ace476b5228d866640b5355f74e5a108d
b0ae5d7071890160da67d2e833d84a400e0406d0
dee020782c17c1388ca5774f9904d318b51b288b
aee0113f5ec1fd39b97458539bd79a1447425ac4

View file

@ -4,8 +4,6 @@ configure
Makefile.in
config/compile
config/config.guess
config/config.h
config/config.h.in
config/config.sub
config/depcomp
config/install-sh
@ -32,6 +30,7 @@ libtiff/mkg3states
libtiff/stamp-h1
libtiff/stamp-h2
libtiff/tif_config.h
libtiff/tif_config.h.in
libtiff/tiffconf.h
libtool
m4/libtool.m4
@ -76,7 +75,3 @@ test/*.log
test/*.trs
test/o-*
*~
.idea
.vs
cmake-build*
build*

View file

@ -1,60 +1,33 @@
image: registry.gitlab.com/libtiff/libtiff-ci-ubuntu22.04:latest
image: ubuntu:20.04
before_script:
- apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq autoconf automake build-essential cmake libtool libjpeg8-dev libjbig-dev liblzma-dev ninja-build zlib1g-dev libdeflate-dev zip wget
stages:
- build
- static-analysis
- pages
autoconf-current:
autoconf:
stage: build
script:
- sh build/gitlab-ci autoconf
after_script:
- 'cat autoconf-build/test/test-suite.log'
artifacts:
name: distribution
paths:
- distribution
autoconf-old:
stage: build
image: registry.gitlab.com/libtiff/libtiff-ci-ubuntu20.04:latest
script:
- sh build/gitlab-ci autoconf-minimal
after_script:
- 'cat autoconf-build/test/test-suite.log'
cmake-makefiles-current:
cmake-makefiles:
stage: build
script:
- sh build/gitlab-ci cmake "Unix Makefiles" Release
cmake-ninja-current:
cmake-ninja:
stage: build
script:
- sh build/gitlab-ci cmake "Ninja" Debug
cmake-makefiles-old:
stage: build
image: registry.gitlab.com/libtiff/libtiff-ci-ubuntu20.04:latest
script:
- sh build/gitlab-ci cmake "Unix Makefiles" Release
coverity:
stage: static-analysis
image: registry.gitlab.com/libtiff/libtiff-ci-ubuntu22.04-coverity:latest
script:
- sh build/gitlab-ci coverity "Ninja" Debug
only:
refs:
- master
pages:
stage: pages
script:
- sh build/gitlab-ci cmake "Ninja" Debug
- cp -r cmake-install/share/doc/tiff/manual/html public
- cp -r html public
artifacts:
name: $CI_PROJECT_NAME-$CI_JOB_NAME
paths:

View file

@ -1,22 +0,0 @@
repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: 'v15.0.4'
hooks:
- id: clang-format
# tif_fax3sm.c is a generated file
# tiffvers.h as well, and its formatting is sensitive for
# FindTIFF.cmake to detect the version number
# Furthermore, the .in files are formatting sensitive for
# cmake functions.
exclude: >
(?x)^(
libtiff/tif_fax3sm.c|
libtiff/tiffvers.h|
libtiff/tiffvers.h.in|
libtiff/tif_config.h|
libtiff/tif_config.h.in|
libtiff/tif_config.h.cmake.in|
libtiff/tiffconf.h|
libtiff/tiffconf.h.in|
libtiff/tiffconf.h.cmake.in
)

View file

@ -0,0 +1,29 @@
language: c
sudo: false
dist: trusty
cache:
directories:
- download
addons:
apt_packages:
- libjpeg8-dev
- libjbig-dev
- liblzma-dev
- zlib1g-dev
- zip
os:
- linux
- osx
env:
matrix:
- BUILD=autoconf
- BUILD=cmake TOOL="Unix Makefiles" TYPE=Release
- BUILD=cmake TOOL="Ninja" TYPE=Debug
script:
- sh ./build/travis-ci "$BUILD" "$TOOL" "$TYPE"

View file

@ -2,7 +2,6 @@
# Run "cmake" to generate the build files for your platform
#
# Copyright © 2015 Open Microscopy Environment / University of Dundee
# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
# Written by Roger Leigh <rleigh@codelibre.net>
#
# Permission to use, copy, modify, distribute, and sell this software and
@ -24,158 +23,739 @@
# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
# OF THIS SOFTWARE.
cmake_minimum_required(VERSION 3.9.0)
cmake_minimum_required(VERSION 2.8.11) # b/c of use of BUILD_INTERFACE generator expression
# Default policy is from 3.9.0
cmake_policy(VERSION 3.9.0)
# Find CMake modules in cmake/
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
# Default policy is from 2.8.9
cmake_policy(VERSION 2.8.9)
# Set MacOSX @rpath usage globally.
if (POLICY CMP0020)
cmake_policy(SET CMP0020 NEW)
endif(POLICY CMP0020)
if (POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif(POLICY CMP0042)
# Use new variable expansion policy.
if (POLICY CMP0053)
cmake_policy(SET CMP0053 NEW)
endif(POLICY CMP0053)
if (POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif(POLICY CMP0054)
# Read version information from configure.ac.
include(AutotoolsVersion)
message(STATUS "Building tiff version ${LIBTIFF_VERSION_FULL}")
message(STATUS "libtiff library version ${SO_VERSION}")
string(TIMESTAMP BUILD_DATE "%Y%m%d")
message(STATUS "libtiff build date: ${BUILD_DATE}")
FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/configure.ac" configure REGEX "^LIBTIFF_.*=")
foreach(line ${configure})
foreach(var LIBTIFF_MAJOR_VERSION LIBTIFF_MINOR_VERSION LIBTIFF_MICRO_VERSION LIBTIFF_ALPHA_VERSION
LIBTIFF_CURRENT LIBTIFF_REVISION LIBTIFF_AGE)
if(NOT ${var} AND line MATCHES "^${var}=(.*)")
set(${var} "${CMAKE_MATCH_1}")
break()
endif()
endforeach()
endforeach()
# Project definition
set(CMAKE_C_STANDARD 99)
project(tiff
VERSION "${LIBTIFF_VERSION}"
LANGUAGES C CXX)
math(EXPR SO_MAJOR "${LIBTIFF_CURRENT} - ${LIBTIFF_AGE}")
set(SO_MINOR "${LIBTIFF_AGE}")
set(SO_REVISION "${LIBTIFF_REVISION}")
if(NOT CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
# libtiff is being included as a subproject of some other project.
set(TIFF_INSTALL_DEFAULT OFF)
else()
set(TIFF_INSTALL_DEFAULT ON)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
endif()
message(STATUS "Building tiff version ${LIBTIFF_MAJOR_VERSION}.${LIBTIFF_MINOR_VERSION}.${LIBTIFF_MICRO_VERSION}${LIBTIFF_ALPHA_VERSION}")
message(STATUS "libtiff library version ${SO_MAJOR}.${SO_MINOR}.${SO_REVISION}")
option(tiff-tools "build TIFF tools" ON)
option(tiff-tests "build TIFF tests" ON)
option(tiff-contrib "build TIFF contrib" ON)
option(tiff-docs "build TIFF documentation" ON)
option(tiff-deprecated "build TIFF deprecated features" OFF)
option(tiff-install "install TIFF targets" ${TIFF_INSTALL_DEFAULT})
set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries")
# Disable deprecated features to ensure clean build
if (tiff-deprecated)
add_definitions(-DTIFF_DISABLE_DEPRECATED)
endif()
# Project version
project(tiff C)
set(VERSION "${LIBTIFF_MAJOR_VERSION}.${LIBTIFF_MINOR_VERSION}.${LIBTIFF_MICRO_VERSION}")
set(tiff_VERSION "${VERSION}")
set(tiff_VERSION_MAJOR "${LIBTIFF_MAJOR_VERSION}")
set(tiff_VERSION_MINOR "${LIBTIFF_MINOR_VERSION}")
set(tiff_VERSION_PATCH "${LIBTIFF_MICRO_VERSION}")
# Autotools compatibility
include(AutotoolsCompat)
# the other tiff_VERSION_* variables are set automatically
set(tiff_VERSION_ALPHA "${LIBTIFF_ALPHA_VERSION}")
# Library version (unlike libtool's baroque scheme, WYSIWYG here)
set(SO_COMPATVERSION "${SO_MAJOR}")
set(SO_VERSION "${SO_MAJOR}.${SO_MINOR}.${SO_REVISION}")
# Compiler checks (warning flags, etc.)
include(CompilerChecks)
# For autotools header compatibility
set(PACKAGE_NAME "LibTIFF Software")
set(PACKAGE_TARNAME "${PROJECT_NAME}")
set(PACKAGE_VERSION "${PROJECT_VERSION}${tiff_VERSION_ALPHA}")
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "tiff@lists.maptools.org")
# Linker checks (version script, etc.)
include(LinkerChecks)
# Processor checks (endianness, fill order, floating point, etc.)
include(ProcessorChecks)
# Checks for headers
include(IncludeChecks)
# Checks for functions and other symbols
include(SymbolChecks)
# Standard installation paths
include(GNUInstallDirs)
# Documentation install directory (default to cmake project docdir)
set(LIBTIFF_DOCDIR "${CMAKE_INSTALL_DOCDIR}")
# CTest testing
include(CheckCCompilerFlag)
include(CheckCSourceCompiles)
include(CheckIncludeFile)
include(CheckLibraryExists)
include(CheckTypeSize)
include(CheckSymbolExists)
enable_testing()
# Checks for type presence and size
include(TypeSizeChecks)
macro(current_date var)
if(UNIX)
execute_process(COMMAND "date" +"%Y%m%d" OUTPUT_VARIABLE ${var})
endif()
endmacro()
# Check for POSIX Large File Support (LFS)
include(LargeFileSupport)
current_date(RELEASE_DATE)
# Options for internal codec support
include(InternalCodecs)
macro(extra_dist)
foreach(file ${ARGV})
file(RELATIVE_PATH relfile "${PROJECT_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/${file}")
list(APPEND EXTRA_DIST "${relfile}")
endforeach()
set(EXTRA_DIST "${EXTRA_DIST}" PARENT_SCOPE)
endmacro()
# Check for Deflate codec
include(DeflateCodec)
set(EXTRA_DIST
HOWTO-RELEASE
Makefile.vc
SConstruct
autogen.sh
configure.com
nmake.opt
libtiff-4.pc.in)
# Check for PixarLog codec
include(PixarLogCodec)
# These are annoyingly verbose, produce false positives or don't work
# nicely with all supported compiler versions, so are disabled unless
# explicitly enabled.
option(extra-warnings "Enable extra compiler warnings" OFF)
# Check for JPEG codec
include(JPEGCodec)
# This will cause the compiler to fail when an error occurs.
option(fatal-warnings "Compiler warnings are errors" OFF)
# Check for JBIG codec
include(JBIGCodec)
# Check if the compiler supports each of the following additional
# flags, and enable them if supported. This greatly improves the
# quality of the build by checking for a number of common problems,
# some of which are quite serious.
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
CMAKE_C_COMPILER_ID MATCHES "Clang")
set(test_flags
-Wall
-Winline
-W
-Wformat-security
-Wpointer-arith
-Wdisabled-optimization
-Wno-unknown-pragmas
-Wdeclaration-after-statement
-fstrict-aliasing)
if(extra-warnings)
list(APPEND test_flags
-Wfloat-equal
-Wmissing-prototypes
-Wunreachable-code)
endif()
if(fatal-warnings)
list(APPEND test_flags
-Werror)
endif()
elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
set(test_flags)
if(extra-warnings)
list(APPEND test_flags
/W4)
else()
list(APPEND test_flags
/W3)
endif()
if (fatal-warnings)
list(APPEND test_flags
/WX)
endif()
endif()
# Check for LERC codec
include(LERCCodec)
foreach(flag ${test_flags})
string(REGEX REPLACE "[^A-Za-z0-9]" "_" flag_var "${flag}")
set(test_c_flag "C_FLAG${flag_var}")
CHECK_C_COMPILER_FLAG(${flag} "${test_c_flag}")
if (${test_c_flag})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
endif (${test_c_flag})
endforeach(flag ${test_flags})
# Check for LZMA codec
include(LZMACodec)
if(MSVC)
set(CMAKE_DEBUG_POSTFIX "d")
endif()
# Check for ZSTD codec
include(ZSTDCodec)
option(ld-version-script "Enable linker version script" ON)
# Check if LD supports linker scripts.
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "VERS_1 {
global: sym;
};
# Check for WebP codec
include(WebPCodec)
VERS_2 {
global: sym;
} VERS_1;
")
set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
check_c_source_compiles("int main(void){return 0;}" HAVE_LD_VERSION_SCRIPT)
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE})
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
if (ld-version-script AND HAVE_LD_VERSION_SCRIPT)
set(HAVE_LD_VERSION_SCRIPT TRUE)
else()
set(HAVE_LD_VERSION_SCRIPT FALSE)
endif()
# Option for C++ libtiffxx library
include(CXXLibrary)
# Find libm, if available
if(NOT WIN32)
find_library(M_LIBRARY m)
endif()
# Checks for OpenGL support
include(OpenGLChecks)
check_include_file(assert.h HAVE_ASSERT_H)
check_include_file(dlfcn.h HAVE_DLFCN_H)
check_include_file(fcntl.h HAVE_FCNTL_H)
check_include_file(inttypes.h HAVE_INTTYPES_H)
check_include_file(io.h HAVE_IO_H)
check_include_file(search.h HAVE_SEARCH_H)
check_include_file(stdint.h HAVE_STDINT_H)
check_include_file(string.h HAVE_STRING_H)
check_include_file(strings.h HAVE_STRINGS_H)
check_include_file(sys/time.h HAVE_SYS_TIME_H)
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_include_file(unistd.h HAVE_UNISTD_H)
# Windows support
include(WindowsSupport)
# Inspired from /usr/share/autoconf/autoconf/c.m4
foreach(inline_keyword "inline" "__inline__" "__inline")
if(NOT DEFINED C_INLINE)
set(CMAKE_REQUIRED_DEFINITIONS_SAVE ${CMAKE_REQUIRED_DEFINITIONS})
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
"-Dinline=${inline_keyword}")
check_c_source_compiles("
typedef int foo_t;
static inline foo_t static_foo() {return 0;}
foo_t foo(){return 0;}
int main(int argc, char *argv[]) {return 0;}"
C_HAS_${inline_keyword})
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS_SAVE})
if(C_HAS_${inline_keyword})
set(C_INLINE TRUE)
set(INLINE_KEYWORD "${inline_keyword}")
endif()
endif()
endforeach()
if(NOT DEFINED C_INLINE)
set(INLINE_KEYWORD)
endif()
# off_t and size_t checks omitted; not clear they are used at all
# Are off_t and size_t checks strictly necessary?
# Check if sys/time.h and time.h allow use together
check_c_source_compiles("
#include <sys/time.h>
#include <time.h>
int main(void){return 0;}"
TIME_WITH_SYS_TIME)
# Check if struct tm is in sys/time.h
check_c_source_compiles("
#include <sys/types.h>
#include <time.h>
int main(void){
struct tm tm;
int *p = &tm.tm_sec;
return !p;
}"
TM_IN_SYS_TIME)
# Check type sizes
# NOTE: Could be replaced with C99 <stdint.h>
check_type_size("signed int" SIZEOF_SIGNED_INT)
check_type_size("unsigned int" SIZEOF_UNSIGNED_INT)
check_type_size("signed long" SIZEOF_SIGNED_LONG)
check_type_size("unsigned long" SIZEOF_UNSIGNED_LONG)
check_type_size("signed long long" SIZEOF_SIGNED_LONG_LONG)
check_type_size("unsigned long long" SIZEOF_UNSIGNED_LONG_LONG)
check_type_size("unsigned char *" SIZEOF_UNSIGNED_CHAR_P)
set(CMAKE_EXTRA_INCLUDE_FILES_SAVE ${CMAKE_EXTRA_INCLUDE_FILES})
set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} "stddef.h")
check_type_size("size_t" SIZEOF_SIZE_T)
check_type_size("ptrdiff_t" SIZEOF_PTRDIFF_T)
set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES_SAVE})
macro(report_values)
foreach(val ${ARGV})
message(STATUS "${val} set to ${${val}}")
endforeach()
endmacro()
set(TIFF_INT8_T "signed char")
set(TIFF_UINT8_T "unsigned char")
set(TIFF_INT16_T "signed short")
set(TIFF_UINT16_T "unsigned short")
if(SIZEOF_SIGNED_INT EQUAL 4)
set(TIFF_INT32_T "signed int")
set(TIFF_INT32_FORMAT "%d")
elseif(SIZEOF_SIGNED_LONG EQUAL 4)
set(TIFF_INT32_T "signed long")
set(TIFF_INT32_FORMAT "%ld")
endif()
if(SIZEOF_UNSIGNED_INT EQUAL 4)
set(TIFF_UINT32_T "unsigned int")
set(TIFF_UINT32_FORMAT "%u")
elseif(SIZEOF_UNSIGNED_LONG EQUAL 4)
set(TIFF_UINT32_T "unsigned long")
set(TIFF_UINT32_FORMAT "%lu")
endif()
if(SIZEOF_SIGNED_LONG EQUAL 8)
set(TIFF_INT64_T "signed long")
set(TIFF_INT64_FORMAT "%ld")
elseif(SIZEOF_SIGNED_LONG_LONG EQUAL 8)
set(TIFF_INT64_T "signed long long")
if (WIN32)
set(TIFF_INT64_FORMAT "%I64d")
else()
set(TIFF_INT64_FORMAT "%lld")
endif()
endif()
if(SIZEOF_UNSIGNED_LONG EQUAL 8)
set(TIFF_UINT64_T "unsigned long")
set(TIFF_UINT64_FORMAT "%lu")
elseif(SIZEOF_UNSIGNED_LONG_LONG EQUAL 8)
set(TIFF_UINT64_T "unsigned long long")
if (WIN32)
set(TIFF_UINT64_FORMAT "%I64u")
else()
set(TIFF_UINT64_FORMAT "%llu")
endif()
endif()
if(SIZEOF_UNSIGNED_INT EQUAL SIZEOF_SIZE_T)
set(TIFF_SIZE_T "unsigned int")
set(TIFF_SIZE_FORMAT "%u")
set(TIFF_SSIZE_T "signed int")
set(TIFF_SSIZE_FORMAT "%d")
elseif(SIZEOF_UNSIGNED_LONG EQUAL SIZEOF_SIZE_T)
set(TIFF_SIZE_T "unsigned long")
set(TIFF_SIZE_FORMAT "%lu")
set(TIFF_SSIZE_T "signed long")
set(TIFF_SSIZE_FORMAT "%ld")
elseif(SIZEOF_UNSIGNED_LONG_LONG EQUAL SIZEOF_SIZE_T)
set(TIFF_SIZE_T "unsigned long long")
set(TIFF_SSIZE_T "signed long long")
if (WIN32)
set(TIFF_SIZE_FORMAT "%I64u")
set(TIFF_SSIZE_FORMAT "%I64d")
else()
set(TIFF_SIZE_FORMAT "%llu")
set(TIFF_SSIZE_FORMAT "%lld")
endif()
endif()
if(NOT SIZEOF_PTRDIFF_T)
set(TIFF_PTRDIFF_T "${TIFF_SSIZE_T}")
set(TIFF_PTRDIFF_FORMAT "${SSIZE_FORMAT}")
else()
set(TIFF_PTRDIFF_T "ptrdiff_t")
set(TIFF_PTRDIFF_FORMAT "%ld")
endif()
#report_values(TIFF_INT8_T TIFF_INT8_FORMAT
# TIFF_UINT8_T TIFF_UINT8_FORMAT
# TIFF_INT16_T TIFF_INT16_FORMAT
# TIFF_UINT16_T TIFF_UINT16_FORMAT
# TIFF_INT32_T TIFF_INT32_FORMAT
# TIFF_UINT32_T TIFF_UINT32_FORMAT
# TIFF_INT64_T TIFF_INT64_FORMAT
# TIFF_UINT64_T TIFF_UINT64_FORMAT
# TIFF_SSIZE_T TIFF_SSIZE_FORMAT
# TIFF_PTRDIFF_T TIFF_PTRDIFF_FORMAT)
check_symbol_exists(mmap "sys/mman.h" HAVE_MMAP)
check_symbol_exists(setmode "unistd.h" HAVE_SETMODE)
check_symbol_exists(snprintf "stdio.h" HAVE_SNPRINTF)
check_symbol_exists(strcasecmp "strings.h" HAVE_STRCASECMP)
check_symbol_exists(strtol "stdlib.h" HAVE_STRTOL)
check_symbol_exists(strtoll "stdlib.h" HAVE_STRTOLL)
check_symbol_exists(strtoul "stdlib.h" HAVE_STRTOUL)
check_symbol_exists(strtoull "stdlib.h" HAVE_STRTOULL)
check_symbol_exists(getopt "unistd.h;stdio.h" HAVE_GETOPT)
check_symbol_exists(lfind "search.h" HAVE_LFIND)
if(NOT HAVE_SNPRINTF)
add_definitions(-DNEED_LIBPORT)
endif()
# CPU bit order
set(HOST_FILLORDER FILLORDER_MSB2LSB)
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "i.*86.*" OR
CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64.*" OR
# AMD64 on Windows
CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "AMD64" OR
CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64.*")
set(HOST_FILLORDER FILLORDER_LSB2MSB)
endif()
# CPU endianness
include(TestBigEndian)
test_big_endian(HOST_BIG_ENDIAN)
if(HOST_BIG_ENDIAN)
add_definitions(-DWORDS_BIGENDIAN)
endif()
# IEEE floating point
set(HAVE_IEEEFP 1)
report_values(CMAKE_HOST_SYSTEM_PROCESSOR HOST_FILLORDER
HOST_BIG_ENDIAN HAVE_IEEEFP)
# Large file support
if (UNIX OR MINGW)
# This might not catch every possibility catered for by
# AC_SYS_LARGEFILE.
add_definitions(-D_FILE_OFFSET_BITS=64)
set(FILE_OFFSET_BITS 64)
endif()
# Documentation install directory (default to cmake project docdir)
set(LIBTIFF_DOCDIR "${CMAKE_INSTALL_FULL_DOCDIR}")
# Options to enable and disable internal codecs
option(ccitt "support for CCITT Group 3 & 4 algorithms" ON)
set(CCITT_SUPPORT ${ccitt})
option(packbits "support for Macintosh PackBits algorithm" ON)
set(PACKBITS_SUPPORT ${packbits})
option(lzw "support for LZW algorithm" ON)
set(LZW_SUPPORT ${lzw})
option(thunder "support for ThunderScan 4-bit RLE algorithm" ON)
set(THUNDER_SUPPORT ${thunder})
option(next "support for NeXT 2-bit RLE algorithm" ON)
set(NEXT_SUPPORT ${next})
option(logluv "support for LogLuv high dynamic range algorithm" ON)
set(LOGLUV_SUPPORT ${logluv})
# Option for Microsoft Document Imaging
option(mdi "support for Microsoft Document Imaging" ON)
set(MDI_SUPPORT ${mdi})
# ZLIB
option(zlib "use zlib (required for Deflate compression)" ON)
if (zlib)
find_package(ZLIB)
endif()
set(ZLIB_SUPPORT 0)
if(ZLIB_FOUND)
set(ZLIB_SUPPORT 1)
endif()
set(ZIP_SUPPORT ${ZLIB_SUPPORT})
# libdeflate
option(libdeflate "use libdeflate (optional for faster Deflate support, still requires zlib)" ON)
if (libdeflate)
set(DEFLATE_FOUND 0)
find_path(DEFLATE_INCLUDE_DIR libdeflate.h)
set(DEFLATE_NAMES ${DEFLATE_NAMES} deflate)
find_library(DEFLATE_LIBRARY NAMES ${DEFLATE_NAMES})
if (DEFLATE_INCLUDE_DIR AND DEFLATE_LIBRARY)
set(DEFLATE_FOUND 1)
set(DEFLATE_LIBRARIES ${DEFLATE_LIBRARY})
endif()
endif()
set(LIBDEFLATE_SUPPORT FALSE)
if(DEFLATE_FOUND)
set(LIBDEFLATE_SUPPORT TRUE)
endif()
if(LIBDEFLATE_SUPPORT AND NOT ZIP_SUPPORT)
message(WARNING "libdeflate available but zlib is not. libdeflate cannot be used")
set(LIBDEFLATE_SUPPORT FALSE)
endif()
set(LIBDEFLATE_SUPPORT ${LIBDEFLATE_SUPPORT})
# Option for Pixar log-format algorithm
# Pixar log format
option(pixarlog "support for Pixar log-format algorithm (requires Zlib)" ON)
set(PIXARLOG_SUPPORT FALSE)
if (ZLIB_SUPPORT)
if(pixarlog)
set(PIXARLOG_SUPPORT TRUE)
endif()
endif()
# JPEG
option(jpeg "use libjpeg (required for JPEG compression)" ON)
if (jpeg)
find_package(JPEG)
endif()
set(JPEG_SUPPORT FALSE)
if(JPEG_FOUND)
set(JPEG_SUPPORT TRUE)
endif()
option(old-jpeg "support for Old JPEG compression (read-only)" ON)
set(OJPEG_SUPPORT FALSE)
if (JPEG_SUPPORT)
if (old-jpeg)
set(OJPEG_SUPPORT TRUE)
endif()
endif()
# JBIG-KIT
option(jbig "use ISO JBIG compression (requires JBIT-KIT library)" ON)
if (jbig)
set(JBIG_FOUND 0)
find_path(JBIG_INCLUDE_DIR jbig.h)
set(JBIG_NAMES ${JBIG_NAMES} jbig libjbig)
find_library(JBIG_LIBRARY NAMES ${JBIG_NAMES})
if (JBIG_INCLUDE_DIR AND JBIG_LIBRARY)
set(JBIG_FOUND 1)
set(JBIG_LIBRARIES ${JBIG_LIBRARY})
endif()
endif()
set(JBIG_SUPPORT 0)
if(JBIG_FOUND)
set(JBIG_FOUND TRUE)
set(JBIG_SUPPORT 1)
else()
set(JBIG_FOUND FALSE)
endif()
set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES})
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${JBIG_INCLUDE_DIR})
check_symbol_exists(jbg_newlen "jbig.h" HAVE_JBG_NEWLEN)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE})
# liblzma2
option(lzma "use liblzma (required for LZMA2 compression)" ON)
if (lzma)
find_package(LibLZMA)
endif()
set(LZMA_SUPPORT 0)
if(LIBLZMA_FOUND)
set(LZMA_SUPPORT 1)
endif()
# libzstd
option(zstd "use libzstd (required for ZSTD compression)" ON)
if (zstd)
find_path(ZSTD_INCLUDE_DIR zstd.h)
find_library(ZSTD_LIBRARY NAMES zstd)
if (ZSTD_INCLUDE_DIR AND ZSTD_LIBRARY)
check_library_exists ("${ZSTD_LIBRARY}" ZSTD_decompressStream "" ZSTD_RECENT_ENOUGH)
if (ZSTD_RECENT_ENOUGH)
set(ZSTD_FOUND TRUE)
set(ZSTD_LIBRARIES ${ZSTD_LIBRARY})
message(STATUS "Found ZSTD library: ${ZSTD_LIBRARY}")
else ()
message(WARNING "Found ZSTD library, but not recent enough. Use zstd >= 1.0")
endif ()
endif ()
endif()
set(ZSTD_SUPPORT 0)
if(ZSTD_FOUND)
set(ZSTD_SUPPORT 1)
endif()
# libwebp
option(webp "use libwebp (required for WEBP compression)" ON)
if (webp)
find_path(WEBP_INCLUDE_DIR /webp/decode.h)
find_library(WEBP_LIBRARY NAMES webp)
endif()
set(WEBP_SUPPORT 0)
set(WEBP_FOUND FALSE)
if (WEBP_INCLUDE_DIR AND WEBP_LIBRARY)
set(WEBP_SUPPORT 1)
set(WEBP_FOUND TRUE)
set(WEBP_LIBRARIES ${WEBP_LIBRARY})
message(STATUS "Found WEBP library: ${WEBP_LIBRARY}")
endif()
# 8/12-bit jpeg mode
option(jpeg12 "enable libjpeg 8/12-bit dual mode (requires separate
12-bit libjpeg build)" ON)
set(JPEG12_INCLUDE_DIR JPEG12_INCLUDE_DIR-NOTFOUND CACHE PATH "Include directory for 12-bit libjpeg")
set(JPEG12_LIBRARY JPEG12_LIBRARY-NOTFOUND CACHE FILEPATH "12-bit libjpeg library")
set(JPEG12_FOUND FALSE)
if (JPEG12_INCLUDE_DIR AND JPEG12_LIBRARY)
set(JPEG12_LIBRARIES ${JPEG12_LIBRARY})
set(JPEG12_FOUND TRUE)
endif()
if (JPEG12_FOUND)
set(JPEG_DUAL_MODE_8_12 1)
set(LIBJPEG_12_PATH "${JPEG12_INCLUDE_DIR}/jpeglib.h")
endif()
# C++ support
option(cxx "Enable C++ stream API building (requires C++ compiler)" ON)
set(CXX_SUPPORT FALSE)
if (cxx)
enable_language(CXX)
set(CXX_SUPPORT TRUE)
endif()
# OpenGL and GLUT
find_package(OpenGL)
find_package(GLUT)
set(HAVE_OPENGL FALSE)
if(OPENGL_FOUND AND OPENGL_GLU_FOUND AND GLUT_FOUND)
set(HAVE_OPENGL TRUE)
endif()
# Purely to satisfy the generated headers:
check_include_file(GL/gl.h HAVE_GL_GL_H)
check_include_file(GL/glu.h HAVE_GL_GLU_H)
check_include_file(GL/glut.h HAVE_GL_GLUT_H)
check_include_file(GLUT/glut.h HAVE_GLUT_GLUT_H)
check_include_file(OpenGL/gl.h HAVE_OPENGL_GL_H)
check_include_file(OpenGL/glu.h HAVE_OPENGL_GLU_H)
# Win32 IO
set(win32_io FALSE)
if(WIN32)
set(win32_io TRUE)
endif()
set(USE_WIN32_FILEIO ${win32_io})
# Orthogonal features
include(LibraryFeatures)
# Strip chopping
option(strip-chopping "strip chopping (whether or not to convert single-strip uncompressed images to mutiple strips of specified size to reduce memory usage)" ON)
set(TIFF_DEFAULT_STRIP_SIZE 8192 CACHE STRING "default size of the strip in bytes (when strip chopping is enabled)")
# math.h/libm portability
find_package(CMath REQUIRED)
set(STRIPCHOP_DEFAULT)
if(strip-chopping)
set(STRIPCHOP_DEFAULT TRUE)
if(TIFF_DEFAULT_STRIP_SIZE)
set(STRIP_SIZE_DEFAULT "${TIFF_DEFAULT_STRIP_SIZE}")
endif()
endif()
# Release support
include(Release)
# Defer loading of strip/tile offsets
option(defer-strile-load "enable deferred strip/tile offset/size loading (also available at runtime with the 'D' flag of TIFFOpen())" OFF)
set(DEFER_STRILE_LOAD ${defer-strile-load})
# CHUNKY_STRIP_READ_SUPPORT
option(chunky-strip-read "enable reading large strips in chunks for TIFFReadScanline() (experimental)" OFF)
set(CHUNKY_STRIP_READ_SUPPORT ${chunky-strip-read})
# SUBIFD support
set(SUBIFD_SUPPORT 1)
# Default handling of ASSOCALPHA support.
option(extrasample-as-alpha "the RGBA interface will treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many packages produce RGBA files but don't mark the alpha properly" ON)
if(extrasample-as-alpha)
set(DEFAULT_EXTRASAMPLE_AS_ALPHA 1)
endif()
# Default handling of YCbCr subsampling support.
# See Bug 168 in Bugzilla, and JPEGFixupTestSubsampling() for details.
option(check-ycbcr-subsampling "enable picking up YCbCr subsampling info from the JPEG data stream to support files lacking the tag" ON)
if (check-ycbcr-subsampling)
set(CHECK_JPEG_YCBCR_SUBSAMPLING 1)
endif()
# Generate pkg-config file
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "${CMAKE_INSTALL_PREFIX}")
set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}")
set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libtiff-4.pc.in
${CMAKE_CURRENT_BINARY_DIR}/libtiff-4.pc)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libtiff-4.pc
DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig")
# Includes used by libtiff (and tests)
if(ZLIB_INCLUDE_DIRS)
list(APPEND TIFF_INCLUDES $<BUILD_INTERFACE:${ZLIB_INCLUDE_DIRS}>)
endif()
if(DEFLATE_INCLUDE_DIR)
list(APPEND TIFF_INCLUDES ${DEFLATE_INCLUDE_DIR})
endif()
if(JPEG_INCLUDE_DIR)
list(APPEND TIFF_INCLUDES ${JPEG_INCLUDE_DIR})
endif()
if(JPEG12_INCLUDE_DIR)
list(APPEND TIFF_INCLUDES ${JPEG12_INCLUDE_DIR})
endif()
if(JBIG_INCLUDE_DIR)
list(APPEND TIFF_INCLUDES ${JBIG_INCLUDE_DIR})
endif()
if(LIBLZMA_INCLUDE_DIRS)
list(APPEND TIFF_INCLUDES ${LIBLZMA_INCLUDE_DIRS})
endif()
if(ZSTD_INCLUDE_DIR)
list(APPEND TIFF_INCLUDES ${ZSTD_INCLUDE_DIR})
endif()
if(WEBP_INCLUDE_DIR)
list(APPEND TIFF_INCLUDES ${WEBP_INCLUDE_DIR})
endif()
# Libraries required by libtiff
set(TIFF_LIBRARY_DEPS)
if(NOT WIN32 AND M_LIBRARY)
list(APPEND TIFF_LIBRARY_DEPS "m")
endif()
if(ZLIB_LIBRARIES)
list(APPEND TIFF_LIBRARY_DEPS ${ZLIB_LIBRARIES})
endif()
if(DEFLATE_LIBRARIES)
list(APPEND TIFF_LIBRARY_DEPS ${DEFLATE_LIBRARIES})
endif()
if(JPEG_LIBRARIES)
list(APPEND TIFF_LIBRARY_DEPS ${JPEG_LIBRARIES})
endif()
if(JPEG12_LIBRARIES)
list(APPEND TIFF_LIBRARY_DEPS ${JPEG12_LIBRARIES})
endif()
if(JBIG_LIBRARIES)
list(APPEND TIFF_LIBRARY_DEPS ${JBIG_LIBRARIES})
endif()
if(LIBLZMA_LIBRARIES)
list(APPEND TIFF_LIBRARY_DEPS ${LIBLZMA_LIBRARIES})
endif()
if(ZSTD_LIBRARIES)
list(APPEND TIFF_LIBRARY_DEPS ${ZSTD_LIBRARIES})
endif()
if(WEBP_LIBRARIES)
list(APPEND TIFF_LIBRARY_DEPS ${WEBP_LIBRARIES})
endif()
#report_values(TIFF_INCLUDES TIFF_LIBRARY_DEPS)
# Process subdirectories
add_subdirectory(port)
add_subdirectory(libtiff)
if(tiff-tools)
add_subdirectory(tools)
endif()
if(tiff-tests)
add_subdirectory(test)
endif()
if(tiff-contrib)
add_subdirectory(contrib)
endif()
add_subdirectory(build)
if(tiff-docs)
add_subdirectory(doc)
endif()
#add_subdirectory(tools)
#add_subdirectory(test)
#add_subdirectory(contrib)
#add_subdirectory(build)
#add_subdirectory(man)
#add_subdirectory(html)
# pkg-config support
include(PkgConfig)
#message(STATUS "EXTRA_DIST: ${EXTRA_DIST}")
message(STATUS "")
message(STATUS "Libtiff is now configured for ${CMAKE_SYSTEM}")
message(STATUS "Libtiff is now configured for ${host}")
message(STATUS "")
message(STATUS " Installation directory: ${prefix}")
message(STATUS " Documentation directory: ${LIBTIFF_DOCDIR}")
message(STATUS " C compiler: ${CMAKE_C_COMPILER}")
message(STATUS " C++ compiler: ${CMAKE_CXX_COMPILER}")
message(STATUS " Build shared libraries: ${BUILD_SHARED_LIBS}")
message(STATUS " Build tools: ${tiff-tools}")
message(STATUS " Build tests: ${tiff-tests}")
message(STATUS " Build contrib: ${tiff-contrib}")
message(STATUS " Build docs: ${tiff-docs}")
message(STATUS " Build deprecated features: ${tiff-deprecated}")
message(STATUS " Enable linker symbol versioning: ${HAVE_LD_VERSION_SCRIPT}")
message(STATUS " Support Microsoft Document Imaging: ${mdi}")
message(STATUS " Use win32 IO: ${USE_WIN32_FILEIO}")
@ -189,40 +769,19 @@ message(STATUS " NeXT 2-bit RLE algorithm: ${next}")
message(STATUS " LogLuv high dynamic range encoding: ${logluv}")
message(STATUS "")
message(STATUS " Support for external codecs:")
message(STATUS " ZLIB support: Requested:${zlib} Availability:${ZLIB_FOUND} Support:${ZLIB_SUPPORT}")
if(ZLIB_SUPPORT)
message(STATUS " libdeflate support: Requested:${libdeflate} Availability:${DEFLATE_FOUND} Support:${LIBDEFLATE_SUPPORT}")
else()
message(STATUS " libdeflate support: Requested:${libdeflate} Availability:${DEFLATE_FOUND} Support:${LIBDEFLATE_SUPPORT} (Depends on ZLIB Support)")
endif()
if(ZLIB_SUPPORT)
message(STATUS " Pixar log-format algorithm: Requested:${pixarlog} Availability:${ZLIB_FOUND} Support:${PIXARLOG_SUPPORT}")
else()
message(STATUS " Pixar log-format algorithm: Requested:${pixarlog} Availability:${ZLIB_FOUND} Support:${PIXARLOG_SUPPORT} (Depends on ZLIB Support)")
endif()
message(STATUS " JPEG support: Requested:${jpeg} Availability:${JPEG_FOUND} Support:${JPEG_SUPPORT}")
if(JPEG_SUPPORT)
message(STATUS " Old JPEG support: Requested:${old-jpeg} Availability:${JPEG_SUPPORT} Support:${OJPEG_SUPPORT}")
else()
message(STATUS " Old JPEG support: Requested:${old-jpeg} Availability:${JPEG_SUPPORT} Support:${OJPEG_SUPPORT} (Depends on JPEG Support)")
endif()
if(JPEG_SUPPORT AND HAVE_JPEGTURBO_DUAL_MODE_8_12)
message(STATUS " JPEG 8/12 bit dual mode: Support: yes (libjpeg turbo >= 2.2 dual mode)")
else()
message(STATUS " JPEG 8/12 bit dual mode: Requested:${jpeg12} Availability:${JPEG12_FOUND} Support:${JPEG_DUAL_MODE_8_12}")
endif()
message(STATUS " ISO JBIG support: Requested:${jbig} Availability:${JBIG_FOUND} Support:${JBIG_SUPPORT}")
if(ZLIB_SUPPORT)
message(STATUS " LERC support: Requested:${lerc} Availability:${LERC_FOUND} Support:${LERC_SUPPORT}")
else()
message(STATUS " LERC support: Requested:${lerc} Availability:${LERC_FOUND} Support:${LERC_SUPPORT} (Depends on ZLIB Support)")
endif()
message(STATUS " LZMA2 support: Requested:${lzma} Availability:${liblzma_FOUND} Support:${LZMA_SUPPORT}")
message(STATUS " ZSTD support: Requested:${zstd} Availability:${ZSTD_USABLE} Support:${ZSTD_SUPPORT}")
message(STATUS " WEBP support: Requested:${webp} Availability:${WebP_FOUND} Support:${WEBP_SUPPORT}")
message(STATUS " ZLIB support: ${zlib} (requested) ${ZLIB_FOUND} (availability)")
message(STATUS " libdeflate support: ${libdeflate} (requested) ${LIBDEFLATE_SUPPORT} (availability)")
message(STATUS " Pixar log-format algorithm: ${pixarlog} (requested) ${PIXARLOG_SUPPORT} (availability)")
message(STATUS " JPEG support: ${jpeg} (requested) ${JPEG_FOUND} (availability)")
message(STATUS " Old JPEG support: ${old-jpeg} (requested) ${JPEG_FOUND} (availability)")
message(STATUS " JPEG 8/12 bit dual mode: ${jpeg12} (requested) ${JPEG12_FOUND} (availability)")
message(STATUS " ISO JBIG support: ${jbig} (requested) ${JBIG_FOUND} (availability)")
message(STATUS " LZMA2 support: ${lzma} (requested) ${LIBLZMA_FOUND} (availability)")
message(STATUS " ZSTD support: ${zstd} (requested) ${ZSTD_FOUND} (availability)")
message(STATUS " WEBP support: ${webp} (requested) ${WEBP_FOUND} (availability)")
message(STATUS "")
message(STATUS " C++ support: ${cxx} (requested) ${CXX_SUPPORT} (availability)")
message(STATUS "")
# message(STATUS " X Athena Widgets support: ${HAVE_XAW}")
message(STATUS " OpenGL support: Requested:${tiff-opengl} Availability:${HAVE_OPENGL} Support:${OPENGL_SUPPORT}")
message(STATUS " OpenGL support: ${HAVE_OPENGL}")
message(STATUS "")

View file

@ -1,19 +0,0 @@
Contributing
------------
libtiff uses a ``.clang-format`` file to enforce code formatting rules.
Automatic code reformatting can be done with pre-commit.
Install (once) pre-commit with ``python -m pip install pre-commit``.
Install it (once) in the libtiff git repository with ``pre-commit install``.
Then the rules defined in the ``.pre-commit-config.yaml`` file will be
enforced at ``git commit`` time, with automatic reformatting.
Due to whole-tree code reformatting done during libtiff 4.5 development,
``git blame`` information might be misleading. To avoid that, you need
to modify your git configuration as following to ignore the revision of
the whole-tree reformatting:
``git config blame.ignoreRevsFile .git-blame-ignore-revs``.

View file

@ -1,7 +1,5 @@
# LibTIFF license
Copyright © 1988-1997 Sam Leffler\
Copyright © 1991-1997 Silicon Graphics, Inc.
Copyright (c) 1988-1997 Sam Leffler
Copyright (c) 1991-1997 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

File diff suppressed because it is too large Load diff

View file

@ -25,11 +25,7 @@ Notes on releasing.
1. Commit any unsaved changes.
2. Use gnulib's gitlog-to-changelog script to add new (since the last
release) entries to the traditional ChangeLog file.
http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;f=build-aux/gitlog-to-changelog
Take note of
release) entries to the traditional ChangeLog file. Take note of
the most recent change note time stamp and use that as the starting
point. Concatenate the old logs to the new logs. The added logs
may be used to help produce the release notes (in next step). For
@ -41,14 +37,13 @@ Notes on releasing.
mv ChangeLog.new ChangeLog
rm ChangeLog.added
3. Create doc/releases/vX.X.rst and add it to git with 'git add doc/releases/vX.X.rst'.
Update doc/releases/index.rst to point to the new file
Take ChangeLog entries and rst-ify in there.
Easist thing to do is take doc/releases/vX.(X-1).rst and use it as a template.
3. Create html/vX.X.html and add it to git with 'git add html/vX.X.html'.
Take ChangeLog entries and html-ify in there.
Easist thing to do is take html/vX.(X-1).html and use it as a template.
4. Add vX.X.rst file to the list of 'rst_sources' files in the doc/Makefile.am.
4. Add vX.X.html file to the list of 'docfiles' files in the html/Makefile.am.
5. Update "Latest Stable Release" in doc/index.rst.
5. Update html/index.html to refer to this new page as the current release.
6. Increment the release version in configure.ac. Put 'alpha' or
'beta' after the version, if applicable. For example:
@ -134,18 +129,18 @@ Notes on releasing.
16. Sign the release files in the build tree using your private key
export GPG_TTY=$(tty)
for file in tiff-*.tar.gz tiff-*.tar.xz tiff-*.zip ; do \
for file in tiff-*.tar.gz tiff-*.zip ; do \
gpg2 --output ${file}.sig --detach-sig $file ; \
done
for file in tiff-*.tar.gz tiff-*.tar.xz tiff-*.zip ; do \
for file in tiff-*.tar.gz tiff-*.zip ; do \
gpg2 --verify ${file}.sig $file ; \
done
17. Copy release packages from the build tree to the
ftp.remotesensing.org ftp site.
scp tiff-*.tar.gz tiff-*.tar.gz.sig tiff-*.tar.xz tiff-*.tar.xz.sig tiff-*.zip tiff-*.zip.sig \
scp tiff-*.tar.gz tiff-*.tar.gz.sig tiff-*.zip tiff-*.zip.sig \
bfriesen@upload.osgeo.org:/osgeo/download/libtiff
18. Announce to list: tiff@lists.osgeo.org
18. Announce to list, tiff@lists.maptools.org

View file

@ -29,30 +29,30 @@ AUTOMAKE_OPTIONS = 1.12 dist-zip foreign
ACLOCAL_AMFLAGS = -I m4
docfiles = \
COPYRIGHT \
ChangeLog \
LICENSE.md \
README.md \
RELEASE-DATE \
TODO \
VERSION
EXTRA_DIST = \
placeholder.h \
cmake \
CMakeLists.txt \
HOWTO-RELEASE \
Makefile.vc \
SConstruct \
autogen.sh \
libtiff-4.pc.in
configure.com \
libtiff-4.pc.in \
nmake.opt
if TIFF_DOCS
dist_doc_DATA = $(docfiles)
endif
distcheck-hook:
if [ -x "$(CMAKE)" ]; then \
mkdir $(distdir)/_build/cmake \
&& cd $(distdir)/_build/cmake \
&& cmake -Dsphinx=OFF ../.. \
&& cmake ../.. \
&& $(MAKE) \
&& ctest -V \
&& $(MAKE) DESTDIR=../../_inst/cmake install ; \
@ -60,12 +60,12 @@ distcheck-hook:
rm -rf $(distdir)/_build/cmake
rm -rf $(distdir)/_inst/cmake
SUBDIRS = port libtiff tools build contrib test doc
SUBDIRS = port libtiff tools build contrib test man html
release:
(rm -f $(top_srcdir)/RELEASE-DATE && echo $(LIBTIFF_RELEASE_DATE) > $(top_srcdir)/RELEASE-DATE)
(rm -f $(top_srcdir)/VERSION && echo $(LIBTIFF_VERSION) > $(top_srcdir)/VERSION)
(rm -f $(top_srcdir)/libtiff/tiffvers.h && sed 's,LIBTIFF_VERSION,$(LIBTIFF_VERSION),;s,LIBTIFF_RELEASE_DATE,$(LIBTIFF_RELEASE_DATE),;s,LIBTIFF_MAJOR_VERSION,$(LIBTIFF_MAJOR_VERSION),;s,LIBTIFF_MINOR_VERSION,$(LIBTIFF_MINOR_VERSION),;s,LIBTIFF_MICRO_VERSION,$(LIBTIFF_MICRO_VERSION),' $(top_srcdir)/libtiff/tiffvers.h.in > $(top_srcdir)/libtiff/tiffvers.h)
(rm -f $(top_srcdir)/libtiff/tiffvers.h && sed 's,LIBTIFF_VERSION,$(LIBTIFF_VERSION),;s,LIBTIFF_RELEASE_DATE,$(LIBTIFF_RELEASE_DATE),' $(top_srcdir)/libtiff/tiffvers.h.in > $(top_srcdir)/libtiff/tiffvers.h)
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libtiff-4.pc

View file

@ -1,43 +1,60 @@
# Checks for symbols
#
# Copyright © 2015 Open Microscopy Environment / University of Dundee
# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
# Written by Roger Leigh <rleigh@codelibre.net>
# Copyright (C) 2004, Andrey Kiselev <dron@ak4719.spb.edu>
#
# Permission to use, copy, modify, distribute, and sell this software and
# 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.
#
#
# 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
# 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 MS Visual C and Watcom C compilers.
# Edit nmake.opt file if you want to ajust building options.
#
# To build:
# C:\libtiff> nmake /f makefile.vc
!INCLUDE nmake.opt
include(CheckSymbolExists)
all: port lib tools
port::
cd libtiff
$(MAKE) /f Makefile.vc tif_config.h
cd..
cd port
$(MAKE) /f Makefile.vc
cd..
# Check for getopt
check_symbol_exists(getopt "unistd.h;stdio.h" HAVE_GETOPT)
check_symbol_exists(optarg "getopt.h" HAVE_DECL_OPTARG)
if (HAVE_DECL_OPTARG)
set(HAVE_DECL_OPTARG 1)
else()
set(HAVE_DECL_OPTARG 0)
endif()
lib: port
cd libtiff
$(MAKE) /f Makefile.vc
cd..
# Check for mmap
check_symbol_exists(mmap "sys/mman.h" HAVE_MMAP)
tools: lib
cd tools
$(MAKE) /f Makefile.vc
cd ..
# Check for setmode
check_symbol_exists(setmode "unistd.h" HAVE_SETMODE)
clean:
cd port
$(MAKE) /f Makefile.vc clean
cd..
cd libtiff
$(MAKE) /f Makefile.vc clean
cd..
cd tools
$(MAKE) /f Makefile.vc clean
cd ..

View file

@ -1 +1 @@
20230609
20201219

View file

@ -0,0 +1,169 @@
# Tag Image File Format (TIFF) Software
#
# Copyright (C) 2005, Andrey Kiselev <dron@ak4719.spb.edu>
#
# 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 file contains rules to build software with the SCons tool
# (see the http://www.scons.org/ for details on SCons).
import os
env = Environment()
# Read the user supplied options
opts = Options('libtiff.conf')
opts.Add(PathOption('PREFIX', \
'install architecture-independent files in this directory', \
'/usr/local', PathOption.PathIsDirCreate))
opts.Add(BoolOption('ccitt', \
'enable support for CCITT Group 3 & 4 algorithms', \
'yes'))
opts.Add(BoolOption('packbits', \
'enable support for Macintosh PackBits algorithm', \
'yes'))
opts.Add(BoolOption('lzw', \
'enable support for LZW algorithm', \
'yes'))
opts.Add(BoolOption('thunder', \
'enable support for ThunderScan 4-bit RLE algorithm', \
'yes'))
opts.Add(BoolOption('next', \
'enable support for NeXT 2-bit RLE algorithm', \
'yes'))
opts.Add(BoolOption('logluv', \
'enable support for LogLuv high dynamic range encoding', \
'yes'))
opts.Add(BoolOption('strip_chopping', \
'support for strip chopping (whether or not to convert single-strip uncompressed images to mutiple strips of ~8Kb to reduce memory usage)', \
'yes'))
opts.Add(BoolOption('extrasample_as_alpha', \
'the RGBA interface will treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many packages produce RGBA files but don\'t mark the alpha properly', \
'yes'))
opts.Add(BoolOption('check_ycbcr_subsampling', \
'disable picking up YCbCr subsampling info from the JPEG data stream to support files lacking the tag', \
'yes'))
opts.Update(env)
opts.Save('libtiff.conf', env)
Help(opts.GenerateHelpText(env))
# Here are our installation paths:
idir_prefix = '$PREFIX'
idir_lib = '$PREFIX/lib'
idir_bin = '$PREFIX/bin'
idir_inc = '$PREFIX/include'
idir_doc = '$PREFIX/doc'
Export([ 'env', 'idir_prefix', 'idir_lib', 'idir_bin', 'idir_inc', 'idir_doc' ])
# Now proceed to system feature checks
target_cpu, target_vendor, target_kernel, target_os = \
os.popen("./config/config.guess").readlines()[0].split("-")
def Define(context, key, have):
import SCons.Conftest
SCons.Conftest._Have(context, key, have)
def CheckCustomOption(context, name):
context.Message('Checking is the ' + name + ' option set... ')
ret = env[name]
Define(context, name + '_SUPPORT', ret)
context.Result(ret)
return ret
def CheckFillorderOption(context):
context.Message('Checking for the native cpu bit order... ')
if target_cpu[0] == 'i' and target_cpu[2:] == '86':
Define(context, 'HOST_FILLORDER', 'FILLORDER_LSB2MSB')
context.Result('lsb2msb')
else:
Define(context, 'HOST_FILLORDER', 'FILLORDER_MSB2LSB')
context.Result('msb2lsb')
return 1
def CheckIEEEFPOption(context):
context.Message('Checking for the IEEE floating point format... ')
Define(context, 'HAVE_IEEEFP', 1)
context.Result(1)
return 1
def CheckOtherOption(context, name):
context.Message('Checking is the ' + name + ' option set... ')
ret = env[name]
Define(context, 'HAVE_' + name, ret)
context.Result(ret)
return ret
custom_tests = { \
'CheckCustomOption' : CheckCustomOption, \
'CheckFillorderOption' : CheckFillorderOption, \
'CheckIEEEFPOption' : CheckIEEEFPOption, \
'CheckOtherOption' : CheckOtherOption \
}
conf = Configure(env, custom_tests = custom_tests, \
config_h = 'libtiff/tif_config.h')
# Check for standard library
conf.CheckLib('c')
if target_os != 'cygwin' \
and target_os != 'mingw32' \
and target_os != 'beos' \
and target_os != 'darwin':
conf.CheckLib('m')
# Check for system headers
conf.CheckCHeader('assert.h')
conf.CheckCHeader('fcntl.h')
conf.CheckCHeader('io.h')
conf.CheckCHeader('limits.h')
conf.CheckCHeader('malloc.h')
conf.CheckCHeader('search.h')
conf.CheckCHeader('sys/time.h')
conf.CheckCHeader('unistd.h')
# Check for standard library functions
conf.CheckFunc('floor')
conf.CheckFunc('isascii')
conf.CheckFunc('memmove')
conf.CheckFunc('memset')
conf.CheckFunc('mmap')
conf.CheckFunc('pow')
conf.CheckFunc('setmode')
conf.CheckFunc('sqrt')
conf.CheckFunc('strchr')
conf.CheckFunc('strrchr')
conf.CheckFunc('strstr')
conf.CheckFunc('strtol')
conf.CheckFillorderOption()
conf.CheckIEEEFPOption()
conf.CheckCustomOption('ccitt')
conf.CheckCustomOption('packbits')
conf.CheckCustomOption('lzw')
conf.CheckCustomOption('thunder')
conf.CheckCustomOption('next')
conf.CheckCustomOption('logluv')
conf.CheckOtherOption('strip_chopping')
conf.CheckOtherOption('extrasample_as_alpha')
conf.CheckOtherOption('check_ycbcr_subsampling')
env = conf.Finish()
# Ok, now go to build files in the subdirectories
SConscript(dirs = [ 'libtiff' ], name = 'SConstruct')

View file

@ -1 +1 @@
4.5.1
4.2.0

File diff suppressed because it is too large Load diff

View file

@ -2,30 +2,30 @@
* Copyright (c) 1990-1997 Sam Leffler
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
* 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.
*
*
* 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
* 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.
*/
/*
* convert a GIF file into a TIFF file.
* based on Paul Haeberli's fromgif program which in turn is
* based on a GIF file reader by Marcel J.E. Mol March 23 1989
* based on a GIF file reader by Marcel J.E. Mol March 23 1989
*
* if input is 320 by 200 pixel aspect is probably 1.2
* if input is 640 350 pixel aspect is probably 1.37
@ -33,65 +33,67 @@
*/
#include "tif_config.h"
#include <errno.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <math.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
# include <unistd.h>
#endif
#ifdef NEED_LIBPORT
#include "libport.h"
# include "libport.h"
#endif
#include "tiffio.h"
#define GIFGAMMA (1.5) /* smaller makes output img brighter */
#define IMAX 0xffff /* max intensity value */
#define EXTRAFUDGE 128 /* some people write BAD .gif files */
#define GIFGAMMA (1.5) /* smaller makes output img brighter */
#define IMAX 0xffff /* max intensity value */
#define EXTRAFUDGE 128 /* some people write BAD .gif files */
#define streq(a, b) (strcmp(a, b) == 0)
#define strneq(a, b, n) (strncmp(a, b, n) == 0)
#define streq(a,b) (strcmp(a,b) == 0)
#define strneq(a,b,n) (strncmp(a,b,n) == 0)
unsigned short gamtab[256];
void makegamtab(float gam)
void
makegamtab(float gam)
{
int i;
for (i = 0; i < 256; i++)
gamtab[i] = (unsigned short)(IMAX * pow(i / 255.0, gam) + 0.5);
for(i=0; i<256; i++)
gamtab[i] = (unsigned short) (IMAX*pow(i/255.0,gam)+0.5);
}
char *stuff[] = {
"usage: gif2tiff [options] input.gif output.tif",
"where options are:",
" -r # make each strip have no more than # rows",
"",
" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding",
" -c zip[:opts] compress output with deflate encoding",
" -c packbits compress output with packbits encoding",
" -c none use no compression algorithm on output",
"",
"LZW and deflate options:",
" # set predictor value",
"For example, -c lzw:2 to get LZW-encoded data with horizontal "
"differencing",
NULL};
char* stuff[] = {
"usage: gif2tiff [options] input.gif output.tif",
"where options are:",
" -r # make each strip have no more than # rows",
"",
" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding",
" -c zip[:opts] compress output with deflate encoding",
" -c packbits compress output with packbits encoding",
" -c none use no compression algorithm on output",
"",
"LZW and deflate options:",
" # set predictor value",
"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing",
NULL
};
static void usage(void)
static void
usage(void)
{
char buf[BUFSIZ];
int i;
char buf[BUFSIZ];
int i;
setbuf(stderr, buf);
fprintf(stderr, "%s\n\n", TIFFGetVersion());
for (i = 0; stuff[i] != NULL; i++)
fprintf(stderr, "%s\n", stuff[i]);
exit(-1);
setbuf(stderr, buf);
fprintf(stderr, "%s\n\n", TIFFGetVersion());
for (i = 0; stuff[i] != NULL; i++)
fprintf(stderr, "%s\n", stuff[i]);
exit(-1);
}
#define COLSIZE 256
@ -100,37 +102,38 @@ unsigned char *stackp;
unsigned int prefix[4096];
unsigned char suffix[4096];
unsigned char stack[4096];
int datasize, codesize, codemask; /* Decoder working variables */
int clear, eoi; /* Special code values */
int datasize,codesize,codemask; /* Decoder working variables */
int clear,eoi; /* Special code values */
int avail, oldcode;
FILE *infile;
int global; /* Is there a global color map? */
int globalbits; /* Number of bits of global colors */
unsigned char globalmap[COLSIZE][3]; /* RGB values for global color map */
unsigned char *raster; /* Decoded image data */
int global; /* Is there a global color map? */
int globalbits; /* Number of bits of global colors */
unsigned char globalmap[COLSIZE][3];/* RGB values for global color map */
unsigned char *raster; /* Decoded image data */
unsigned long width, height;
unsigned short red[COLSIZE];
unsigned short green[COLSIZE];
unsigned short blue[COLSIZE];
char *filename, *imagename;
static uint16_t compression = COMPRESSION_PACKBITS;
static uint16_t predictor = 0;
static uint32_t rowsperstrip = (uint32_t)-1;
static int processCompressOptions(char *);
static uint16 compression = COMPRESSION_PACKBITS;
static uint16 predictor = 0;
static uint32 rowsperstrip = (uint32) -1;
static int processCompressOptions(char*);
int convert(void);
int checksignature(void);
int readscreen(void);
int readgifimage(char *);
int readextension(void);
int readraster(void);
int process(int, unsigned char **);
void initcolors(unsigned char[COLSIZE][3], int);
void rasterize(int, char *);
int convert(void);
int checksignature(void);
int readscreen(void);
int readgifimage(char*);
int readextension(void);
int readraster(void);
int process(int, unsigned char**);
void initcolors(unsigned char [COLSIZE][3], int);
void rasterize(int, char*);
int main(int argc, char *argv[])
int
main(int argc, char* argv[])
{
#if !HAVE_DECL_OPTARG
extern int optind;
@ -140,119 +143,105 @@ int main(int argc, char *argv[])
int c, status;
while ((c = getopt(argc, argv, "c:r:")) != -1)
switch (c)
{
case 'c': /* compression scheme */
if (!processCompressOptions(optarg))
usage();
break;
case 'r': /* rows/strip */
rowsperstrip = atoi(optarg);
break;
case '?':
usage();
/*NOTREACHED*/
}
switch (c) {
case 'c': /* compression scheme */
if (!processCompressOptions(optarg))
usage();
break;
case 'r': /* rows/strip */
rowsperstrip = atoi(optarg);
break;
case '?':
usage();
/*NOTREACHED*/
}
if (argc - optind != 2)
usage();
usage();
makegamtab(GIFGAMMA);
filename = argv[optind];
imagename = argv[optind + 1];
if ((infile = fopen(imagename, "rb")) != NULL)
{
int c;
fclose(infile);
printf("overwrite %s? ", imagename);
fflush(stdout);
c = getc(stdin);
if (c != 'y' && c != 'Y')
return (1);
imagename = argv[optind+1];
if ((infile = fopen(imagename, "rb")) != NULL) {
int c;
fclose(infile);
printf("overwrite %s? ", imagename); fflush(stdout);
c = getc(stdin);
if (c != 'y' && c != 'Y')
return (1);
}
if ((infile = fopen(filename, "rb")) == NULL)
{
perror(filename);
return (1);
if ((infile = fopen(filename, "rb")) == NULL) {
perror(filename);
return (1);
}
status = convert();
fclose(infile);
return (status);
}
static int processCompressOptions(char *opt)
static int
processCompressOptions(char* opt)
{
if (streq(opt, "none"))
compression = COMPRESSION_NONE;
else if (streq(opt, "packbits"))
compression = COMPRESSION_PACKBITS;
else if (strneq(opt, "lzw", 3))
{
char *cp = strchr(opt, ':');
if (cp)
predictor = atoi(cp + 1);
compression = COMPRESSION_LZW;
}
else if (strneq(opt, "zip", 3))
{
char *cp = strchr(opt, ':');
if (cp)
predictor = atoi(cp + 1);
compression = COMPRESSION_ADOBE_DEFLATE;
}
else
return (0);
return (1);
if (streq(opt, "none"))
compression = COMPRESSION_NONE;
else if (streq(opt, "packbits"))
compression = COMPRESSION_PACKBITS;
else if (strneq(opt, "lzw", 3)) {
char* cp = strchr(opt, ':');
if (cp)
predictor = atoi(cp+1);
compression = COMPRESSION_LZW;
} else if (strneq(opt, "zip", 3)) {
char* cp = strchr(opt, ':');
if (cp)
predictor = atoi(cp+1);
compression = COMPRESSION_DEFLATE;
} else
return (0);
return (1);
}
int convert(void)
int
convert(void)
{
int ch;
char *mode = "w";
char* mode = "w";
if (!checksignature())
return (-1);
if (!readscreen())
return (-1);
while ((ch = getc(infile)) != ';' && ch != EOF)
{
switch (ch)
{
case '\0':
break; /* this kludge for non-standard files */
case ',':
if (!readgifimage(mode))
return (-1);
mode = "a"; /* subsequent images append */
break;
case '!':
if (!readextension())
return (-1);
break;
default:
fprintf(stderr, "illegal GIF block type\n");
return (-1);
while ((ch = getc(infile)) != ';' && ch != EOF) {
switch (ch) {
case '\0': break; /* this kludge for non-standard files */
case ',': if (!readgifimage(mode))
return (-1);
mode = "a"; /* subsequent images append */
break;
case '!': if (!readextension())
return (-1);
break;
default: fprintf(stderr, "illegal GIF block type\n");
return (-1);
}
}
return (0);
}
int checksignature(void)
int
checksignature(void)
{
char buf[6];
if (fread(buf, 1, 6, infile) != 6)
{
fprintf(stderr, "short read from file %s (%s)\n", filename,
strerror(errno));
if (fread(buf,1,6,infile) != 6) {
fprintf(stderr, "short read from file %s (%s)\n",
filename, strerror(errno));
return 0;
}
if (strncmp(buf, "GIF", 3))
{
if (strncmp(buf,"GIF",3)) {
fprintf(stderr, "file is not a GIF file\n");
return 0;
}
if (strncmp(&buf[3], "87a", 3))
{
if (strncmp(&buf[3],"87a",3)) {
fprintf(stderr, "unknown GIF version number\n");
return 0;
}
@ -260,36 +249,35 @@ int checksignature(void)
}
/*
* readscreen -
* Get information which is global to all the images stored
* readscreen -
* Get information which is global to all the images stored
* in the file
*/
int readscreen(void)
int
readscreen(void)
{
unsigned char buf[7];
if (fread(buf, 1, 7, infile) != 7)
{
fprintf(stderr, "short read from file %s (%s)\n", filename,
strerror(errno));
if (fread(buf,1,7,infile) != 7) {
fprintf(stderr, "short read from file %s (%s)\n",
filename, strerror(errno));
return 0;
}
global = buf[4] & 0x80;
if (global)
{
if (global) {
globalbits = (buf[4] & 0x07) + 1;
if (fread(globalmap, 3, ((size_t)1) << globalbits, infile) !=
((size_t)1) << globalbits)
{
fprintf(stderr, "short read from file %s (%s)\n", filename,
strerror(errno));
if (fread(globalmap,3,((size_t)1)<<globalbits,infile) !=
((size_t)1)<<globalbits) {
fprintf(stderr, "short read from file %s (%s)\n",
filename, strerror(errno));
return 0;
}
}
return 1;
}
int readgifimage(char *mode)
int
readgifimage(char* mode)
{
unsigned char buf[9];
int local, interleaved;
@ -298,61 +286,50 @@ int readgifimage(char *mode)
int status;
size_t raster_size;
if (fread(buf, 1, 9, infile) != 9)
{
fprintf(stderr, "short read from file %s (%s)\n", filename,
strerror(errno));
return (0);
if (fread(buf, 1, 9, infile) != 9) {
fprintf(stderr, "short read from file %s (%s)\n",
filename, strerror(errno));
return (0);
}
width = (buf[4] + (buf[5] << 8)) & 0xffff; /* 16 bit */
height = (buf[6] + (buf[7] << 8)) & 0xffff; /* 16 bit */
width = (buf[4] + (buf[5] << 8)) & 0xffff; /* 16 bit */
height = (buf[6] + (buf[7] << 8)) & 0xffff; /* 16 bit */
local = buf[8] & 0x80;
interleaved = buf[8] & 0x40;
if (width == 0UL || height == 0UL || (width > 2000000000UL / height))
{
if (width == 0UL || height == 0UL || (width > 2000000000UL / height)) {
fprintf(stderr, "Invalid value of width or height\n");
return (0);
return(0);
}
if (local == 0 && global == 0)
{
if (local == 0 && global == 0) {
fprintf(stderr, "no colormap present for image\n");
return (0);
}
raster_size = width * height;
if ((raster_size / width) == height)
{
raster_size += EXTRAFUDGE; /* Add elbow room */
raster_size=width*height;
if ((raster_size/width) == height) {
raster_size += EXTRAFUDGE; /* Add elbow room */
} else {
raster_size=0;
}
else
{
raster_size = 0;
}
if ((raster = (unsigned char *)_TIFFmalloc(raster_size)) == NULL)
{
if ((raster = (unsigned char*) _TIFFmalloc(raster_size)) == NULL) {
fprintf(stderr, "not enough memory for image\n");
return (0);
}
if (local)
{
if (local) {
localbits = (buf[8] & 0x7) + 1;
fprintf(stderr, " local colors: %d\n", 1 << localbits);
fprintf(stderr, " local colors: %d\n", 1<<localbits);
if (fread(localmap, 3, ((size_t)1) << localbits, infile) !=
((size_t)1) << localbits)
{
fprintf(stderr, "short read from file %s (%s)\n", filename,
strerror(errno));
if (fread(localmap, 3, ((size_t)1)<<localbits, infile) !=
((size_t)1)<<localbits) {
fprintf(stderr, "short read from file %s (%s)\n",
filename, strerror(errno));
return (0);
}
initcolors(localmap, 1 << localbits);
}
else if (global)
{
initcolors(globalmap, 1 << globalbits);
initcolors(localmap, 1<<localbits);
} else if (global) {
initcolors(globalmap, 1<<globalbits);
}
if ((status = readraster()))
rasterize(interleaved, mode);
rasterize(interleaved, mode);
_TIFFfree(raster);
return status;
}
@ -362,18 +339,18 @@ int readgifimage(char *mode)
* Read a GIF extension block (and do nothing with it).
*
*/
int readextension(void)
int
readextension(void)
{
int count;
char buf[255];
int status = 1;
(void)getc(infile);
(void) getc(infile);
while ((count = getc(infile)) && count <= 255)
if (fread(buf, 1, count, infile) != (size_t)count)
{
fprintf(stderr, "short read from file %s (%s)\n", filename,
strerror(errno));
if (fread(buf, 1, count, infile) != (size_t) count) {
fprintf(stderr, "short read from file %s (%s)\n",
filename, strerror(errno));
status = 0;
break;
}
@ -385,129 +362,114 @@ int readextension(void)
* Decode a raster image
*
*/
int readraster(void)
int
readraster(void)
{
unsigned char *fill = raster;
unsigned char buf[255];
register int bits = 0;
register unsigned long datum = 0;
register int bits=0;
register unsigned long datum=0;
register unsigned char *ch;
register int count, code;
int status = 1;
datasize = getc(infile);
if (datasize > 12)
return 0;
return 0;
clear = 1 << datasize;
eoi = clear + 1;
avail = clear + 2;
oldcode = -1;
codesize = datasize + 1;
codemask = (1 << codesize) - 1;
for (code = 0; code < clear; code++)
{
prefix[code] = 0;
suffix[code] = code;
for (code = 0; code < clear; code++) {
prefix[code] = 0;
suffix[code] = code;
}
stackp = stack;
for (count = getc(infile); count > 0 && count <= 255; count = getc(infile))
{
if (fread(buf, 1, count, infile) != (size_t)count)
{
fprintf(stderr, "short read from file %s (%s)\n", filename,
strerror(errno));
for (count = getc(infile); count > 0 && count <= 255; count = getc(infile)) {
if (fread(buf,1,count,infile) != (size_t)count) {
fprintf(stderr, "short read from file %s (%s)\n",
filename, strerror(errno));
return 0;
}
for (ch = buf; count-- > 0; ch++)
{
datum += (unsigned long)*ch << bits;
bits += 8;
while (bits >= codesize)
{
code = datum & codemask;
datum >>= codesize;
bits -= codesize;
if (code == eoi)
{ /* This kludge put in */
goto exitloop; /* because some GIF files*/
} /* aren't standard */
if (!process(code, &fill))
{
status = 0;
goto exitloop;
}
}
}
if (fill >= raster + width * height)
{
fprintf(stderr, "raster full before eoi code\n");
break;
}
for (ch=buf; count-- > 0; ch++) {
datum += (unsigned long) *ch << bits;
bits += 8;
while (bits >= codesize) {
code = datum & codemask;
datum >>= codesize;
bits -= codesize;
if (code == eoi) { /* This kludge put in */
goto exitloop; /* because some GIF files*/
} /* aren't standard */
if (!process(code, &fill)) {
status = 0;
goto exitloop;
}
}
}
if (fill >= raster + width*height) {
fprintf(stderr, "raster full before eoi code\n");
break;
}
}
exitloop:
if (fill != raster + width * height)
{
fprintf(stderr, "warning: wrong rastersize: %ld bytes\n",
(long)(fill - raster));
fprintf(stderr, " instead of %ld bytes\n",
(long)width * height);
if (fill != raster + width*height) {
fprintf(stderr, "warning: wrong rastersize: %ld bytes\n",
(long) (fill-raster));
fprintf(stderr, " instead of %ld bytes\n",
(long) width*height);
}
return status;
}
/*
* process -
* Process a compression code. "clear" resets the code table.
* Otherwise make a new code table entry, and output the bytes
* process -
* Process a compression code. "clear" resets the code table.
* Otherwise make a new code table entry, and output the bytes
* associated with the code.
*/
int process(register int code, unsigned char **fill)
int
process(register int code, unsigned char** fill)
{
int incode;
static unsigned char firstchar;
if (code == clear)
{
codesize = datasize + 1;
codemask = (1 << codesize) - 1;
avail = clear + 2;
oldcode = -1;
return 1;
if (code == clear) {
codesize = datasize + 1;
codemask = (1 << codesize) - 1;
avail = clear + 2;
oldcode = -1;
return 1;
}
if (oldcode == -1)
{
if (code >= clear)
{
fprintf(stderr, "bad input: code=%d is larger than clear=%d\n",
code, clear);
if (oldcode == -1) {
if (code >= clear) {
fprintf(stderr, "bad input: code=%d is larger than clear=%d\n",code, clear);
return 0;
}
if (*fill >= raster + width * height)
{
if (*fill >= raster + width*height) {
fprintf(stderr, "raster full before eoi code\n");
return 0;
}
*(*fill)++ = suffix[code];
firstchar = oldcode = code;
return 1;
*(*fill)++ = suffix[code];
firstchar = oldcode = code;
return 1;
}
if (code > avail)
{
fprintf(stderr, "code %d too large for %d\n", code, avail);
return 0;
if (code > avail) {
fprintf(stderr, "code %d too large for %d\n", code, avail);
return 0;
}
incode = code;
if (code == avail)
{ /* the first code is always < avail */
*stackp++ = firstchar;
code = oldcode;
if (code == avail) { /* the first code is always < avail */
*stackp++ = firstchar;
code = oldcode;
}
while (code > clear)
{
*stackp++ = suffix[code];
code = prefix[code];
while (code > clear) {
*stackp++ = suffix[code];
code = prefix[code];
}
*stackp++ = firstchar = suffix[code];
@ -515,20 +477,17 @@ int process(register int code, unsigned char **fill)
suffix[avail] = firstchar;
avail++;
if (((avail & codemask) == 0) && (avail < 4096))
{
codesize++;
codemask += avail;
if (((avail & codemask) == 0) && (avail < 4096)) {
codesize++;
codemask += avail;
}
oldcode = incode;
do
{
if (*fill >= raster + width * height)
{
do {
if (*fill >= raster + width*height) {
fprintf(stderr, "raster full before eoi code\n");
return 0;
}
*(*fill)++ = *--stackp;
*(*fill)++ = *--stackp;
} while (stackp > stack);
return 1;
}
@ -536,22 +495,23 @@ int process(register int code, unsigned char **fill)
/*
* initcolors -
* Convert a color map (local or global) to arrays with R, G and B
* values.
* values.
*
*/
void initcolors(unsigned char colormap[COLSIZE][3], int ncolors)
void
initcolors(unsigned char colormap[COLSIZE][3], int ncolors)
{
register int i;
for (i = 0; i < ncolors; i++)
{
red[i] = gamtab[colormap[i][0]];
for (i = 0; i < ncolors; i++) {
red[i] = gamtab[colormap[i][0]];
green[i] = gamtab[colormap[i][1]];
blue[i] = gamtab[colormap[i][2]];
blue[i] = gamtab[colormap[i][2]];
}
}
void rasterize(int interleaved, char *mode)
void
rasterize(int interleaved, char* mode)
{
register unsigned long row;
unsigned char *newras;
@ -560,73 +520,70 @@ void rasterize(int interleaved, char *mode)
tstrip_t strip;
tsize_t stripsize;
if ((newras = (unsigned char *)_TIFFmalloc(width * height + EXTRAFUDGE)) ==
NULL)
{
if ((newras = (unsigned char*) _TIFFmalloc(width*height+EXTRAFUDGE)) == NULL) {
fprintf(stderr, "not enough memory for image\n");
return;
}
#define DRAWSEGMENT(offset, step) \
{ \
for (row = offset; row < height; row += step) \
{ \
_TIFFmemcpy(newras + row * width, ras, width); \
ras += width; \
} \
#define DRAWSEGMENT(offset, step) { \
for (row = offset; row < height; row += step) { \
_TIFFmemcpy(newras + row*width, ras, width);\
ras += width; \
} \
}
ras = raster;
if (interleaved)
{
if (interleaved) {
DRAWSEGMENT(0, 8);
DRAWSEGMENT(4, 8);
DRAWSEGMENT(2, 4);
DRAWSEGMENT(1, 2);
}
else
} else
DRAWSEGMENT(0, 1);
#undef DRAWSEGMENT
tif = TIFFOpen(imagename, mode);
if (!tif)
{
TIFFError(imagename, "Can not open output image");
exit(-1);
if (!tif) {
TIFFError(imagename,"Can not open output image");
exit(-1);
}
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, (uint32_t)width);
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, (uint32_t)height);
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, (uint32) width);
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, (uint32) height);
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE);
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP,
rowsperstrip = TIFFDefaultStripSize(tif, rowsperstrip));
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP,
rowsperstrip = TIFFDefaultStripSize(tif, rowsperstrip));
TIFFSetField(tif, TIFFTAG_COMPRESSION, compression);
switch (compression)
{
case COMPRESSION_LZW:
case COMPRESSION_ADOBE_DEFLATE:
case COMPRESSION_DEFLATE:
if (predictor != 0)
TIFFSetField(tif, TIFFTAG_PREDICTOR, predictor);
break;
switch (compression) {
case COMPRESSION_LZW:
case COMPRESSION_DEFLATE:
if (predictor != 0)
TIFFSetField(tif, TIFFTAG_PREDICTOR, predictor);
break;
}
TIFFSetField(tif, TIFFTAG_COLORMAP, red, green, blue);
TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
strip = 0;
stripsize = TIFFStripSize(tif);
for (row = 0; row < height; row += rowsperstrip)
{
if (rowsperstrip > height - row)
{
rowsperstrip = height - row;
stripsize = TIFFVStripSize(tif, rowsperstrip);
}
if (TIFFWriteEncodedStrip(tif, strip, newras + row * width, stripsize) <
0)
break;
strip++;
for (row=0; row<height; row += rowsperstrip) {
if (rowsperstrip > height-row) {
rowsperstrip = height-row;
stripsize = TIFFVStripSize(tif, rowsperstrip);
}
if (TIFFWriteEncodedStrip(tif, strip, newras+row*width, stripsize) < 0)
break;
strip++;
}
TIFFClose(tif);
_TIFFfree(newras);
}
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 4
* fill-column: 78
* End:
*/

View file

@ -2,366 +2,335 @@
* Copyright (c) 1988-1997 Sam Leffler
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
* 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.
*
*
* 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
* 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.
*/
#include "tif_config.h"
#include <ctype.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
# include <unistd.h>
#endif
#ifdef NEED_LIBPORT
#include "libport.h"
# include "libport.h"
#endif
#include "rasterfile.h"
#include "tiffio.h"
#ifndef howmany
#define howmany(x, y) (((x) + ((y)-1)) / (y))
#define howmany(x, y) (((x)+((y)-1))/(y))
#endif
#define streq(a, b) (strcmp(a, b) == 0)
#define strneq(a, b, n) (strncmp(a, b, n) == 0)
#define streq(a,b) (strcmp(a,b) == 0)
#define strneq(a,b,n) (strncmp(a,b,n) == 0)
static uint16_t compression = (uint16_t)-1;
static int jpegcolormode = JPEGCOLORMODE_RGB;
static int quality = 75; /* JPEG quality */
static uint16_t predictor = 0;
static uint16 compression = (uint16) -1;
static int jpegcolormode = JPEGCOLORMODE_RGB;
static int quality = 75; /* JPEG quality */
static uint16 predictor = 0;
static void usage(void);
static int processCompressOptions(char *);
static int processCompressOptions(char*);
int main(int argc, char *argv[])
int
main(int argc, char* argv[])
{
unsigned char *buf;
long row;
tsize_t linebytes, scanline;
TIFF *out;
FILE *in;
struct rasterfile h;
uint16_t photometric;
uint16_t config = PLANARCONFIG_CONTIG;
uint32_t rowsperstrip = (uint32_t)-1;
int c;
unsigned char* buf;
long row;
tsize_t linebytes, scanline;
TIFF *out;
FILE *in;
struct rasterfile h;
uint16 photometric;
uint16 config = PLANARCONFIG_CONTIG;
uint32 rowsperstrip = (uint32) -1;
int c;
#if !HAVE_DECL_OPTARG
extern int optind;
extern char *optarg;
extern int optind;
extern char* optarg;
#endif
while ((c = getopt(argc, argv, "c:r:h")) != -1)
switch (c)
{
case 'c': /* compression scheme */
if (!processCompressOptions(optarg))
usage();
break;
case 'r': /* rows/strip */
rowsperstrip = atoi(optarg);
break;
case 'h':
usage();
/*NOTREACHED*/
}
if (argc - optind != 2)
usage();
in = fopen(argv[optind], "rb");
if (in == NULL)
{
fprintf(stderr, "%s: Can not open.\n", argv[optind]);
return (-1);
}
if (fread(&h, sizeof(h), 1, in) != 1)
{
fprintf(stderr, "%s: Can not read header.\n", argv[optind]);
fclose(in);
return (-2);
}
if (strcmp(h.ras_magic, RAS_MAGIC) == 0)
{
while ((c = getopt(argc, argv, "c:r:h")) != -1)
switch (c) {
case 'c': /* compression scheme */
if (!processCompressOptions(optarg))
usage();
break;
case 'r': /* rows/strip */
rowsperstrip = atoi(optarg);
break;
case 'h':
usage();
/*NOTREACHED*/
}
if (argc - optind != 2)
usage();
in = fopen(argv[optind], "rb");
if (in == NULL) {
fprintf(stderr, "%s: Can not open.\n", argv[optind]);
return (-1);
}
if (fread(&h, sizeof (h), 1, in) != 1) {
fprintf(stderr, "%s: Can not read header.\n", argv[optind]);
fclose(in);
return (-2);
}
if (strcmp(h.ras_magic, RAS_MAGIC) == 0) {
#ifndef WORDS_BIGENDIAN
TIFFSwabLong((uint32_t *)&h.ras_width);
TIFFSwabLong((uint32_t *)&h.ras_height);
TIFFSwabLong((uint32_t *)&h.ras_depth);
TIFFSwabLong((uint32_t *)&h.ras_length);
TIFFSwabLong((uint32_t *)&h.ras_type);
TIFFSwabLong((uint32_t *)&h.ras_maptype);
TIFFSwabLong((uint32_t *)&h.ras_maplength);
TIFFSwabLong((uint32 *)&h.ras_width);
TIFFSwabLong((uint32 *)&h.ras_height);
TIFFSwabLong((uint32 *)&h.ras_depth);
TIFFSwabLong((uint32 *)&h.ras_length);
TIFFSwabLong((uint32 *)&h.ras_type);
TIFFSwabLong((uint32 *)&h.ras_maptype);
TIFFSwabLong((uint32 *)&h.ras_maplength);
#endif
}
else if (strcmp(h.ras_magic, RAS_MAGIC_INV) == 0)
{
} else if (strcmp(h.ras_magic, RAS_MAGIC_INV) == 0) {
#ifdef WORDS_BIGENDIAN
TIFFSwabLong((uint32_t *)&h.ras_width);
TIFFSwabLong((uint32_t *)&h.ras_height);
TIFFSwabLong((uint32_t *)&h.ras_depth);
TIFFSwabLong((uint32_t *)&h.ras_length);
TIFFSwabLong((uint32_t *)&h.ras_type);
TIFFSwabLong((uint32_t *)&h.ras_maptype);
TIFFSwabLong((uint32_t *)&h.ras_maplength);
TIFFSwabLong((uint32 *)&h.ras_width);
TIFFSwabLong((uint32 *)&h.ras_height);
TIFFSwabLong((uint32 *)&h.ras_depth);
TIFFSwabLong((uint32 *)&h.ras_length);
TIFFSwabLong((uint32 *)&h.ras_type);
TIFFSwabLong((uint32 *)&h.ras_maptype);
TIFFSwabLong((uint32 *)&h.ras_maplength);
#endif
}
else
{
fprintf(stderr, "%s: Not a rasterfile.\n", argv[optind]);
fclose(in);
return (-3);
}
if ((h.ras_width <= 0) || (h.ras_width >= INT_MAX) || (h.ras_height <= 0) ||
(h.ras_height >= INT_MAX) || (h.ras_depth <= 0) ||
(h.ras_depth >= INT_MAX) || (h.ras_length <= 0) ||
(h.ras_length >= INT_MAX) || (h.ras_type <= 0) ||
(h.ras_maptype <= 0) || (h.ras_maplength <= 0) ||
(h.ras_maplength >= INT_MAX))
{
fprintf(stderr, "%s: Improper image header.\n", argv[optind]);
fclose(in);
return (-2);
}
if ((h.ras_depth != 1) && (h.ras_depth != 8) && (h.ras_depth != 24))
{
fprintf(stderr, "%s: Improper image depth (%d).\n", argv[optind],
h.ras_depth);
fclose(in);
return (-2);
}
out = TIFFOpen(argv[optind + 1], "w");
if (out == NULL)
{
fclose(in);
return (-4);
}
TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32_t)h.ras_width);
TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32_t)h.ras_height);
TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, h.ras_depth > 8 ? 3 : 1);
TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, h.ras_depth > 1 ? 8 : 1);
TIFFSetField(out, TIFFTAG_PLANARCONFIG, config);
if (h.ras_maptype != RMT_NONE)
{
uint16_t *red;
register uint16_t *map;
register int i, j;
int mapsize;
} else {
fprintf(stderr, "%s: Not a rasterfile.\n", argv[optind]);
fclose(in);
return (-3);
}
if ((h.ras_width <= 0) || (h.ras_width >= INT_MAX) ||
(h.ras_height <= 0) || (h.ras_height >= INT_MAX) ||
(h.ras_depth <= 0) || (h.ras_depth >= INT_MAX) ||
(h.ras_length <= 0) || (h.ras_length >= INT_MAX) ||
(h.ras_type <= 0) ||
(h.ras_maptype <= 0) ||
(h.ras_maplength <= 0) || (h.ras_maplength >= INT_MAX)) {
fprintf(stderr, "%s: Improper image header.\n", argv[optind]);
fclose(in);
return (-2);
}
if ((h.ras_depth != 1) &&
(h.ras_depth != 8) &&
(h.ras_depth != 24)) {
fprintf(stderr, "%s: Improper image depth (%d).\n",
argv[optind], h.ras_depth);
fclose(in);
return (-2);
}
out = TIFFOpen(argv[optind+1], "w");
if (out == NULL)
{
fclose(in);
return (-4);
}
TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32) h.ras_width);
TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32) h.ras_height);
TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, h.ras_depth > 8 ? 3 : 1);
TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, h.ras_depth > 1 ? 8 : 1);
TIFFSetField(out, TIFFTAG_PLANARCONFIG, config);
if (h.ras_maptype != RMT_NONE) {
uint16* red;
register uint16* map;
register int i, j;
int mapsize;
buf = (unsigned char *)_TIFFmalloc(h.ras_maplength);
if (buf == NULL)
{
fprintf(stderr, "No space to read in colormap.\n");
fclose(in);
(void)TIFFClose(out);
return (-5);
}
if (fread(buf, h.ras_maplength, 1, in) != 1)
{
fprintf(stderr, "%s: Read error on colormap.\n", argv[optind]);
fclose(in);
(void)TIFFClose(out);
return (-6);
}
mapsize = 1 << h.ras_depth;
if (h.ras_maplength > mapsize * 3)
{
fprintf(stderr, "%s: Huh, %d colormap entries, should be %d?\n",
argv[optind], h.ras_maplength, mapsize * 3);
fclose(in);
(void)TIFFClose(out);
return (-7);
}
red = (uint16_t *)_TIFFmalloc(mapsize * 3 * sizeof(uint16_t));
if (red == NULL)
{
fprintf(stderr, "No space for colormap.\n");
fclose(in);
(void)TIFFClose(out);
return (-8);
}
map = red;
for (j = 0; j < 3; j++)
{
#define SCALE(x) (((x) * ((1L << 16) - 1)) / 255)
for (i = h.ras_maplength / 3; i-- > 0;)
*map++ = SCALE(*buf++);
if ((i = h.ras_maplength / 3) < mapsize)
{
i = mapsize - i;
_TIFFmemset(map, 0, i * sizeof(uint16_t));
map += i;
}
}
TIFFSetField(out, TIFFTAG_COLORMAP, red, red + mapsize,
red + 2 * mapsize);
photometric = PHOTOMETRIC_PALETTE;
if (compression == (uint16_t)-1)
compression = COMPRESSION_PACKBITS;
TIFFSetField(out, TIFFTAG_COMPRESSION, compression);
}
else
{
/* XXX this is bogus... */
photometric =
h.ras_depth == 24 ? PHOTOMETRIC_RGB : PHOTOMETRIC_MINISBLACK;
if (compression == (uint16_t)-1)
compression = COMPRESSION_LZW;
TIFFSetField(out, TIFFTAG_COMPRESSION, compression);
}
switch (compression)
{
case COMPRESSION_JPEG:
if (photometric == PHOTOMETRIC_RGB &&
jpegcolormode == JPEGCOLORMODE_RGB)
photometric = PHOTOMETRIC_YCBCR;
TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality);
TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode);
break;
case COMPRESSION_LZW:
case COMPRESSION_ADOBE_DEFLATE:
case COMPRESSION_DEFLATE:
if (predictor != 0)
TIFFSetField(out, TIFFTAG_PREDICTOR, predictor);
break;
}
TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric);
linebytes = ((h.ras_depth * h.ras_width + 15) >> 3) & ~1;
scanline = TIFFScanlineSize(out);
if (scanline > linebytes)
{
buf = (unsigned char *)_TIFFmalloc(scanline);
_TIFFmemset(buf + linebytes, 0, scanline - linebytes);
}
else
buf = (unsigned char *)_TIFFmalloc(linebytes);
TIFFSetField(out, TIFFTAG_ROWSPERSTRIP,
TIFFDefaultStripSize(out, rowsperstrip));
for (row = 0; row < h.ras_height; row++)
{
if (fread(buf, linebytes, 1, in) != 1)
{
fprintf(stderr, "%s: scanline %ld: Read error.\n", argv[optind],
row);
break;
}
if (h.ras_type == RT_STANDARD && h.ras_depth == 24)
{
tsize_t cc = h.ras_width;
unsigned char *cp = buf;
#define SWAP(a, b) \
{ \
unsigned char t = (a); \
(a) = (b); \
(b) = t; \
}
do
{
SWAP(cp[0], cp[2]);
cp += 3;
} while (--cc);
}
if (TIFFWriteScanline(out, buf, row, 0) < 0)
break;
}
(void)TIFFClose(out);
fclose(in);
return (0);
buf = (unsigned char *)_TIFFmalloc(h.ras_maplength);
if (buf == NULL) {
fprintf(stderr, "No space to read in colormap.\n");
return (-5);
}
if (fread(buf, h.ras_maplength, 1, in) != 1) {
fprintf(stderr, "%s: Read error on colormap.\n",
argv[optind]);
return (-6);
}
mapsize = 1<<h.ras_depth;
if (h.ras_maplength > mapsize*3) {
fprintf(stderr,
"%s: Huh, %d colormap entries, should be %d?\n",
argv[optind], h.ras_maplength, mapsize*3);
return (-7);
}
red = (uint16*)_TIFFmalloc(mapsize * 3 * sizeof (uint16));
if (red == NULL) {
fprintf(stderr, "No space for colormap.\n");
return (-8);
}
map = red;
for (j = 0; j < 3; j++) {
#define SCALE(x) (((x)*((1L<<16)-1))/255)
for (i = h.ras_maplength/3; i-- > 0;)
*map++ = SCALE(*buf++);
if ((i = h.ras_maplength/3) < mapsize) {
i = mapsize - i;
_TIFFmemset(map, 0, i*sizeof (uint16));
map += i;
}
}
TIFFSetField(out, TIFFTAG_COLORMAP,
red, red + mapsize, red + 2*mapsize);
photometric = PHOTOMETRIC_PALETTE;
if (compression == (uint16) -1)
compression = COMPRESSION_PACKBITS;
TIFFSetField(out, TIFFTAG_COMPRESSION, compression);
} else {
/* XXX this is bogus... */
photometric = h.ras_depth == 24 ?
PHOTOMETRIC_RGB : PHOTOMETRIC_MINISBLACK;
if (compression == (uint16) -1)
compression = COMPRESSION_LZW;
TIFFSetField(out, TIFFTAG_COMPRESSION, compression);
}
switch (compression) {
case COMPRESSION_JPEG:
if (photometric == PHOTOMETRIC_RGB && jpegcolormode == JPEGCOLORMODE_RGB)
photometric = PHOTOMETRIC_YCBCR;
TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality);
TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode);
break;
case COMPRESSION_LZW:
case COMPRESSION_DEFLATE:
if (predictor != 0)
TIFFSetField(out, TIFFTAG_PREDICTOR, predictor);
break;
}
TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric);
linebytes = ((h.ras_depth*h.ras_width+15) >> 3) &~ 1;
scanline = TIFFScanlineSize(out);
if (scanline > linebytes) {
buf = (unsigned char *)_TIFFmalloc(scanline);
_TIFFmemset(buf+linebytes, 0, scanline-linebytes);
} else
buf = (unsigned char *)_TIFFmalloc(linebytes);
TIFFSetField(out, TIFFTAG_ROWSPERSTRIP,
TIFFDefaultStripSize(out, rowsperstrip));
for (row = 0; row < h.ras_height; row++) {
if (fread(buf, linebytes, 1, in) != 1) {
fprintf(stderr, "%s: scanline %ld: Read error.\n",
argv[optind], row);
break;
}
if (h.ras_type == RT_STANDARD && h.ras_depth == 24) {
tsize_t cc = h.ras_width;
unsigned char* cp = buf;
#define SWAP(a,b) { unsigned char t = (a); (a) = (b); (b) = t; }
do {
SWAP(cp[0], cp[2]);
cp += 3;
} while (--cc);
}
if (TIFFWriteScanline(out, buf, row, 0) < 0)
break;
}
(void) TIFFClose(out);
fclose(in);
return (0);
}
static int processCompressOptions(char *opt)
static int
processCompressOptions(char* opt)
{
if (streq(opt, "none"))
compression = COMPRESSION_NONE;
else if (streq(opt, "packbits"))
compression = COMPRESSION_PACKBITS;
else if (strneq(opt, "jpeg", 4))
{
char *cp = strchr(opt, ':');
if (streq(opt, "none"))
compression = COMPRESSION_NONE;
else if (streq(opt, "packbits"))
compression = COMPRESSION_PACKBITS;
else if (strneq(opt, "jpeg", 4)) {
char* cp = strchr(opt, ':');
compression = COMPRESSION_JPEG;
while (cp)
{
if (isdigit((int)cp[1]))
quality = atoi(cp + 1);
else if (cp[1] == 'r')
jpegcolormode = JPEGCOLORMODE_RAW;
else
usage();
compression = COMPRESSION_JPEG;
while( cp )
{
if (isdigit((int)cp[1]))
quality = atoi(cp+1);
else if (cp[1] == 'r' )
jpegcolormode = JPEGCOLORMODE_RAW;
else
usage();
cp = strchr(cp + 1, ':');
}
}
else if (strneq(opt, "lzw", 3))
{
char *cp = strchr(opt, ':');
if (cp)
predictor = atoi(cp + 1);
compression = COMPRESSION_LZW;
}
else if (strneq(opt, "zip", 3))
{
char *cp = strchr(opt, ':');
if (cp)
predictor = atoi(cp + 1);
compression = COMPRESSION_ADOBE_DEFLATE;
}
else
return (0);
return (1);
cp = strchr(cp+1,':');
}
} else if (strneq(opt, "lzw", 3)) {
char* cp = strchr(opt, ':');
if (cp)
predictor = atoi(cp+1);
compression = COMPRESSION_LZW;
} else if (strneq(opt, "zip", 3)) {
char* cp = strchr(opt, ':');
if (cp)
predictor = atoi(cp+1);
compression = COMPRESSION_DEFLATE;
} else
return (0);
return (1);
}
char *stuff[] = {
"usage: ras2tiff [options] input.ras output.tif",
"where options are:",
" -r # make each strip have no more than # rows",
"",
" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding",
" -c zip[:opts] compress output with deflate encoding",
" -c jpeg[:opts] compress output with JPEG encoding",
" -c packbits compress output with packbits encoding",
" -c none use no compression algorithm on output",
"",
"JPEG options:",
" # set compression quality level (0-100, default 75)",
" r output color image as RGB rather than YCbCr",
"For example, -c jpeg:r:50 to get JPEG-encoded RGB data with 50% comp. "
"quality",
"",
"LZW and deflate options:",
" # set predictor value",
"For example, -c lzw:2 to get LZW-encoded data with horizontal "
"differencing",
" -h this help message",
NULL};
char* stuff[] = {
"usage: ras2tiff [options] input.ras output.tif",
"where options are:",
" -r # make each strip have no more than # rows",
"",
" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding",
" -c zip[:opts] compress output with deflate encoding",
" -c jpeg[:opts] compress output with JPEG encoding",
" -c packbits compress output with packbits encoding",
" -c none use no compression algorithm on output",
"",
"JPEG options:",
" # set compression quality level (0-100, default 75)",
" r output color image as RGB rather than YCbCr",
"For example, -c jpeg:r:50 to get JPEG-encoded RGB data with 50% comp. quality",
"",
"LZW and deflate options:",
" # set predictor value",
"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing",
" -h this help message",
NULL
};
static void usage(void)
static void
usage(void)
{
char buf[BUFSIZ];
int i;
char buf[BUFSIZ];
int i;
setbuf(stderr, buf);
fprintf(stderr, "%s\n\n", TIFFGetVersion());
for (i = 0; stuff[i] != NULL; i++)
fprintf(stderr, "%s\n", stuff[i]);
exit(-1);
setbuf(stderr, buf);
fprintf(stderr, "%s\n\n", TIFFGetVersion());
for (i = 0; stuff[i] != NULL; i++)
fprintf(stderr, "%s\n", stuff[i]);
exit(-1);
}
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -3,32 +3,31 @@
/*
* Description of header for files containing raster images
*/
struct rasterfile
{
char ras_magic[4]; /* magic number */
int32_t ras_width; /* width (pixels) of image */
int32_t ras_height; /* height (pixels) of image */
int32_t ras_depth; /* depth (1, 8, or 24 bits) of pixel */
int32_t ras_length; /* length (bytes) of image */
int32_t ras_type; /* type of file; see RT_* below */
int32_t ras_maptype; /* type of colormap; see RMT_* below */
int32_t ras_maplength; /* length (bytes) of following map */
/* color map follows for ras_maplength bytes, followed by image */
struct rasterfile {
char ras_magic[4]; /* magic number */
int32 ras_width; /* width (pixels) of image */
int32 ras_height; /* height (pixels) of image */
int32 ras_depth; /* depth (1, 8, or 24 bits) of pixel */
int32 ras_length; /* length (bytes) of image */
int32 ras_type; /* type of file; see RT_* below */
int32 ras_maptype; /* type of colormap; see RMT_* below */
int32 ras_maplength; /* length (bytes) of following map */
/* color map follows for ras_maplength bytes, followed by image */
};
#define RAS_MAGIC "\x59\xa6\x6a\x95"
#define RAS_MAGIC_INV "\x95\x6a\xa6\x59"
#define RAS_MAGIC "\x59\xa6\x6a\x95"
#define RAS_MAGIC_INV "\x95\x6a\xa6\x59"
/* Sun supported ras_type's */
#define RT_OLD 0 /* Raw pixrect image in 68000 byte order */
#define RT_STANDARD 1 /* Raw pixrect image in 68000 byte order */
#define RT_BYTE_ENCODED 2 /* Run-length compression of bytes */
#define RT_EXPERIMENTAL 0xffff /* Reserved for testing */
/* Sun supported ras_type's */
#define RT_OLD 0 /* Raw pixrect image in 68000 byte order */
#define RT_STANDARD 1 /* Raw pixrect image in 68000 byte order */
#define RT_BYTE_ENCODED 2 /* Run-length compression of bytes */
#define RT_EXPERIMENTAL 0xffff /* Reserved for testing */
/* Sun registered ras_maptype's */
#define RMT_RAW 2
/* Sun supported ras_maptype's */
#define RMT_NONE 0 /* ras_maplength is expected to be 0 */
#define RMT_EQUAL_RGB 1 /* red[ras_maplength/3],green[],blue[] */
/* Sun registered ras_maptype's */
#define RMT_RAW 2
/* Sun supported ras_maptype's */
#define RMT_NONE 0 /* ras_maplength is expected to be 0 */
#define RMT_EQUAL_RGB 1 /* red[ras_maplength/3],green[],blue[] */
/*
* NOTES:

View file

@ -2,345 +2,334 @@
* Copyright (c) 1991-1997 Sam Leffler
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
* 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.
*
*
* 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
* 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.
*/
#include <ctype.h>
#include <gl/image.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gl/image.h>
#include <ctype.h>
#include "tiffio.h"
#define streq(a, b) (strcmp(a, b) == 0)
#define strneq(a, b, n) (strncmp(a, b, n) == 0)
#define streq(a,b) (strcmp(a,b) == 0)
#define strneq(a,b,n) (strncmp(a,b,n) == 0)
static short config = PLANARCONFIG_CONTIG;
static uint16_t compression = COMPRESSION_PACKBITS;
static uint16_t predictor = 0;
static uint16_t fillorder = 0;
static uint32_t rowsperstrip = (uint32_t)-1;
static int jpegcolormode = JPEGCOLORMODE_RGB;
static int quality = 75; /* JPEG quality */
static uint16_t photometric;
static short config = PLANARCONFIG_CONTIG;
static uint16 compression = COMPRESSION_PACKBITS;
static uint16 predictor = 0;
static uint16 fillorder = 0;
static uint32 rowsperstrip = (uint32) -1;
static int jpegcolormode = JPEGCOLORMODE_RGB;
static int quality = 75; /* JPEG quality */
static uint16 photometric;
static void usage(void);
static int cpContig(IMAGE *, TIFF *);
static int cpSeparate(IMAGE *, TIFF *);
static int processCompressOptions(char *);
static void usage(void);
static int cpContig(IMAGE*, TIFF*);
static int cpSeparate(IMAGE*, TIFF*);
static int processCompressOptions(char*);
/* XXX image library has no prototypes */
extern IMAGE *iopen(const char *, const char *);
extern void iclose(IMAGE *);
extern void getrow(IMAGE *, short *, int, int);
extern IMAGE* iopen(const char*, const char*);
extern void iclose(IMAGE*);
extern void getrow(IMAGE*, short*, int, int);
int main(int argc, char *argv[])
int
main(int argc, char* argv[])
{
IMAGE *in;
TIFF *out;
int c;
IMAGE *in;
TIFF *out;
int c;
#if !HAVE_DECL_OPTARG
extern int optind;
extern char *optarg;
extern int optind;
extern char* optarg;
#endif
while ((c = getopt(argc, argv, "c:p:r:")) != -1)
switch (c)
{
case 'c': /* compression scheme */
if (!processCompressOptions(optarg))
usage();
break;
case 'f': /* fill order */
if (streq(optarg, "lsb2msb"))
fillorder = FILLORDER_LSB2MSB;
else if (streq(optarg, "msb2lsb"))
fillorder = FILLORDER_MSB2LSB;
else
usage();
break;
case 'p': /* planar configuration */
if (streq(optarg, "separate"))
config = PLANARCONFIG_SEPARATE;
else if (streq(optarg, "contig"))
config = PLANARCONFIG_CONTIG;
else
usage();
break;
case 'r': /* rows/strip */
rowsperstrip = atoi(optarg);
break;
case '?':
usage();
/*NOTREACHED*/
}
if (argc - optind != 2)
usage();
in = iopen(argv[optind], "r");
if (in == NULL)
return (-1);
out = TIFFOpen(argv[optind + 1], "w");
if (out == NULL)
return (-2);
TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32_t)in->xsize);
TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32_t)in->ysize);
TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8);
TIFFSetField(out, TIFFTAG_COMPRESSION, compression);
if (in->zsize == 1)
photometric = PHOTOMETRIC_MINISBLACK;
else
photometric = PHOTOMETRIC_RGB;
switch (compression)
{
case COMPRESSION_JPEG:
if (photometric == PHOTOMETRIC_RGB &&
jpegcolormode == JPEGCOLORMODE_RGB)
photometric = PHOTOMETRIC_YCBCR;
TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality);
TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode);
break;
case COMPRESSION_LZW:
case COMPRESSION_ADOBE_DEFLATE:
case COMPRESSION_DEFLATE:
if (predictor != 0)
TIFFSetField(out, TIFFTAG_PREDICTOR, predictor);
break;
}
TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric);
if (fillorder != 0)
TIFFSetField(out, TIFFTAG_FILLORDER, fillorder);
TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, in->zsize);
if (in->zsize > 3)
{
uint16_t v[1];
v[0] = EXTRASAMPLE_UNASSALPHA;
TIFFSetField(out, TIFFTAG_EXTRASAMPLES, 1, v);
}
TIFFSetField(out, TIFFTAG_MINSAMPLEVALUE, (uint16_t)in->min);
TIFFSetField(out, TIFFTAG_MAXSAMPLEVALUE, (uint16_t)in->max);
TIFFSetField(out, TIFFTAG_PLANARCONFIG, config);
if (config != PLANARCONFIG_SEPARATE)
TIFFSetField(out, TIFFTAG_ROWSPERSTRIP,
TIFFDefaultStripSize(out, rowsperstrip));
else /* force 1 row/strip for library limitation */
TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, 1L);
if (in->name[0] != '\0')
TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION, in->name);
if (config == PLANARCONFIG_CONTIG)
cpContig(in, out);
else
cpSeparate(in, out);
(void)iclose(in);
(void)TIFFClose(out);
return (0);
while ((c = getopt(argc, argv, "c:p:r:")) != -1)
switch (c) {
case 'c': /* compression scheme */
if (!processCompressOptions(optarg))
usage();
break;
case 'f': /* fill order */
if (streq(optarg, "lsb2msb"))
fillorder = FILLORDER_LSB2MSB;
else if (streq(optarg, "msb2lsb"))
fillorder = FILLORDER_MSB2LSB;
else
usage();
break;
case 'p': /* planar configuration */
if (streq(optarg, "separate"))
config = PLANARCONFIG_SEPARATE;
else if (streq(optarg, "contig"))
config = PLANARCONFIG_CONTIG;
else
usage();
break;
case 'r': /* rows/strip */
rowsperstrip = atoi(optarg);
break;
case '?':
usage();
/*NOTREACHED*/
}
if (argc - optind != 2)
usage();
in = iopen(argv[optind], "r");
if (in == NULL)
return (-1);
out = TIFFOpen(argv[optind+1], "w");
if (out == NULL)
return (-2);
TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32) in->xsize);
TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32) in->ysize);
TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8);
TIFFSetField(out, TIFFTAG_COMPRESSION, compression);
if (in->zsize == 1)
photometric = PHOTOMETRIC_MINISBLACK;
else
photometric = PHOTOMETRIC_RGB;
switch (compression) {
case COMPRESSION_JPEG:
if (photometric == PHOTOMETRIC_RGB && jpegcolormode == JPEGCOLORMODE_RGB)
photometric = PHOTOMETRIC_YCBCR;
TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality);
TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode);
break;
case COMPRESSION_LZW:
case COMPRESSION_DEFLATE:
if (predictor != 0)
TIFFSetField(out, TIFFTAG_PREDICTOR, predictor);
break;
}
TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric);
if (fillorder != 0)
TIFFSetField(out, TIFFTAG_FILLORDER, fillorder);
TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, in->zsize);
if (in->zsize > 3) {
uint16 v[1];
v[0] = EXTRASAMPLE_UNASSALPHA;
TIFFSetField(out, TIFFTAG_EXTRASAMPLES, 1, v);
}
TIFFSetField(out, TIFFTAG_MINSAMPLEVALUE, (uint16) in->min);
TIFFSetField(out, TIFFTAG_MAXSAMPLEVALUE, (uint16) in->max);
TIFFSetField(out, TIFFTAG_PLANARCONFIG, config);
if (config != PLANARCONFIG_SEPARATE)
TIFFSetField(out, TIFFTAG_ROWSPERSTRIP,
TIFFDefaultStripSize(out, rowsperstrip));
else /* force 1 row/strip for library limitation */
TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, 1L);
if (in->name[0] != '\0')
TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION, in->name);
if (config == PLANARCONFIG_CONTIG)
cpContig(in, out);
else
cpSeparate(in, out);
(void) iclose(in);
(void) TIFFClose(out);
return (0);
}
static int processCompressOptions(char *opt)
static int
processCompressOptions(char* opt)
{
if (streq(opt, "none"))
compression = COMPRESSION_NONE;
else if (streq(opt, "packbits"))
compression = COMPRESSION_PACKBITS;
else if (strneq(opt, "jpeg", 4))
{
char *cp = strchr(opt, ':');
if (streq(opt, "none"))
compression = COMPRESSION_NONE;
else if (streq(opt, "packbits"))
compression = COMPRESSION_PACKBITS;
else if (strneq(opt, "jpeg", 4)) {
char* cp = strchr(opt, ':');
defcompression = COMPRESSION_JPEG;
while (cp)
{
if (isdigit((int)cp[1]))
quality = atoi(cp + 1);
else if (cp[1] == 'r')
jpegcolormode = JPEGCOLORMODE_RAW;
else
usage();
defcompression = COMPRESSION_JPEG;
while( cp )
{
if (isdigit((int)cp[1]))
quality = atoi(cp+1);
else if (cp[1] == 'r' )
jpegcolormode = JPEGCOLORMODE_RAW;
else
usage();
cp = strchr(cp + 1, ':');
}
}
else if (strneq(opt, "lzw", 3))
{
char *cp = strchr(opt, ':');
if (cp)
predictor = atoi(cp + 1);
compression = COMPRESSION_LZW;
}
else if (strneq(opt, "zip", 3))
{
char *cp = strchr(opt, ':');
if (cp)
predictor = atoi(cp + 1);
compression = COMPRESSION_ADOBE_DEFLATE;
}
else
return (0);
return (1);
cp = strchr(cp+1,':');
}
} else if (strneq(opt, "lzw", 3)) {
char* cp = strchr(opt, ':');
if (cp)
predictor = atoi(cp+1);
compression = COMPRESSION_LZW;
} else if (strneq(opt, "zip", 3)) {
char* cp = strchr(opt, ':');
if (cp)
predictor = atoi(cp+1);
compression = COMPRESSION_DEFLATE;
} else
return (0);
return (1);
}
static int cpContig(IMAGE *in, TIFF *out)
static int
cpContig(IMAGE* in, TIFF* out)
{
tdata_t buf = _TIFFmalloc(TIFFScanlineSize(out));
short *r = NULL;
int x, y;
tdata_t buf = _TIFFmalloc(TIFFScanlineSize(out));
short *r = NULL;
int x, y;
if (in->zsize == 3)
{
short *g, *b;
if (in->zsize == 3) {
short *g, *b;
r = (short *)_TIFFmalloc(3 * in->xsize * sizeof(short));
g = r + in->xsize;
b = g + in->xsize;
for (y = in->ysize - 1; y >= 0; y--)
{
uint8_t *pp = (uint8_t *)buf;
r = (short *)_TIFFmalloc(3 * in->xsize * sizeof (short));
g = r + in->xsize;
b = g + in->xsize;
for (y = in->ysize-1; y >= 0; y--) {
uint8* pp = (uint8*) buf;
getrow(in, r, y, 0);
getrow(in, g, y, 1);
getrow(in, b, y, 2);
for (x = 0; x < in->xsize; x++)
{
pp[0] = r[x];
pp[1] = g[x];
pp[2] = b[x];
pp += 3;
}
if (TIFFWriteScanline(out, buf, in->ysize - y - 1, 0) < 0)
goto bad;
}
}
else if (in->zsize == 4)
{
short *g, *b, *a;
getrow(in, r, y, 0);
getrow(in, g, y, 1);
getrow(in, b, y, 2);
for (x = 0; x < in->xsize; x++) {
pp[0] = r[x];
pp[1] = g[x];
pp[2] = b[x];
pp += 3;
}
if (TIFFWriteScanline(out, buf, in->ysize-y-1, 0) < 0)
goto bad;
}
} else if (in->zsize == 4) {
short *g, *b, *a;
r = (short *)_TIFFmalloc(4 * in->xsize * sizeof(short));
g = r + in->xsize;
b = g + in->xsize;
a = b + in->xsize;
for (y = in->ysize - 1; y >= 0; y--)
{
uint8_t *pp = (uint8_t *)buf;
r = (short *)_TIFFmalloc(4 * in->xsize * sizeof (short));
g = r + in->xsize;
b = g + in->xsize;
a = b + in->xsize;
for (y = in->ysize-1; y >= 0; y--) {
uint8* pp = (uint8*) buf;
getrow(in, r, y, 0);
getrow(in, g, y, 1);
getrow(in, b, y, 2);
getrow(in, a, y, 3);
for (x = 0; x < in->xsize; x++)
{
pp[0] = r[x];
pp[1] = g[x];
pp[2] = b[x];
pp[3] = a[x];
pp += 4;
}
if (TIFFWriteScanline(out, buf, in->ysize - y - 1, 0) < 0)
goto bad;
}
}
else
{
uint8_t *pp = (uint8_t *)buf;
getrow(in, r, y, 0);
getrow(in, g, y, 1);
getrow(in, b, y, 2);
getrow(in, a, y, 3);
for (x = 0; x < in->xsize; x++) {
pp[0] = r[x];
pp[1] = g[x];
pp[2] = b[x];
pp[3] = a[x];
pp += 4;
}
if (TIFFWriteScanline(out, buf, in->ysize-y-1, 0) < 0)
goto bad;
}
} else {
uint8* pp = (uint8*) buf;
r = (short *)_TIFFmalloc(in->xsize * sizeof(short));
for (y = in->ysize - 1; y >= 0; y--)
{
getrow(in, r, y, 0);
for (x = in->xsize - 1; x >= 0; x--)
pp[x] = r[x];
if (TIFFWriteScanline(out, buf, in->ysize - y - 1, 0) < 0)
goto bad;
}
}
if (r)
_TIFFfree(r);
_TIFFfree(buf);
return (1);
r = (short *)_TIFFmalloc(in->xsize * sizeof (short));
for (y = in->ysize-1; y >= 0; y--) {
getrow(in, r, y, 0);
for (x = in->xsize-1; x >= 0; x--)
pp[x] = r[x];
if (TIFFWriteScanline(out, buf, in->ysize-y-1, 0) < 0)
goto bad;
}
}
if (r)
_TIFFfree(r);
_TIFFfree(buf);
return (1);
bad:
if (r)
_TIFFfree(r);
_TIFFfree(buf);
return (0);
if (r)
_TIFFfree(r);
_TIFFfree(buf);
return (0);
}
static int cpSeparate(IMAGE *in, TIFF *out)
static int
cpSeparate(IMAGE* in, TIFF* out)
{
tdata_t buf = _TIFFmalloc(TIFFScanlineSize(out));
short *r = (short *)_TIFFmalloc(in->xsize * sizeof(short));
uint8_t *pp = (uint8_t *)buf;
int x, y, z;
tdata_t buf = _TIFFmalloc(TIFFScanlineSize(out));
short *r = (short *)_TIFFmalloc(in->xsize * sizeof (short));
uint8* pp = (uint8*) buf;
int x, y, z;
for (z = 0; z < in->zsize; z++)
{
for (y = in->ysize - 1; y >= 0; y--)
{
getrow(in, r, y, z);
for (x = 0; x < in->xsize; x++)
pp[x] = r[x];
if (TIFFWriteScanline(out, buf, in->ysize - y - 1, z) < 0)
goto bad;
}
}
_TIFFfree(r);
_TIFFfree(buf);
return (1);
for (z = 0; z < in->zsize; z++) {
for (y = in->ysize-1; y >= 0; y--) {
getrow(in, r, y, z);
for (x = 0; x < in->xsize; x++)
pp[x] = r[x];
if (TIFFWriteScanline(out, buf, in->ysize-y-1, z) < 0)
goto bad;
}
}
_TIFFfree(r);
_TIFFfree(buf);
return (1);
bad:
_TIFFfree(r);
_TIFFfree(buf);
return (0);
_TIFFfree(r);
_TIFFfree(buf);
return (0);
}
char *stuff[] = {
"usage: sgi2tiff [options] input.rgb output.tif",
"where options are:",
" -r # make each strip have no more than # rows",
"",
" -p contig pack samples contiguously (e.g. RGBRGB...)",
" -p separate store samples separately (e.g. RRR...GGG...BBB...)",
"",
" -f lsb2msb force lsb-to-msb FillOrder for output",
" -f msb2lsb force msb-to-lsb FillOrder for output",
"",
" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding",
" -c zip[:opts] compress output with deflate encoding",
" -c jpeg[:opts]compress output with JPEG encoding",
" -c packbits compress output with packbits encoding",
" -c none use no compression algorithm on output",
"",
"JPEG options:",
" # set compression quality level (0-100, default 75)",
" r output color image as RGB rather than YCbCr",
"",
"LZW and deflate options:",
" # set predictor value",
"For example, -c lzw:2 to get LZW-encoded data with horizontal "
"differencing",
NULL};
char* stuff[] = {
"usage: sgi2tiff [options] input.rgb output.tif",
"where options are:",
" -r # make each strip have no more than # rows",
"",
" -p contig pack samples contiguously (e.g. RGBRGB...)",
" -p separate store samples separately (e.g. RRR...GGG...BBB...)",
"",
" -f lsb2msb force lsb-to-msb FillOrder for output",
" -f msb2lsb force msb-to-lsb FillOrder for output",
"",
" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding",
" -c zip[:opts] compress output with deflate encoding",
" -c jpeg[:opts]compress output with JPEG encoding",
" -c packbits compress output with packbits encoding",
" -c none use no compression algorithm on output",
"",
"JPEG options:",
" # set compression quality level (0-100, default 75)",
" r output color image as RGB rather than YCbCr",
"",
"LZW and deflate options:",
" # set predictor value",
"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing",
NULL
};
static void usage(void)
static void
usage(void)
{
char buf[BUFSIZ];
int i;
char buf[BUFSIZ];
int i;
setbuf(stderr, buf);
for (i = 0; stuff[i] != NULL; i++)
fprintf(stderr, "%s\n", stuff[i]);
exit(-1);
setbuf(stderr, buf);
for (i = 0; stuff[i] != NULL; i++)
fprintf(stderr, "%s\n", stuff[i]);
exit(-1);
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -2,23 +2,23 @@
* Copyright (c) 1990-1997 Sam Leffler
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
* 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.
*
*
* 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
* 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.
*/
@ -26,297 +26,291 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <gl.h>
#include <ctype.h>
#include "tiffio.h"
typedef unsigned char unsigned char;
typedef unsigned long uint32_t;
typedef unsigned long uint32;
#define streq(a, b) (strcmp(a, b) == 0)
#define strneq(a, b, n) (strncmp(a, b, n) == 0)
#define streq(a,b) (strcmp(a,b) == 0)
#define strneq(a,b,n) (strncmp(a,b,n) == 0)
uint32_t rowsperstrip = (uint32_t)-1;
uint16_t compression = COMPRESSION_PACKBITS;
uint16_t config = PLANARCONFIG_CONTIG;
uint16_t predictor = 0;
int xmaxscreen;
int ymaxscreen;
uint16_t photometric = PHOTOMETRIC_RGB;
int jpegcolormode = JPEGCOLORMODE_RGB;
int quality = 75; /* JPEG quality */
uint32 rowsperstrip = (uint32) -1;
uint16 compression = COMPRESSION_PACKBITS;
uint16 config = PLANARCONFIG_CONTIG;
uint16 predictor = 0;
int xmaxscreen;
int ymaxscreen;
uint16 photometric = PHOTOMETRIC_RGB;
int jpegcolormode = JPEGCOLORMODE_RGB;
int quality = 75; /* JPEG quality */
static void usage(void);
static void tiffsv(char *, int, int, int, int);
static void usage(void);
static void tiffsv(char*, int, int, int, int);
int main(int argc, char *argv[])
int
main(int argc, char* argv[])
{
int c;
int c;
#if !HAVE_DECL_OPTARG
extern int optind;
extern char *optarg;
extern int optind;
extern char* optarg;
#endif
while ((c = getopt(argc, argv, "c:p:r:")) != -1)
switch (c)
{
case 'b': /* save as b&w */
photometric = PHOTOMETRIC_MINISBLACK;
break;
case 'c': /* compression scheme */
if (streq(optarg, "none"))
compression = COMPRESSION_NONE;
else if (streq(optarg, "packbits"))
compression = COMPRESSION_PACKBITS;
else if (strneq(optarg, "jpeg", 4))
{
char *cp = strchr(optarg, ':');
if (cp && isdigit(cp[1]))
quality = atoi(cp + 1);
if (cp && strchr(cp, 'r'))
jpegcolormode = JPEGCOLORMODE_RAW;
compression = COMPRESSION_JPEG;
}
else if (strneq(optarg, "lzw", 3))
{
char *cp = strchr(optarg, ':');
if (cp)
predictor = atoi(cp + 1);
compression = COMPRESSION_LZW;
}
else
usage();
break;
case 'p': /* planar configuration */
if (streq(optarg, "separate"))
config = PLANARCONFIG_SEPARATE;
else if (streq(optarg, "contig"))
config = PLANARCONFIG_CONTIG;
else
usage();
break;
case 'r': /* rows/strip */
rowsperstrip = atoi(optarg);
break;
case '?':
usage();
/*NOTREACHED*/
}
if (argc - optind != 1 && argc - optind != 5)
usage();
xmaxscreen = getgdesc(GD_XPMAX) - 1;
ymaxscreen = getgdesc(GD_YPMAX) - 1;
foreground();
noport();
winopen("tiffsv");
if (argc - optind == 5)
tiffsv(argv[optind], atoi(argv[optind + 1]), atoi(argv[optind + 2]),
atoi(argv[optind + 3]), atoi(argv[optind + 4]));
else
tiffsv(argv[optind], 0, xmaxscreen, 0, ymaxscreen);
return (0);
while ((c = getopt(argc, argv, "c:p:r:")) != -1)
switch (c) {
case 'b': /* save as b&w */
photometric = PHOTOMETRIC_MINISBLACK;
break;
case 'c': /* compression scheme */
if (streq(optarg, "none"))
compression = COMPRESSION_NONE;
else if (streq(optarg, "packbits"))
compression = COMPRESSION_PACKBITS;
else if (strneq(optarg, "jpeg", 4)) {
char* cp = strchr(optarg, ':');
if (cp && isdigit(cp[1]))
quality = atoi(cp+1);
if (cp && strchr(cp, 'r'))
jpegcolormode = JPEGCOLORMODE_RAW;
compression = COMPRESSION_JPEG;
} else if (strneq(optarg, "lzw", 3)) {
char* cp = strchr(optarg, ':');
if (cp)
predictor = atoi(cp+1);
compression = COMPRESSION_LZW;
} else
usage();
break;
case 'p': /* planar configuration */
if (streq(optarg, "separate"))
config = PLANARCONFIG_SEPARATE;
else if (streq(optarg, "contig"))
config = PLANARCONFIG_CONTIG;
else
usage();
break;
case 'r': /* rows/strip */
rowsperstrip = atoi(optarg);
break;
case '?':
usage();
/*NOTREACHED*/
}
if (argc - optind != 1 && argc - optind != 5)
usage();
xmaxscreen = getgdesc(GD_XPMAX)-1;
ymaxscreen = getgdesc(GD_YPMAX)-1;
foreground();
noport();
winopen("tiffsv");
if (argc - optind == 5)
tiffsv(argv[optind],
atoi(argv[optind+1]), atoi(argv[optind+2]),
atoi(argv[optind+3]), atoi(argv[optind+4]));
else
tiffsv(argv[optind], 0, xmaxscreen, 0, ymaxscreen);
return (0);
}
char *stuff[] = {
"usage: tiffsv [options] outimage.tif [x1 x2 y1 y2] [-b]",
"where options are:",
" -p contig pack samples contiguously (e.g. RGBRGB...)",
" -p separate store samples separately (e.g. RRR...GGG...BBB...)",
"",
" -r # make each strip have no more than # rows",
"",
" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding",
" -c jpeg[:opts]compress output with JPEG encoding",
" -c packbits compress output with packbits encoding",
" -c none use no compression algorithm on output",
"",
"JPEG options:",
" # set compression quality level (0-100, default 75)",
" r output color image as RGB rather than YCbCr",
"",
"LZW options:",
" # set predictor value for Lempel-Ziv & Welch encoding",
"For example, -c lzw:2 to get LZW-encoded data with horizontal "
"differencing",
NULL};
char* stuff[] = {
"usage: tiffsv [options] outimage.tif [x1 x2 y1 y2] [-b]",
"where options are:",
" -p contig pack samples contiguously (e.g. RGBRGB...)",
" -p separate store samples separately (e.g. RRR...GGG...BBB...)",
"",
" -r # make each strip have no more than # rows",
"",
" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding",
" -c jpeg[:opts]compress output with JPEG encoding",
" -c packbits compress output with packbits encoding",
" -c none use no compression algorithm on output",
"",
"JPEG options:",
" # set compression quality level (0-100, default 75)",
" r output color image as RGB rather than YCbCr",
"",
"LZW options:",
" # set predictor value for Lempel-Ziv & Welch encoding",
"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing",
NULL
};
static void usage(void)
static void
usage(void)
{
char buf[BUFSIZ];
int i;
char buf[BUFSIZ];
int i;
setbuf(stderr, buf);
for (i = 0; stuff[i] != NULL; i++)
fprintf(stderr, "%s\n", stuff[i]);
exit(-1);
setbuf(stderr, buf);
for (i = 0; stuff[i] != NULL; i++)
fprintf(stderr, "%s\n", stuff[i]);
exit(-1);
}
static void svRGBSeparate(TIFF *tif, uint32_t *ss, int xsize, int ysize)
static void
svRGBSeparate(TIFF* tif, uint32* ss, int xsize, int ysize)
{
tsize_t stripsize = TIFFStripSize(tif);
unsigned char *rbuf = (unsigned char *)_TIFFmalloc(3 * stripsize);
unsigned char *gbuf = rbuf + stripsize;
unsigned char *bbuf = gbuf + stripsize;
register int y;
tsize_t stripsize = TIFFStripSize(tif);
unsigned char *rbuf = (unsigned char *)_TIFFmalloc(3*stripsize);
unsigned char *gbuf = rbuf + stripsize;
unsigned char *bbuf = gbuf + stripsize;
register int y;
for (y = 0; y <= ysize; y += rowsperstrip)
{
unsigned char *rp, *gp, *bp;
register int x;
register uint32_t n;
for (y = 0; y <= ysize; y += rowsperstrip) {
unsigned char *rp, *gp, *bp;
register int x;
register uint32 n;
n = rowsperstrip;
if (n > ysize - y + 1)
n = ysize - y + 1;
rp = rbuf;
gp = gbuf;
bp = bbuf;
do
{
for (x = 0; x <= xsize; x++)
{
uint32_t v = ss[x];
rp[x] = v;
gp[x] = v >> 8;
bp[x] = v >> 16;
}
rp += xsize + 1, gp += xsize + 1, bp += xsize + 1;
ss += xsize + 1;
} while (--n);
if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif, y, 0), rbuf,
stripsize) < 0)
break;
if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif, y, 1), gbuf,
stripsize) < 0)
break;
if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif, y, 2), bbuf,
stripsize) < 0)
break;
}
_TIFFfree(rbuf);
n = rowsperstrip;
if (n > ysize-y+1)
n = ysize-y+1;
rp = rbuf; gp = gbuf; bp = bbuf;
do {
for (x = 0; x <= xsize; x++) {
uint32 v = ss[x];
rp[x] = v;
gp[x] = v >> 8;
bp[x] = v >> 16;
}
rp += xsize+1, gp += xsize+1, bp += xsize+1;
ss += xsize+1;
} while (--n);
if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif,y,0),
rbuf, stripsize) < 0)
break;
if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif,y,1),
gbuf, stripsize) < 0)
break;
if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif,y,2),
bbuf, stripsize) < 0)
break;
}
_TIFFfree(rbuf);
}
static void svRGBContig(TIFF *tif, uint32_t *ss, int xsize, int ysize)
static void
svRGBContig(TIFF* tif, uint32* ss, int xsize, int ysize)
{
register int x, y;
tsize_t stripsize = TIFFStripSize(tif);
unsigned char *strip = (unsigned char *)_TIFFmalloc(stripsize);
register int x, y;
tsize_t stripsize = TIFFStripSize(tif);
unsigned char *strip = (unsigned char *)_TIFFmalloc(stripsize);
for (y = 0; y <= ysize; y += rowsperstrip)
{
register unsigned char *pp = strip;
register uint32_t n;
for (y = 0; y <= ysize; y += rowsperstrip) {
register unsigned char *pp = strip;
register uint32 n;
n = rowsperstrip;
if (n > ysize - y + 1)
n = ysize - y + 1;
do
{
for (x = 0; x <= xsize; x++)
{
uint32_t v = ss[x];
pp[0] = v;
pp[1] = v >> 8;
pp[2] = v >> 16;
pp += 3;
}
ss += xsize + 1;
} while (--n);
if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif, y, 0), strip,
stripsize) < 0)
break;
}
_TIFFfree(strip);
n = rowsperstrip;
if (n > ysize-y+1)
n = ysize-y+1;
do {
for (x = 0; x <= xsize; x++) {
uint32 v = ss[x];
pp[0] = v;
pp[1] = v >> 8;
pp[2] = v >> 16;
pp += 3;
}
ss += xsize+1;
} while (--n);
if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif,y,0),
strip, stripsize) < 0)
break;
}
_TIFFfree(strip);
}
#undef RED
#undef GREEN
#undef BLUE
#define CVT(x) (((x)*255) / 100)
#define RED CVT(28) /* 28% */
#define GREEN CVT(59) /* 59% */
#define BLUE CVT(11) /* 11% */
#define CVT(x) (((x)*255)/100)
#define RED CVT(28) /* 28% */
#define GREEN CVT(59) /* 59% */
#define BLUE CVT(11) /* 11% */
static void svGrey(TIFF *tif, uint32_t *ss, int xsize, int ysize)
static void
svGrey(TIFF* tif, uint32* ss, int xsize, int ysize)
{
register int x, y;
unsigned char *buf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(tif));
register int x, y;
unsigned char *buf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(tif));
for (y = 0; y <= ysize; y++)
{
for (x = 0; x <= xsize; x++)
{
unsigned char *cp = (unsigned char *)&ss[x];
buf[x] = (RED * cp[3] + GREEN * cp[2] + BLUE * cp[1]) >> 8;
}
if (TIFFWriteScanline(tif, buf, (uint32_t)y, 0) < 0)
break;
ss += xsize + 1;
}
_TIFFfree(buf);
for (y = 0; y <= ysize; y++) {
for (x = 0; x <= xsize; x++) {
unsigned char *cp = (unsigned char *)&ss[x];
buf[x] = (RED*cp[3] + GREEN*cp[2] + BLUE*cp[1]) >> 8;
}
if (TIFFWriteScanline(tif, buf, (uint32) y, 0) < 0)
break;
ss += xsize+1;
}
_TIFFfree(buf);
}
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(x) ((x) < 0 ? -(x) : (x))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(x) ((x)<0?-(x):(x))
static void tiffsv(char *name, int x1, int x2, int y1, int y2)
static void
tiffsv(char* name, int x1, int x2, int y1, int y2)
{
TIFF *tif;
int xsize, ysize;
int xorg, yorg;
uint32_t *scrbuf;
TIFF *tif;
int xsize, ysize;
int xorg, yorg;
uint32 *scrbuf;
xorg = MIN(x1, x2);
yorg = MIN(y1, y2);
if (xorg < 0)
xorg = 0;
if (yorg < 0)
yorg = 0;
xsize = ABS(x2 - x1);
ysize = ABS(y2 - y1);
if (xorg + xsize > xmaxscreen)
xsize = xmaxscreen - xorg;
if (yorg + ysize > ymaxscreen)
ysize = ymaxscreen - yorg;
tif = TIFFOpen(name, "w");
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, (uint32_t)(xsize + 1));
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, (uint32_t)(ysize + 1));
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL,
photometric == PHOTOMETRIC_RGB ? 3 : 1);
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, config);
TIFFSetField(tif, TIFFTAG_COMPRESSION, compression);
switch (compression)
{
case COMPRESSION_JPEG:
if (photometric == PHOTOMETRIC_RGB &&
jpegcolormode == JPEGCOLORMODE_RGB)
photometric = PHOTOMETRIC_YCBCR;
TIFFSetField(tif, TIFFTAG_JPEGQUALITY, quality);
TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, jpegcolormode);
break;
case COMPRESSION_LZW:
if (predictor != 0)
TIFFSetField(tif, TIFFTAG_PREDICTOR, predictor);
break;
}
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric);
TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_BOTLEFT);
rowsperstrip = TIFFDefaultStripSize(tif, rowsperstrip);
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
scrbuf =
(uint32_t *)_TIFFmalloc((xsize + 1) * (ysize + 1) * sizeof(uint32_t));
readdisplay(xorg, yorg, xorg + xsize, yorg + ysize, scrbuf, RD_FREEZE);
if (photometric == PHOTOMETRIC_RGB)
{
if (config == PLANARCONFIG_SEPARATE)
svRGBSeparate(tif, scrbuf, xsize, ysize);
else
svRGBContig(tif, scrbuf, xsize, ysize);
}
else
svGrey(tif, scrbuf, xsize, ysize);
(void)TIFFClose(tif);
_TIFFfree((char *)scrbuf);
xorg = MIN(x1,x2);
yorg = MIN(y1,y2);
if (xorg<0)
xorg = 0;
if (yorg<0)
yorg = 0;
xsize = ABS(x2-x1);
ysize = ABS(y2-y1);
if (xorg+xsize > xmaxscreen)
xsize = xmaxscreen-xorg;
if (yorg+ysize > ymaxscreen)
ysize = ymaxscreen-yorg;
tif = TIFFOpen(name, "w");
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, (uint32) (xsize+1));
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, (uint32) (ysize+1));
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL,
photometric == PHOTOMETRIC_RGB ? 3 : 1);
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, config);
TIFFSetField(tif, TIFFTAG_COMPRESSION, compression);
switch (compression) {
case COMPRESSION_JPEG:
if (photometric == PHOTOMETRIC_RGB && jpegcolormode == JPEGCOLORMODE_RGB)
photometric = PHOTOMETRIC_YCBCR;
TIFFSetField(tif, TIFFTAG_JPEGQUALITY, quality);
TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, jpegcolormode);
break;
case COMPRESSION_LZW:
if (predictor != 0)
TIFFSetField(tif, TIFFTAG_PREDICTOR, predictor);
break;
}
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric);
TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_BOTLEFT);
rowsperstrip = TIFFDefaultStripSize(tif, rowsperstrip);
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
scrbuf = (uint32 *)_TIFFmalloc((xsize+1)*(ysize+1)*sizeof (uint32));
readdisplay(xorg, yorg, xorg+xsize, yorg+ysize, scrbuf, RD_FREEZE);
if (photometric == PHOTOMETRIC_RGB) {
if (config == PLANARCONFIG_SEPARATE)
svRGBSeparate(tif, scrbuf, xsize, ysize);
else
svRGBContig(tif, scrbuf, xsize, ysize);
} else
svGrey(tif, scrbuf, xsize, ysize);
(void) TIFFClose(tif);
_TIFFfree((char *)scrbuf);
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,17 +1,17 @@
float ycbcrCoeffs[3] = {.299, .587, .114};
float ycbcrCoeffs[3] = { .299, .587, .114 };
/* default coding range is CCIR Rec 601-1 with no headroom/footroom */
unsigned long refBlackWhite[6] = {0, 255, 128, 255, 128, 255};
unsigned long refBlackWhite[6] = { 0, 255, 128, 255, 128, 255 };
#define LumaRed ycbcrCoeffs[0]
#define LumaGreen ycbcrCoeffs[1]
#define LumaBlue ycbcrCoeffs[2]
#define LumaRed ycbcrCoeffs[0]
#define LumaGreen ycbcrCoeffs[1]
#define LumaBlue ycbcrCoeffs[2]
long eRtotal = 0;
long eGtotal = 0;
long eBtotal = 0;
long preveRtotal = 0;
long preveGtotal = 0;
long preveBtotal = 0;
long eRtotal = 0;
long eGtotal = 0;
long eBtotal = 0;
long preveRtotal = 0;
long preveGtotal = 0;
long preveBtotal = 0;
unsigned long AbseRtotal = 0;
unsigned long AbseGtotal = 0;
unsigned long AbseBtotal = 0;
@ -20,90 +20,101 @@ unsigned long preveCodes = 0;
unsigned long eBits = 0;
unsigned long preveBits = 0;
static void setupLumaTables();
static void setupLumaTables();
static int abs(int v) { return (v < 0 ? -v : v); }
static double pct(int v, double range) { return (v * 100. / range); }
static double pct(int v,double range) { return (v*100. / range); }
static void check(int R, int G, int B);
float D1, D2;
float D3, D4;
float D5, D6;
float D1, D2;
float D3, D4;
float D5, D6;
int main(int argc, char **argv)
int
main(int argc, char** argv)
{
int R, G, B;
if (argc > 1)
{
refBlackWhite[0] = 16;
refBlackWhite[1] = 235;
refBlackWhite[2] = 128;
refBlackWhite[3] = 240;
refBlackWhite[4] = 128;
refBlackWhite[5] = 240;
if (argc > 1) {
refBlackWhite[0] = 16;
refBlackWhite[1] = 235;
refBlackWhite[2] = 128;
refBlackWhite[3] = 240;
refBlackWhite[4] = 128;
refBlackWhite[5] = 240;
}
D3 = 2 - 2 * LumaRed;
D4 = 2 - 2 * LumaBlue;
D3 = 2 - 2*LumaRed;
D4 = 2 - 2*LumaBlue;
D1 = 1. / D3;
D2 = 1. / D4;
D5 = D3 * LumaRed / LumaGreen;
D6 = D4 * LumaBlue / LumaGreen;
D5 = D3*LumaRed / LumaGreen;
D6 = D4*LumaBlue / LumaGreen;
setupLumaTables();
for (R = 0; R < 256; R++)
{
for (G = 0; G < 256; G++)
for (B = 0; B < 256; B++)
check(R, G, B);
printf("[%3u] c %u/%u b %u/%u (R %u/%d/%u G %u/%d/%u B %u/%d/%u)\n", R,
eCodes - preveCodes, eCodes, eBits - preveBits, eBits,
abs(AbseRtotal - preveRtotal), eRtotal, AbseRtotal,
abs(AbseGtotal - preveGtotal), eGtotal, AbseGtotal,
abs(AbseBtotal - preveBtotal), eBtotal, AbseBtotal);
preveRtotal = AbseRtotal;
preveGtotal = AbseGtotal;
preveBtotal = AbseBtotal;
preveCodes = eCodes;
preveBits = eBits;
for (R = 0; R < 256; R++) {
for (G = 0; G < 256; G++)
for (B = 0; B < 256; B++)
check(R, G, B);
printf("[%3u] c %u/%u b %u/%u (R %u/%d/%u G %u/%d/%u B %u/%d/%u)\n"
, R
, eCodes - preveCodes, eCodes
, eBits - preveBits, eBits
, abs(AbseRtotal - preveRtotal), eRtotal , AbseRtotal
, abs(AbseGtotal - preveGtotal), eGtotal , AbseGtotal
, abs(AbseBtotal - preveBtotal), eBtotal , AbseBtotal
);
preveRtotal = AbseRtotal;
preveGtotal = AbseGtotal;
preveBtotal = AbseBtotal;
preveCodes = eCodes;
preveBits = eBits;
}
printf("%u total codes\n", 256 * 256 * 256);
printf("total error: %u codes %u bits (R %d/%u G %d/%u B %d/%u)\n", eCodes,
eBits, eRtotal, AbseRtotal, eGtotal, AbseGtotal, eBtotal,
AbseBtotal);
printf("%u total codes\n", 256*256*256);
printf("total error: %u codes %u bits (R %d/%u G %d/%u B %d/%u)\n"
, eCodes
, eBits
, eRtotal , AbseRtotal
, eGtotal , AbseGtotal
, eBtotal , AbseBtotal
);
return (0);
}
float *lumaRed;
float *lumaGreen;
float *lumaBlue;
float *lumaRed;
float *lumaGreen;
float *lumaBlue;
static float *setupLuma(float c)
static float*
setupLuma(float c)
{
float *v = (float *)_TIFFmalloc(256 * sizeof(float));
float *v = (float *)_TIFFmalloc(256 * sizeof (float));
int i;
for (i = 0; i < 256; i++)
v[i] = c * i;
v[i] = c * i;
return (v);
}
static void setupLumaTables(void)
static void
setupLumaTables(void)
{
lumaRed = setupLuma(LumaRed);
lumaGreen = setupLuma(LumaGreen);
lumaBlue = setupLuma(LumaBlue);
}
static unsigned V2Code(float f, unsigned long RB, unsigned long RW, int CR)
static unsigned
V2Code(float f, unsigned long RB, unsigned long RW, int CR)
{
unsigned int c = (unsigned int)((((f) * (RW - RB) / CR) + RB) + .5);
unsigned int c = (unsigned int)((((f)*(RW-RB)/CR)+RB)+.5);
return (c > 255 ? 255 : c);
}
#define Code2V(c, RB, RW, CR) ((((c) - (int)RB) * (float)CR) / (float)(RW - RB))
#define Code2V(c, RB, RW, CR) ((((c)-(int)RB)*(float)CR)/(float)(RW-RB))
#define CLAMP(f, min, max) \
(int)((f) + .5 < (min) ? (min) : (f) + .5 > (max) ? (max) : (f) + .5)
#define CLAMP(f,min,max) \
(int)((f)+.5 < (min) ? (min) : (f)+.5 > (max) ? (max) : (f)+.5)
static void check(int R, int G, int B)
static
void
check(int R, int G, int B)
{
float Y, Cb, Cr;
int iY, iCb, iCr;
@ -112,29 +123,31 @@ static void check(int R, int G, int B)
int eR, eG, eB;
Y = lumaRed[R] + lumaGreen[G] + lumaBlue[B];
Cb = (B - Y) * D2;
Cr = (R - Y) * D1;
Cb = (B - Y)*D2;
Cr = (R - Y)*D1;
iY = V2Code(Y, refBlackWhite[0], refBlackWhite[1], 255);
iCb = V2Code(Cb, refBlackWhite[2], refBlackWhite[3], 127);
iCr = V2Code(Cr, refBlackWhite[4], refBlackWhite[5], 127);
rCb = Code2V(iCb, refBlackWhite[2], refBlackWhite[3], 127);
rCr = Code2V(iCr, refBlackWhite[4], refBlackWhite[5], 127);
rY = Code2V(iY, refBlackWhite[0], refBlackWhite[1], 255);
rR = rY + rCr * D3;
rB = rY + rCb * D4;
rG = rY - rCb * D6 - rCr * D5;
eR = R - CLAMP(rR, 0, 255);
eG = G - CLAMP(rG, 0, 255);
eB = B - CLAMP(rB, 0, 255);
if (abs(eR) > 1 || abs(eG) > 1 || abs(eB) > 1)
{
printf("R %u G %u B %u", R, G, B);
printf(" Y %g Cb %g Cr %g", Y, Cb, Cr);
printf(" iY %u iCb %u iCr %u", iY, iCb, iCr);
printf("\n -> Y %g Cb %g Cr %g", rY, rCb, rCr);
printf(" R %g (%u) G %g (%u) B %g (%u) E=[%d %d %d])\n", rR,
CLAMP(rR, 0, 255), rG, CLAMP(rG, 0, 255), rB, CLAMP(rB, 0, 255),
eR, eG, eB);
rR = rY + rCr*D3;
rB = rY + rCb*D4;
rG = rY - rCb*D6 - rCr*D5;
eR = R - CLAMP(rR,0,255);
eG = G - CLAMP(rG,0,255);
eB = B - CLAMP(rB,0,255);
if (abs(eR) > 1 || abs(eG) > 1 || abs(eB) > 1) {
printf("R %u G %u B %u", R, G, B);
printf(" Y %g Cb %g Cr %g", Y, Cb, Cr);
printf(" iY %u iCb %u iCr %u", iY, iCb, iCr);
printf("\n -> Y %g Cb %g Cr %g", rY, rCb, rCr);
printf(" R %g (%u) G %g (%u) B %g (%u) E=[%d %d %d])\n"
, rR, CLAMP(rR,0,255)
, rG, CLAMP(rG,0,255)
, rB, CLAMP(rB,0,255)
, eR, eG, eB
);
}
eRtotal += eR;
eGtotal += eG;
@ -143,6 +156,13 @@ static void check(int R, int G, int B)
AbseGtotal += abs(eG);
AbseBtotal += abs(eB);
if (eR | eG | eB)
eCodes++;
eCodes++;
eBits += abs(eR) + abs(eG) + abs(eB);
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,27 +1,8 @@
#!/bin/sh
set -x
case `uname` in
Darwin*)
glibtoolize --force --copy
;;
*)
libtoolize --force --copy
;;
esac
libtoolize --force --copy
aclocal -I ./m4
autoheader
automake --foreign --add-missing --copy
autoconf
# Get latest config.guess and config.sub from upstream master since
# these are often out of date.
for file in config.guess config.sub
do
echo "$0: getting $file..."
wget -q --timeout=5 -O config/$file.tmp \
"https://git.savannah.gnu.org/cgit/config.git/plain/${file}" \
&& mv -f config/$file.tmp config/$file \
&& chmod a+x config/$file
retval=$?
rm -f config/$file.tmp
test $retval -eq 0 || exit $retval
done

View file

@ -1,7 +1,6 @@
# C++ library option
# CMake build for libtiff
#
# Copyright © 2015 Open Microscopy Environment / University of Dundee
# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
# Written by Roger Leigh <rleigh@codelibre.net>
#
# Permission to use, copy, modify, distribute, and sell this software and
@ -23,10 +22,4 @@
# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
# OF THIS SOFTWARE.
# C++ support
option(cxx "Enable C++ stream API building (requires C++ compiler)" ON)
set(CXX_SUPPORT FALSE)
if (cxx)
enable_language(CXX)
set(CXX_SUPPORT TRUE)
endif()
extra_dist(README)

View file

@ -1,32 +1,32 @@
# Checks for LERC codec support
#
# Copyright © 2021 Antonio Valentino <antonio.valentino@tiscali.it>
# Written by Antonio Valentino <antonio.valentino@tiscali.it>
# Tag Image File Format (TIFF) Software
#
# Permission to use, copy, modify, distribute, and sell this software and
# Copyright (C) 2007, Andrey Kiselev <dron@ak4719.spb.edu>
#
# 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.
#
#
# 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
# 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.
# Process this file with automake to produce Makefile.in.
EXTRA_DIST = \
CMakeLists.txt \
README
SUBDIRS =
# libLerc
set(LERC_SUPPORT FALSE)
find_package(LERC)
option(lerc "use libLerc (required for LERC compression)" ${LERC_FOUND})
if (lerc AND LERC_FOUND AND ZIP_SUPPORT)
set(LERC_SUPPORT TRUE)
endif()

View file

@ -0,0 +1,3 @@
This directory contains scripts and tools needed to build libtiff library
and its utilities in various environments.

Some files were not shown because too many files have changed in this diff Show more