Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
282 changes: 194 additions & 88 deletions CMakeLists.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/FreeImage/J2KHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "FreeImage.h"
#include "Utilities.h"
#include "../LibOpenJPEG/openjpeg.h"
#include <openjpeg.h>
#include "J2KHelper.h"

// --------------------------------------------------------------------------
Expand Down
37 changes: 32 additions & 5 deletions Source/FreeImage/PluginEXR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// EXR Loader and writer
//
// Design and implementation by
// - Hervé Drolon (drolon@infonie.fr)
// - Herv� Drolon (drolon@infonie.fr)
// - Mihail Naydenov (mnaydenov@users.sourceforge.net)
//
// This file is part of FreeImage 3
Expand Down Expand Up @@ -30,6 +30,22 @@
#pragma warning (disable : 4800) // ImfVersion.h - 'const int' : forcing value to bool 'true' or 'false' (performance warning)
#endif

#ifdef FREEIMAGE_SYSTEM_OPENEXR
// The bundled Source/OpenEXR/Half type isn't binary-compatible with a system
// OpenEXR build's own Imath::half (which its Imf* API surface is built
// against), so this file - unlike PluginTIFF.cpp's standalone LogLuv use of
// half.h - must switch to the matching system Imath header too.
#include <OpenEXR/ImfIO.h>
#include <OpenEXR/Iex.h>
#include <OpenEXR/ImfOutputFile.h>
#include <OpenEXR/ImfInputFile.h>
#include <OpenEXR/ImfRgbaFile.h>
#include <OpenEXR/ImfChannelList.h>
#include <OpenEXR/ImfRgba.h>
#include <OpenEXR/ImfArray.h>
#include <OpenEXR/ImfPreviewImage.h>
#include <Imath/half.h>
#else
#include "../OpenEXR/IlmImf/ImfIO.h"
#include "../OpenEXR/Iex/Iex.h"
#include "../OpenEXR/IlmImf/ImfOutputFile.h"
Expand All @@ -40,6 +56,7 @@
#include "../OpenEXR/IlmImf/ImfArray.h"
#include "../OpenEXR/IlmImf/ImfPreviewImage.h"
#include "../OpenEXR/Half/half.h"
#endif


// ==========================================================
Expand All @@ -48,6 +65,16 @@

static int s_format_id;

// IStream/OStream's tellg/seekg/tellp/seekp use Imath::Int64 in the bundled
// (OpenEXR 2.x-era) headers, but that type was removed from Imath 3.x in
// favor of plain uint64_t, which is what a system OpenEXR 3.x's ImfIO.h
// virtuals now use.
#ifdef FREEIMAGE_SYSTEM_OPENEXR
typedef uint64_t exr_offset_t;
#else
typedef Imath::Int64 exr_offset_t;
#endif

// ----------------------------------------------------------

/**
Expand All @@ -68,11 +95,11 @@ class C_IStream : public Imf::IStream {
return ((unsigned)n != _io->read_proc(c, 1, n, _handle));
}

virtual Imath::Int64 tellg() {
virtual exr_offset_t tellg() {
return _io->tell_proc(_handle);
}

virtual void seekg(Imath::Int64 pos) {
virtual void seekg(exr_offset_t pos) {
_io->seek_proc(_handle, (unsigned)pos, SEEK_SET);
}

Expand Down Expand Up @@ -102,11 +129,11 @@ class C_OStream : public Imf::OStream {
}
}

virtual Imath::Int64 tellp() {
virtual exr_offset_t tellp() {
return _io->tell_proc(_handle);
}

virtual void seekp(Imath::Int64 pos) {
virtual void seekp(exr_offset_t pos) {
_io->seek_proc(_handle, (unsigned)pos, SEEK_SET);
}
};
Expand Down
21 changes: 19 additions & 2 deletions Source/FreeImage/PluginG3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// G3 Fax Loader
//
// Design and implementation by
// - Hervé Drolon (drolon@infonie.fr)
// - Herv� Drolon (drolon@infonie.fr)
// - Petr Pytelka (pyta@lightcomp.com)
//
// This file is part of FreeImage 3
Expand All @@ -20,7 +20,11 @@
// Use at your own risk!
// ==========================================================

#ifdef FREEIMAGE_SYSTEM_LIBTIFF
#include <tiffio.h>
#else
#include "../LibTIFF4/tiffiop.h"
#endif

#include "FreeImage.h"
#include "Utilities.h"
Expand Down Expand Up @@ -99,7 +103,11 @@ G3ReadFile(FreeImageIO *io, fi_handle handle, uint8_t *tif_rawdata, tmsize_t tif
// Internal functions
// ==========================================================

static int
#ifndef FREEIMAGE_SYSTEM_LIBTIFF
// Manipulates libtiff's private TIFF struct fields directly (tif_rawdata,
// tif_decoderow, ...), which a system libtiff's public tiffio.h doesn't
// expose - only compiled in the bundled-libtiff build (see Load() below).
static int
copyFaxFile(FreeImageIO *io, fi_handle handle, TIFF* tifin, uint32_t xsize, int stretch, FIMEMORY *memory) {
BYTE *rowbuf = NULL;
BYTE *refbuf = NULL;
Expand Down Expand Up @@ -192,6 +200,7 @@ copyFaxFile(FreeImageIO *io, fi_handle handle, TIFF* tifin, uint32_t xsize, int

return (row);
}
#endif // !FREEIMAGE_SYSTEM_LIBTIFF


// ==========================================================
Expand Down Expand Up @@ -232,6 +241,13 @@ SupportsExportDepth(int depth) {

static FIBITMAP * DLL_CALLCONV
Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
#ifdef FREEIMAGE_SYSTEM_LIBTIFF
// This decoder manipulates libtiff's private TIFF struct fields directly
// (tif_rawdata, tif_decoderow, ...), which aren't reachable through a
// system libtiff's public tiffio.h - report cleanly unsupported instead.
FreeImage_OutputMessageProc(s_format_id, "G3 fax loading is unavailable in this build (built against system libtiff)");
return NULL;
#else
TIFF *faxTIFF = NULL;
FIBITMAP *dib = NULL;
FIMEMORY *memory = NULL;
Expand Down Expand Up @@ -405,6 +421,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {

return dib;

#endif // FREEIMAGE_SYSTEM_LIBTIFF
}

// ==========================================================
Expand Down
2 changes: 1 addition & 1 deletion Source/FreeImage/PluginJ2K.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "FreeImage.h"
#include "Utilities.h"
#include "../LibOpenJPEG/openjpeg.h"
#include <openjpeg.h>
#include "J2KHelper.h"

// ==========================================================
Expand Down
2 changes: 1 addition & 1 deletion Source/FreeImage/PluginJP2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "FreeImage.h"
#include "Utilities.h"
#include "../LibOpenJPEG/openjpeg.h"
#include <openjpeg.h>
#include "J2KHelper.h"

// ==========================================================
Expand Down
12 changes: 9 additions & 3 deletions Source/FreeImage/PluginJPEG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// - Jan L. Nauta (jln@magentammt.com)
// - Markus Loibl (markus.loibl@epost.de)
// - Karl-Heinz Bussian (khbussian@moss.de)
// - Hervé Drolon (drolon@infonie.fr)
// - Herv� Drolon (drolon@infonie.fr)
// - Jascha Wetzel (jascha@mainia.de)
// - Mihail Naydenov (mnaydenov@users.sourceforge.net)
//
Expand Down Expand Up @@ -35,9 +35,15 @@ extern "C" {
#undef FAR
#include <setjmp.h>

#ifdef FREEIMAGE_SYSTEM_LIBJPEG
#include <stdio.h>
#include <jpeglib.h>
#include <jerror.h>
#else
#include "../LibJPEG/jinclude.h"
#include "../LibJPEG/jpeglib.h"
#include "../LibJPEG/jerror.h"
#endif
}

#include "FreeImage.h"
Expand Down Expand Up @@ -503,7 +509,7 @@ marker_is_icc(jpeg_saved_marker_ptr marker) {
return FALSE. You might want to issue an error message instead.
*/
static BOOL
jpeg_read_icc_profile(j_decompress_ptr cinfo, JOCTET **icc_data_ptr, unsigned *icc_data_len) {
fi_jpeg_read_icc_profile(j_decompress_ptr cinfo, JOCTET **icc_data_ptr, unsigned *icc_data_len) {
jpeg_saved_marker_ptr marker;
int num_markers = 0;
int seq_no;
Expand Down Expand Up @@ -745,7 +751,7 @@ read_markers(j_decompress_ptr cinfo, FIBITMAP *dib) {
BYTE *icc_profile = NULL;
unsigned icc_length = 0;

if( jpeg_read_icc_profile(cinfo, &icc_profile, &icc_length) ) {
if( fi_jpeg_read_icc_profile(cinfo, &icc_profile, &icc_length) ) {
// copy ICC profile data
FreeImage_CreateICCProfile(dib, icc_profile, icc_length);
// clean up
Expand Down
2 changes: 1 addition & 1 deletion Source/FreeImage/PluginJXR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "Utilities.h"
#include "../Metadata/FreeImageTag.h"

#include "../LibJXR/jxrgluelib/JXRGlue.h"
#include <JXRGlue.h>

// ==========================================================
// Plugin Interface
Expand Down
4 changes: 2 additions & 2 deletions Source/FreeImage/PluginPNG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@

// ----------------------------------------------------------

#include "../ZLib/zlib.h"
#include "../LibPNG/png.h"
#include <zlib.h>
#include <png.h>

// ----------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions Source/FreeImage/PluginRAW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// RAW camera image loader
//
// Design and implementation by
// - Hervé Drolon (drolon@infonie.fr)
// - Herv� Drolon (drolon@infonie.fr)
//
// This file is part of FreeImage 3
//
Expand All @@ -21,7 +21,7 @@

#if INCLUDE_LIB_RAW

#include "../LibRawLite/libraw/libraw.h"
#include <libraw/libraw.h>

#include "FreeImage.h"
#include "Utilities.h"
Expand Down
2 changes: 1 addition & 1 deletion Source/FreeImage/PluginTIFF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

#include "FreeImage.h"
#include "Utilities.h"
#include "../LibTIFF4/tiffiop.h"
#include <tiffio.h>
#include "../Metadata/FreeImageTag.h"
#include "../OpenEXR/Half/half.h"

Expand Down
6 changes: 3 additions & 3 deletions Source/FreeImage/PluginWebP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

#include "../Metadata/FreeImageTag.h"

#include "../LibWebP/src/webp/decode.h"
#include "../LibWebP/src/webp/encode.h"
#include "../LibWebP/src/webp/mux.h"
#include <webp/decode.h>
#include <webp/encode.h>
#include <webp/mux.h>

// ==========================================================
// Plugin Interface
Expand Down
13 changes: 12 additions & 1 deletion Source/FreeImage/ZLibInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@
// Use at your own risk!
// ==========================================================

#ifdef FREEIMAGE_SYSTEM_ZLIB
#include <zlib.h>
#else
#include "../ZLib/zlib.h"
#endif
#include "FreeImage.h"
#include "Utilities.h"
#ifndef FREEIMAGE_SYSTEM_ZLIB
#include "../ZLib/zutil.h" /* must be the last header because of error C3163 in VS2008 (_vsnprintf defined in stdio.h) */
#endif

/**
Compresses a source buffer into a target buffer, using the ZLib library.
Expand Down Expand Up @@ -115,7 +121,12 @@ FreeImage_ZLibGZip(BYTE *target, DWORD target_size, BYTE *source, DWORD source_s
return 0;
case Z_OK: {
// patch header, setup crc and length (stolen from mod_trace_output)
BYTE *p = target + 8; *p++ = 2; *p = OS_CODE; // xflags, os_code
#ifdef FREEIMAGE_SYSTEM_ZLIB
const BYTE gzip_os_code = 0x03; // unix - zutil.h's OS_CODE isn't part of zlib's public API
#else
const BYTE gzip_os_code = OS_CODE;
#endif
BYTE *p = target + 8; *p++ = 2; *p = gzip_os_code; // xflags, os_code
crc = crc32(crc, source, source_size);
memcpy(target + 4 + dest_len, &crc, 4);
memcpy(target + 8 + dest_len, &source_size, 4);
Expand Down
21 changes: 21 additions & 0 deletions Source/FreeImageToolkit/JPEGTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,19 @@ extern "C" {
#undef FAR
#include <setjmp.h>

#ifdef FREEIMAGE_SYSTEM_LIBJPEG
#include <stdio.h>
#include <jpeglib.h>
#include <jerror.h>
// transupp.h isn't installed by system libjpeg/libjpeg-turbo packages; the
// jtransform_*/jpeg_transform_info API it declares is only used in the
// bundled-libjpeg branch below.
#else
#include "../LibJPEG/jinclude.h"
#include "../LibJPEG/jpeglib.h"
#include "../LibJPEG/jerror.h"
#include "../LibJPEG/transupp.h"
#endif
}

#include "FreeImage.h"
Expand Down Expand Up @@ -148,6 +157,17 @@ getCropString(char* crop, int* left, int* top, int* right, int* bottom, int widt
return TRUE;
}

#ifdef FREEIMAGE_SYSTEM_LIBJPEG
// Lossless JPEG transforms need transupp.h's jtransform_* API, which isn't
// installed by system libjpeg/libjpeg-turbo packages (it ships only as
// jpegtran example source, not a public dev header) - report cleanly
// unsupported rather than failing the build.
static BOOL
JPEGTransformFromHandle(FreeImageIO* src_io, fi_handle src_handle, FreeImageIO* dst_io, fi_handle dst_handle, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect) {
FreeImage_OutputMessageProc(FIF_JPEG, "Lossless JPEG transforms are unavailable in this build (built against system libjpeg)");
return FALSE;
}
#else
static BOOL
JPEGTransformFromHandle(FreeImageIO* src_io, fi_handle src_handle, FreeImageIO* dst_io, fi_handle dst_handle, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect) {
const BOOL onlyReturnCropRect = (dst_io == NULL) || (dst_handle == NULL);
Expand Down Expand Up @@ -361,6 +381,7 @@ JPEGTransformFromHandle(FreeImageIO* src_io, fi_handle src_handle, FreeImageIO*

return TRUE;
}
#endif // FREEIMAGE_SYSTEM_LIBJPEG

// ----------------------------------------------------------
// FreeImage interface
Expand Down
Loading
Loading