| 1 | https://src.fedoraproject.org/cgit/rpms/freeimage.git/tree/FreeImage_unbundle.patch
|
| 2 |
|
| 3 | diff -rupN FreeImage/genfipsrclist.sh FreeImage-new/genfipsrclist.sh
|
| 4 | |
| 5 | |
| 6 | @@ -1,6 +1,6 @@
|
| 7 | #!/bin/sh
|
| 8 |
|
| 9 | -DIRLIST=". Source Source/Metadata Source/FreeImageToolkit Source/LibJPEG Source/LibPNG Source/LibTIFF4 Source/ZLib Source/LibOpenJPEG Source/OpenEXR Source/OpenEXR/Half Source/OpenEXR/Iex Source/OpenEXR/IlmImf Source/OpenEXR/IlmThread Source/OpenEXR/Imath Source/OpenEXR/IexMath Source/LibRawLite Source/LibRawLite/dcraw Source/LibRawLite/internal Source/LibRawLite/libraw Source/LibRawLite/src Source/LibWebP Source/LibJXR Source/LibJXR/common/include Source/LibJXR/image/sys Source/LibJXR/jxrgluelib Wrapper/FreeImagePlus"
|
| 10 | +DIRLIST="Wrapper/FreeImagePlus"
|
| 11 |
|
| 12 |
|
| 13 | echo "VER_MAJOR = 3" > fipMakefile.srcs
|
| 14 | @@ -19,5 +19,6 @@ echo -n "INCLUDE =" >> fipMakefile.srcs
|
| 15 | for DIR in $DIRLIST; do
|
| 16 | echo -n " -I$DIR" >> fipMakefile.srcs
|
| 17 | done
|
| 18 | +echo -n " -IDist" >> fipMakefile.srcs
|
| 19 | echo >> fipMakefile.srcs
|
| 20 |
|
| 21 | diff -rupN FreeImage/gensrclist.sh FreeImage-new/gensrclist.sh
|
| 22 | |
| 23 | |
| 24 | @@ -1,6 +1,6 @@
|
| 25 | #!/bin/sh
|
| 26 |
|
| 27 | -DIRLIST=". Source Source/Metadata Source/FreeImageToolkit Source/LibJPEG Source/LibPNG Source/LibTIFF4 Source/ZLib Source/LibOpenJPEG Source/OpenEXR Source/OpenEXR/Half Source/OpenEXR/Iex Source/OpenEXR/IlmImf Source/OpenEXR/IlmThread Source/OpenEXR/Imath Source/OpenEXR/IexMath Source/LibRawLite Source/LibRawLite/dcraw Source/LibRawLite/internal Source/LibRawLite/libraw Source/LibRawLite/src Source/LibWebP Source/LibJXR Source/LibJXR/common/include Source/LibJXR/image/sys Source/LibJXR/jxrgluelib"
|
| 28 | +DIRLIST=". Source Source/Metadata Source/FreeImageToolkit"
|
| 29 |
|
| 30 | echo "VER_MAJOR = 3" > Makefile.srcs
|
| 31 | echo "VER_MINOR = 18.0" >> Makefile.srcs
|
| 32 | diff -rupN FreeImage/Makefile.fip FreeImage-new/Makefile.fip
|
| 33 | |
| 34 | |
| 35 | @@ -17,20 +17,22 @@ MODULES = $(SRCS:.c=.o)
|
| 36 | MODULES := $(MODULES:.cpp=.o)
|
| 37 | CFLAGS ?= -O3 -fPIC -fexceptions -fvisibility=hidden
|
| 38 | # OpenJPEG
|
| 39 | -CFLAGS += -DOPJ_STATIC
|
| 40 | +override CFLAGS += -DOPJ_STATIC
|
| 41 | # LibRaw
|
| 42 | -CFLAGS += -DNO_LCMS
|
| 43 | +override CFLAGS += -DNO_LCMS
|
| 44 | # LibJXR
|
| 45 | -CFLAGS += -DDISABLE_PERF_MEASUREMENT -D__ANSI__
|
| 46 | -CFLAGS += $(INCLUDE)
|
| 47 | +override CFLAGS += -DDISABLE_PERF_MEASUREMENT -D__ANSI__
|
| 48 | +override CFLAGS += $(INCLUDE)
|
| 49 | CXXFLAGS ?= -O3 -fPIC -fexceptions -fvisibility=hidden -Wno-ctor-dtor-privacy
|
| 50 | # LibJXR
|
| 51 | -CXXFLAGS += -D__ANSI__
|
| 52 | -CXXFLAGS += $(INCLUDE)
|
| 53 | +override CXXFLAGS += -D__ANSI__
|
| 54 | +override CXXFLAGS += $(INCLUDE)
|
| 55 | +LDFLAGS ?=
|
| 56 | +override LDFLAGS += -LDist -lfreeimage-$(VER_MAJOR).$(VER_MINOR)
|
| 57 |
|
| 58 | ifeq ($(shell sh -c 'uname -m 2>/dev/null || echo not'),x86_64)
|
| 59 | - CFLAGS += -fPIC
|
| 60 | - CXXFLAGS += -fPIC
|
| 61 | + override CFLAGS += -fPIC
|
| 62 | + override CXXFLAGS += -fPIC
|
| 63 | endif
|
| 64 |
|
| 65 | TARGET = freeimageplus
|
| 66 | @@ -68,7 +70,7 @@ $(STATICLIB): $(MODULES)
|
| 67 | $(AR) r $@ $(MODULES)
|
| 68 |
|
| 69 | $(SHAREDLIB): $(MODULES)
|
| 70 | - $(CC) -s -shared -Wl,-soname,$(VERLIBNAME) $(LDFLAGS) -o $@ $(MODULES) $(LIBRARIES)
|
| 71 | + $(CC) -shared -Wl,-soname,$(VERLIBNAME) $(LDFLAGS) -o $@ $(MODULES) $(LIBRARIES)
|
| 72 |
|
| 73 | install:
|
| 74 | install -d $(INCDIR) $(INSTALLDIR)
|
| 75 | diff -rupN FreeImage/Makefile.gnu FreeImage-new/Makefile.gnu
|
| 76 | |
| 77 | |
| 78 | @@ -16,21 +16,11 @@ LIBRARIES = -lstdc++
|
| 79 | MODULES = $(SRCS:.c=.o)
|
| 80 | MODULES := $(MODULES:.cpp=.o)
|
| 81 | CFLAGS ?= -O3 -fPIC -fexceptions -fvisibility=hidden
|
| 82 | -# OpenJPEG
|
| 83 | -CFLAGS += -DOPJ_STATIC
|
| 84 | -# LibRaw
|
| 85 | -CFLAGS += -DNO_LCMS
|
| 86 | -# LibJXR
|
| 87 | -CFLAGS += -DDISABLE_PERF_MEASUREMENT -D__ANSI__
|
| 88 | -CFLAGS += $(INCLUDE)
|
| 89 | -CXXFLAGS ?= -O3 -fPIC -fexceptions -fvisibility=hidden -Wno-ctor-dtor-privacy
|
| 90 | -# LibJXR
|
| 91 | -CXXFLAGS += -D__ANSI__
|
| 92 | -CXXFLAGS += $(INCLUDE)
|
| 93 | +override CFLAGS += $(INCLUDE) -D__ANSI__ -I/usr/include/jxrlib $(shell pkg-config --cflags OpenEXR libopenjp2 libraw libpng libtiff-4 libwebp libwebpmux zlib)
|
| 94 | +override LDFLAGS += -ljpeg -ljpegxr -ljxrglue $(shell pkg-config --libs OpenEXR libopenjp2 libraw libpng libtiff-4 libwebp libwebpmux zlib)
|
| 95 |
|
| 96 | ifeq ($(shell sh -c 'uname -m 2>/dev/null || echo not'),x86_64)
|
| 97 | - CFLAGS += -fPIC
|
| 98 | - CXXFLAGS += -fPIC
|
| 99 | + override CFLAGS += -fPIC
|
| 100 | endif
|
| 101 |
|
| 102 | TARGET = freeimage
|
| 103 | @@ -61,13 +51,13 @@ FreeImage: $(STATICLIB) $(SHAREDLIB)
|
| 104 | $(CC) $(CFLAGS) -c $< -o $@
|
| 105 |
|
| 106 | .cpp.o:
|
| 107 | - $(CXX) $(CXXFLAGS) -c $< -o $@
|
| 108 | + $(CXX) $(CFLAGS) -c $< -o $@
|
| 109 |
|
| 110 | $(STATICLIB): $(MODULES)
|
| 111 | $(AR) r $@ $(MODULES)
|
| 112 |
|
| 113 | $(SHAREDLIB): $(MODULES)
|
| 114 | - $(CC) -s -shared -Wl,-soname,$(VERLIBNAME) $(LDFLAGS) -o $@ $(MODULES) $(LIBRARIES)
|
| 115 | + $(CC) -shared -Wl,-soname,$(VERLIBNAME) $(LDFLAGS) -o $@ $(MODULES) $(LIBRARIES)
|
| 116 |
|
| 117 | install:
|
| 118 | install -d $(INCDIR) $(INSTALLDIR)
|
| 119 | diff -rupN FreeImage/Source/FreeImage/J2KHelper.cpp FreeImage-new/Source/FreeImage/J2KHelper.cpp
|
| 120 | |
| 121 | |
| 122 | @@ -21,7 +21,7 @@
|
| 123 |
|
| 124 | #include "FreeImage.h"
|
| 125 | #include "Utilities.h"
|
| 126 | -#include "../LibOpenJPEG/openjpeg.h"
|
| 127 | +#include <openjpeg.h>
|
| 128 | #include "J2KHelper.h"
|
| 129 |
|
| 130 | // --------------------------------------------------------------------------
|
| 131 | diff -rupN FreeImage/Source/FreeImage/Plugin.cpp FreeImage-new/Source/FreeImage/Plugin.cpp
|
| 132 | |
| 133 | |
| 134 | @@ -263,7 +263,12 @@ FreeImage_Initialise(BOOL load_local_plu
|
| 135 | s_plugins->AddNode(InitDDS);
|
| 136 | s_plugins->AddNode(InitGIF);
|
| 137 | s_plugins->AddNode(InitHDR);
|
| 138 | - s_plugins->AddNode(InitG3);
|
| 139 | +/* The G3 fax format plugin is deliberately disabled in the Fedora build of
|
| 140 | + FreeImage as it requires that FreeImage uses a private copy of libtiff
|
| 141 | + which is a no no because of security reasons. */
|
| 142 | +#if 0
|
| 143 | + s_plugins->AddNode(InitG3);
|
| 144 | +#endif
|
| 145 | s_plugins->AddNode(InitSGI);
|
| 146 | s_plugins->AddNode(InitEXR);
|
| 147 | s_plugins->AddNode(InitJ2K);
|
| 148 | diff -rupN FreeImage/Source/FreeImage/PluginEXR.cpp FreeImage-new/Source/FreeImage/PluginEXR.cpp
|
| 149 | |
| 150 | |
| 151 | @@ -28,16 +28,16 @@
|
| 152 | #pragma warning (disable : 4800) // ImfVersion.h - 'const int' : forcing value to bool 'true' or 'false' (performance warning)
|
| 153 | #endif
|
| 154 |
|
| 155 | -#include "../OpenEXR/IlmImf/ImfIO.h"
|
| 156 | -#include "../OpenEXR/Iex/Iex.h"
|
| 157 | -#include "../OpenEXR/IlmImf/ImfOutputFile.h"
|
| 158 | -#include "../OpenEXR/IlmImf/ImfInputFile.h"
|
| 159 | -#include "../OpenEXR/IlmImf/ImfRgbaFile.h"
|
| 160 | -#include "../OpenEXR/IlmImf/ImfChannelList.h"
|
| 161 | -#include "../OpenEXR/IlmImf/ImfRgba.h"
|
| 162 | -#include "../OpenEXR/IlmImf/ImfArray.h"
|
| 163 | -#include "../OpenEXR/IlmImf/ImfPreviewImage.h"
|
| 164 | -#include "../OpenEXR/Half/half.h"
|
| 165 | +#include <OpenEXR/ImfIO.h>
|
| 166 | +#include <OpenEXR/Iex.h>
|
| 167 | +#include <OpenEXR/ImfOutputFile.h>
|
| 168 | +#include <OpenEXR/ImfInputFile.h>
|
| 169 | +#include <OpenEXR/ImfRgbaFile.h>
|
| 170 | +#include <OpenEXR/ImfChannelList.h>
|
| 171 | +#include <OpenEXR/ImfRgba.h>
|
| 172 | +#include <OpenEXR/ImfArray.h>
|
| 173 | +#include <OpenEXR/ImfPreviewImage.h>
|
| 174 | +#include <OpenEXR/half.h>
|
| 175 |
|
| 176 |
|
| 177 | // ==========================================================
|
| 178 | diff -rupN FreeImage/Source/FreeImage/PluginJ2K.cpp FreeImage-new/Source/FreeImage/PluginJ2K.cpp
|
| 179 | |
| 180 | |
| 181 | @@ -21,7 +21,7 @@
|
| 182 |
|
| 183 | #include "FreeImage.h"
|
| 184 | #include "Utilities.h"
|
| 185 | -#include "../LibOpenJPEG/openjpeg.h"
|
| 186 | +#include <openjpeg.h>
|
| 187 | #include "J2KHelper.h"
|
| 188 |
|
| 189 | // ==========================================================
|
| 190 | diff -rupN FreeImage/Source/FreeImage/PluginJP2.cpp FreeImage-new/Source/FreeImage/PluginJP2.cpp
|
| 191 | |
| 192 | |
| 193 | @@ -21,7 +21,7 @@
|
| 194 |
|
| 195 | #include "FreeImage.h"
|
| 196 | #include "Utilities.h"
|
| 197 | -#include "../LibOpenJPEG/openjpeg.h"
|
| 198 | +#include <openjpeg.h>
|
| 199 | #include "J2KHelper.h"
|
| 200 |
|
| 201 | // ==========================================================
|
| 202 | diff -rupN FreeImage/Source/FreeImage/PluginJPEG.cpp FreeImage-new/Source/FreeImage/PluginJPEG.cpp
|
| 203 | |
| 204 | |
| 205 | @@ -35,9 +35,9 @@ extern "C" {
|
| 206 | #undef FAR
|
| 207 | #include <setjmp.h>
|
| 208 |
|
| 209 | -#include "../LibJPEG/jinclude.h"
|
| 210 | -#include "../LibJPEG/jpeglib.h"
|
| 211 | -#include "../LibJPEG/jerror.h"
|
| 212 | +#include <stdio.h>
|
| 213 | +#include <jpeglib.h>
|
| 214 | +#include <jerror.h>
|
| 215 | }
|
| 216 |
|
| 217 | #include "FreeImage.h"
|
| 218 | diff -rupN FreeImage/Source/FreeImage/PluginJXR.cpp FreeImage-new/Source/FreeImage/PluginJXR.cpp
|
| 219 | |
| 220 | |
| 221 | @@ -23,7 +23,7 @@
|
| 222 | #include "Utilities.h"
|
| 223 | #include "../Metadata/FreeImageTag.h"
|
| 224 |
|
| 225 | -#include "../LibJXR/jxrgluelib/JXRGlue.h"
|
| 226 | +#include <JXRGlue.h>
|
| 227 |
|
| 228 | // ==========================================================
|
| 229 | // Plugin Interface
|
| 230 | diff -rupN FreeImage/Source/FreeImage/PluginPNG.cpp FreeImage-new/Source/FreeImage/PluginPNG.cpp
|
| 231 | |
| 232 | |
| 233 | @@ -40,8 +40,8 @@
|
| 234 |
|
| 235 | // ----------------------------------------------------------
|
| 236 |
|
| 237 | -#include "../ZLib/zlib.h"
|
| 238 | -#include "../LibPNG/png.h"
|
| 239 | +#include <zlib.h>
|
| 240 | +#include <png.h>
|
| 241 |
|
| 242 | // ----------------------------------------------------------
|
| 243 |
|
| 244 | diff -rupN FreeImage/Source/FreeImage/PluginRAW.cpp FreeImage-new/Source/FreeImage/PluginRAW.cpp
|
| 245 | |
| 246 | |
| 247 | @@ -19,7 +19,7 @@
|
| 248 | // Use at your own risk!
|
| 249 | // ==========================================================
|
| 250 |
|
| 251 | -#include "../LibRawLite/libraw/libraw.h"
|
| 252 | +#include <libraw/libraw.h>
|
| 253 |
|
| 254 | #include "FreeImage.h"
|
| 255 | #include "Utilities.h"
|
| 256 |
|
| 257 | diff -rupN FreeImage/Source/FreeImage/PluginTIFF.cpp FreeImage-new/Source/FreeImage/PluginTIFF.cpp
|
| 258 | |
| 259 | |
| 260 | @@ -37,9 +37,9 @@
|
| 261 |
|
| 262 | #include "FreeImage.h"
|
| 263 | #include "Utilities.h"
|
| 264 | -#include "../LibTIFF4/tiffiop.h"
|
| 265 | +#include <tiffio.h>
|
| 266 | #include "../Metadata/FreeImageTag.h"
|
| 267 | -#include "../OpenEXR/Half/half.h"
|
| 268 | +#include <OpenEXR/half.h>
|
| 269 |
|
| 270 | #include "FreeImageIO.h"
|
| 271 | #include "PSDParser.h"
|
| 272 | @@ -194,16 +194,6 @@ TIFFFdOpen(thandle_t handle, const char *name, const char *mode) {
|
| 273 | return tif;
|
| 274 | }
|
| 275 |
|
| 276 | -/**
|
| 277 | -Open a TIFF file for reading or writing
|
| 278 | -@param name
|
| 279 | -@param mode
|
| 280 | -*/
|
| 281 | -TIFF*
|
| 282 | -TIFFOpen(const char* name, const char* mode) {
|
| 283 | - return 0;
|
| 284 | -}
|
| 285 | -
|
| 286 | // ----------------------------------------------------------
|
| 287 | // TIFF library FreeImage-specific routines.
|
| 288 | // ----------------------------------------------------------
|
| 289 | diff -rupN FreeImage/Source/FreeImage/PluginWebP.cpp FreeImage-new/Source/FreeImage/PluginWebP.cpp
|
| 290 | |
| 291 | |
| 292 | @@ -24,10 +24,10 @@
|
| 293 |
|
| 294 | #include "../Metadata/FreeImageTag.h"
|
| 295 |
|
| 296 | -#include "../LibWebP/src/webp/decode.h"
|
| 297 | -#include "../LibWebP/src/webp/encode.h"
|
| 298 | -#include "../LibWebP/src/webp/mux.h"
|
| 299 | +#include <webp/decode.h>
|
| 300 | +#include <webp/encode.h>
|
| 301 | +#include <webp/mux.h>
|
| 302 |
|
| 303 | // ==========================================================
|
| 304 | // Plugin Interface
|
| 305 | diff -rupN FreeImage/Source/FreeImage/PSDParser.cpp FreeImage-new/Source/FreeImage/PSDParser.cpp
|
| 306 | |
| 307 | |
| 308 | @@ -133,8 +133,8 @@ public:
|
| 309 | template <>
|
| 310 | class PSDGetValue<8> {
|
| 311 | public:
|
| 312 | - static inline UINT64 get(const BYTE * iprBuffer) {
|
| 313 | - UINT64 v = ((const UINT64*)iprBuffer)[0];
|
| 314 | + static inline uint64_t get(const BYTE * iprBuffer) {
|
| 315 | + uint64_t v = ((const uint64_t*)iprBuffer)[0];
|
| 316 | #ifndef FREEIMAGE_BIGENDIAN
|
| 317 | SwapInt64(&v);
|
| 318 | #endif
|
| 319 | @@ -147,7 +147,7 @@ public:
|
| 320 |
|
| 321 | // --------------------------------------------------------------------------
|
| 322 |
|
| 323 | -static UINT64
|
| 324 | +static uint64_t
|
| 325 | psdReadSize(FreeImageIO *io, fi_handle handle, const psdHeaderInfo& header) {
|
| 326 | if(header._Version == 1) {
|
| 327 | BYTE Length[4];
|
| 328 | @@ -199,11 +199,11 @@ public:
|
| 329 | template <>
|
| 330 | class PSDSetValue<8> {
|
| 331 | public:
|
| 332 | - static inline void set(const BYTE * iprBuffer, UINT64 v) {
|
| 333 | + static inline void set(const BYTE * iprBuffer, uint64_t v) {
|
| 334 | #ifndef FREEIMAGE_BIGENDIAN
|
| 335 | SwapInt64(&v);
|
| 336 | #endif
|
| 337 | - ((UINT64*)iprBuffer)[0] = v;
|
| 338 | + ((uint64_t*)iprBuffer)[0] = v;
|
| 339 | }
|
| 340 | };
|
| 341 |
|
| 342 | @@ -213,7 +213,7 @@ public:
|
| 343 | // --------------------------------------------------------------------------
|
| 344 |
|
| 345 | static inline bool
|
| 346 | -psdWriteSize(FreeImageIO *io, fi_handle handle, const psdHeaderInfo& header, UINT64 v) {
|
| 347 | +psdWriteSize(FreeImageIO *io, fi_handle handle, const psdHeaderInfo& header, uint64_t v) {
|
| 348 | if(header._Version == 1) {
|
| 349 | BYTE Length[4];
|
| 350 | psdSetLongValue(Length, sizeof(Length), (DWORD)v);
|
| 351 | @@ -1063,10 +1063,10 @@ unsigned psdParser::GetChannelOffset(FIB
|
| 352 | bool psdParser::ReadLayerAndMaskInfoSection(FreeImageIO *io, fi_handle handle) {
|
| 353 | bool bSuccess = true;
|
| 354 |
|
| 355 | - UINT64 nTotalBytes = psdReadSize(io, handle, _headerInfo);
|
| 356 | + uint64_t nTotalBytes = psdReadSize(io, handle, _headerInfo);
|
| 357 |
|
| 358 | // Hack to handle large PSB files without using fseeko().
|
| 359 | - if (sizeof(long) < sizeof(UINT64)) {
|
| 360 | + if (sizeof(long) < sizeof(uint64_t)) {
|
| 361 | const long offset = 0x10000000;
|
| 362 | while (nTotalBytes > offset) {
|
| 363 | if (io->seek_proc(handle, offset, SEEK_CUR) != 0) {
|
| 364 | @@ -1672,7 +1672,7 @@ bool psdParser::WriteLayerAndMaskInfoSec
|
| 365 | // Short section with no layers.
|
| 366 | BYTE IntValue[4];
|
| 367 |
|
| 368 | - UINT64 size;
|
| 369 | + uint64_t size;
|
| 370 | if(_headerInfo._Version == 1) {
|
| 371 | size = 8;
|
| 372 | } else {
|
| 373 | diff -rupN FreeImage/Source/FreeImage/ZLibInterface.cpp FreeImage-new/Source/FreeImage/ZLibInterface.cpp
|
| 374 | |
| 375 | |
| 376 | @@ -19,10 +19,9 @@
|
| 377 | // Use at your own risk!
|
| 378 | // ==========================================================
|
| 379 |
|
| 380 | -#include "../ZLib/zlib.h"
|
| 381 | +#include <zlib.h>
|
| 382 | #include "FreeImage.h"
|
| 383 | #include "Utilities.h"
|
| 384 | -#include "../ZLib/zutil.h" /* must be the last header because of error C3163 in VS2008 (_vsnprintf defined in stdio.h) */
|
| 385 |
|
| 386 | /**
|
| 387 | Compresses a source buffer into a target buffer, using the ZLib library.
|
| 388 | @@ -115,7 +114,7 @@ FreeImage_ZLibGZip(BYTE *target, DWORD t
|
| 389 | return 0;
|
| 390 | case Z_OK: {
|
| 391 | // patch header, setup crc and length (stolen from mod_trace_output)
|
| 392 | - BYTE *p = target + 8; *p++ = 2; *p = OS_CODE; // xflags, os_code
|
| 393 | + BYTE *p = target + 8; *p++ = 2; *p = 0x03; // xflags, os_code (unix)
|
| 394 | crc = crc32(crc, source, source_size);
|
| 395 | memcpy(target + 4 + dest_len, &crc, 4);
|
| 396 | memcpy(target + 8 + dest_len, &source_size, 4);
|
| 397 | diff -rupN FreeImage/Source/FreeImage.h FreeImage-new/Source/FreeImage.h
|
| 398 | |
| 399 | |
| 400 | @@ -155,8 +155,11 @@ typedef uint8_t BYTE;
|
| 401 | typedef uint16_t WORD;
|
| 402 | typedef uint32_t DWORD;
|
| 403 | typedef int32_t LONG;
|
| 404 | +// Disable these, they conflict with the (wrong) ones of libraw
|
| 405 | +#if 0
|
| 406 | typedef int64_t INT64;
|
| 407 | typedef uint64_t UINT64;
|
| 408 | +#endif
|
| 409 | #else
|
| 410 | // MS is not C99 ISO compliant
|
| 411 | typedef long BOOL;
|
| 412 | @@ -410,7 +413,12 @@ FI_ENUM(FREE_IMAGE_FORMAT) {
|
| 413 | FIF_DDS = 24,
|
| 414 | FIF_GIF = 25,
|
| 415 | FIF_HDR = 26,
|
| 416 | - FIF_FAXG3 = 27,
|
| 417 | +/* The G3 fax format plugin is deliberately disabled in the Fedora build of
|
| 418 | + FreeImage as it requires that FreeImage uses a private copy of libtiff
|
| 419 | + which is a no no because of security reasons. */
|
| 420 | +#if 0
|
| 421 | + FIF_FAXG3 = 27,
|
| 422 | +#endif
|
| 423 | FIF_SGI = 28,
|
| 424 | FIF_EXR = 29,
|
| 425 | FIF_J2K = 30,
|
| 426 | @@ -473,6 +481,10 @@ FI_ENUM(FREE_IMAGE_DITHER) {
|
| 427 | FID_BAYER16x16 = 6 //! Bayer ordered dispersed dot dithering (order 4 dithering matrix)
|
| 428 | };
|
| 429 |
|
| 430 | +/* The FreeImage_JPEGTransform functions are deliberately disabled in the
|
| 431 | + Fedora build of FreeImage as they require that FreeImage uses a private copy
|
| 432 | + of libjpeg which is a no no because of security reasons. */
|
| 433 | +#if 0
|
| 434 | /** Lossless JPEG transformations
|
| 435 | Constants used in FreeImage_JPEGTransform
|
| 436 | */
|
| 437 | @@ -486,6 +498,7 @@ FI_ENUM(FREE_IMAGE_JPEG_OPERATION) {
|
| 438 | FIJPEG_OP_ROTATE_180 = 6, //! 180-degree rotation
|
| 439 | FIJPEG_OP_ROTATE_270 = 7 //! 270-degree clockwise (or 90 ccw)
|
| 440 | };
|
| 441 | +#endif
|
| 442 |
|
| 443 | /** Tone mapping operators.
|
| 444 | Constants used in FreeImage_ToneMapping.
|
| 445 | @@ -1076,7 +1089,10 @@ DLL_API const char* DLL_CALLCONV FreeIma
|
| 446 | // --------------------------------------------------------------------------
|
| 447 | // JPEG lossless transformation routines
|
| 448 | // --------------------------------------------------------------------------
|
| 449 | -
|
| 450 | +/* The FreeImage_JPEGTransform functions are deliberately disabled in the
|
| 451 | ++ Fedora build of FreeImage as they require that FreeImage uses a private copy
|
| 452 | ++ of libjpeg which is a no no because of security reasons. */
|
| 453 | +#if 0
|
| 454 | DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransform(const char *src_file, const char *dst_file, FREE_IMAGE_JPEG_OPERATION operation, BOOL perfect FI_DEFAULT(TRUE));
|
| 455 | DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformU(const wchar_t *src_file, const wchar_t *dst_file, FREE_IMAGE_JPEG_OPERATION operation, BOOL perfect FI_DEFAULT(TRUE));
|
| 456 | DLL_API BOOL DLL_CALLCONV FreeImage_JPEGCrop(const char *src_file, const char *dst_file, int left, int top, int right, int bottom);
|
| 457 | @@ -1085,6 +1101,7 @@ DLL_API BOOL DLL_CALLCONV FreeImage_JPEG
|
| 458 | DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformCombined(const char *src_file, const char *dst_file, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect FI_DEFAULT(TRUE));
|
| 459 | DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformCombinedU(const wchar_t *src_file, const wchar_t *dst_file, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect FI_DEFAULT(TRUE));
|
| 460 | DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformCombinedFromMemory(FIMEMORY* src_stream, FIMEMORY* dst_stream, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect FI_DEFAULT(TRUE));
|
| 461 | +#endif
|
| 462 |
|
| 463 |
|
| 464 | // --------------------------------------------------------------------------
|
| 465 | diff -rupN FreeImage/Source/FreeImageToolkit/JPEGTransform.cpp FreeImage-new/Source/FreeImageToolkit/JPEGTransform.cpp
|
| 466 | |
| 467 | |
| 468 | @@ -26,10 +26,10 @@ extern "C" {
|
| 469 | #undef FAR
|
| 470 | #include <setjmp.h>
|
| 471 |
|
| 472 | -#include "../LibJPEG/jinclude.h"
|
| 473 | -#include "../LibJPEG/jpeglib.h"
|
| 474 | -#include "../LibJPEG/jerror.h"
|
| 475 | -#include "../LibJPEG/transupp.h"
|
| 476 | +#include <jinclude.h>
|
| 477 | +#include <jpeglib.h>
|
| 478 | +#include <jerror.h>
|
| 479 | +#include <transupp.h>
|
| 480 | }
|
| 481 |
|
| 482 | #include "FreeImage.h"
|
| 483 | diff -rupN FreeImage/Source/Metadata/TagConversion.cpp FreeImage-new/Source/Metadata/TagConversion.cpp
|
| 484 | |
| 485 | |
| 486 | @@ -30,6 +30,11 @@
|
| 487 |
|
| 488 | #define MAX_TEXT_EXTENT 512
|
| 489 |
|
| 490 | +// These were in FreeImage.h, but are moved here to avoid conflicts (see note in FreeImage.h)
|
| 491 | +typedef int64_t INT64;
|
| 492 | +typedef uint64_t UINT64;
|
| 493 | +
|
| 494 | +
|
| 495 | /**
|
| 496 | Convert a tag to a C string
|
| 497 | */
|
| 498 | diff -rupN FreeImage/Source/Metadata/XTIFF.cpp FreeImage-new/Source/Metadata/XTIFF.cpp
|
| 499 | |
| 500 | |
| 501 | @@ -29,13 +29,18 @@
|
| 502 | #pragma warning (disable : 4786) // identifier was truncated to 'number' characters
|
| 503 | #endif
|
| 504 |
|
| 505 | -#include "../LibTIFF4/tiffiop.h"
|
| 506 | +#include <tiffio.h>
|
| 507 |
|
| 508 | #include "FreeImage.h"
|
| 509 | #include "Utilities.h"
|
| 510 | #include "FreeImageTag.h"
|
| 511 | #include "FIRational.h"
|
| 512 |
|
| 513 | +extern "C"
|
| 514 | +{
|
| 515 | + int _TIFFDataSize(TIFFDataType type);
|
| 516 | +}
|
| 517 | +
|
| 518 | // ----------------------------------------------------------
|
| 519 | // Extended TIFF Directory GEO Tag Support
|
| 520 | // ----------------------------------------------------------
|
| 521 | @@ -224,6 +229,33 @@ tiff_write_geotiff_profile(TIFF *tif, FI
|
| 522 | // TIFF EXIF tag reading & writing
|
| 523 | // ----------------------------------------------------------
|
| 524 |
|
| 525 | +static uint32 exif_tag_ids[] = {
|
| 526 | + EXIFTAG_EXPOSURETIME, EXIFTAG_FNUMBER, EXIFTAG_EXPOSUREPROGRAM,
|
| 527 | + EXIFTAG_SPECTRALSENSITIVITY, EXIFTAG_ISOSPEEDRATINGS, EXIFTAG_OECF,
|
| 528 | + EXIFTAG_EXIFVERSION, EXIFTAG_DATETIMEORIGINAL, EXIFTAG_DATETIMEDIGITIZED,
|
| 529 | + EXIFTAG_COMPONENTSCONFIGURATION, EXIFTAG_COMPRESSEDBITSPERPIXEL,
|
| 530 | + EXIFTAG_SHUTTERSPEEDVALUE, EXIFTAG_APERTUREVALUE,
|
| 531 | + EXIFTAG_BRIGHTNESSVALUE, EXIFTAG_EXPOSUREBIASVALUE,
|
| 532 | + EXIFTAG_MAXAPERTUREVALUE, EXIFTAG_SUBJECTDISTANCE, EXIFTAG_METERINGMODE,
|
| 533 | + EXIFTAG_LIGHTSOURCE, EXIFTAG_FLASH, EXIFTAG_FOCALLENGTH,
|
| 534 | + EXIFTAG_SUBJECTAREA, EXIFTAG_MAKERNOTE, EXIFTAG_USERCOMMENT,
|
| 535 | + EXIFTAG_SUBSECTIME, EXIFTAG_SUBSECTIMEORIGINAL,
|
| 536 | + EXIFTAG_SUBSECTIMEDIGITIZED, EXIFTAG_FLASHPIXVERSION, EXIFTAG_COLORSPACE,
|
| 537 | + EXIFTAG_PIXELXDIMENSION, EXIFTAG_PIXELYDIMENSION,
|
| 538 | + EXIFTAG_RELATEDSOUNDFILE, EXIFTAG_FLASHENERGY,
|
| 539 | + EXIFTAG_SPATIALFREQUENCYRESPONSE, EXIFTAG_FOCALPLANEXRESOLUTION,
|
| 540 | + EXIFTAG_FOCALPLANEYRESOLUTION, EXIFTAG_FOCALPLANERESOLUTIONUNIT,
|
| 541 | + EXIFTAG_SUBJECTLOCATION, EXIFTAG_EXPOSUREINDEX, EXIFTAG_SENSINGMETHOD,
|
| 542 | + EXIFTAG_FILESOURCE, EXIFTAG_SCENETYPE, EXIFTAG_CFAPATTERN,
|
| 543 | + EXIFTAG_CUSTOMRENDERED, EXIFTAG_EXPOSUREMODE, EXIFTAG_WHITEBALANCE,
|
| 544 | + EXIFTAG_DIGITALZOOMRATIO, EXIFTAG_FOCALLENGTHIN35MMFILM,
|
| 545 | + EXIFTAG_SCENECAPTURETYPE, EXIFTAG_GAINCONTROL, EXIFTAG_CONTRAST,
|
| 546 | + EXIFTAG_SATURATION, EXIFTAG_SHARPNESS, EXIFTAG_DEVICESETTINGDESCRIPTION,
|
| 547 | + EXIFTAG_SUBJECTDISTANCERANGE, EXIFTAG_GAINCONTROL, EXIFTAG_GAINCONTROL,
|
| 548 | + EXIFTAG_IMAGEUNIQUEID
|
| 549 | +};
|
| 550 | +static int nExifTags = sizeof(exif_tag_ids) / sizeof(exif_tag_ids[0]);
|
| 551 | +
|
| 552 | /**
|
| 553 | Read a single Exif tag
|
| 554 |
|
| 555 | @@ -575,45 +607,11 @@ tiff_read_exif_tags(TIFF *tif, TagLib::M
|
| 556 |
|
| 557 | // loop over all Core Directory Tags
|
| 558 | // ### uses private data, but there is no other way
|
| 559 | + // -> Fedora: Best we can do without private headers is to hard-code a list of known EXIF tags and read those
|
| 560 | if(md_model == TagLib::EXIF_MAIN) {
|
| 561 | - const TIFFDirectory *td = &tif->tif_dir;
|
| 562 | -
|
| 563 | - uint32 lastTag = 0; //<- used to prevent reading some tags twice (as stored in tif_fieldinfo)
|
| 564 | -
|
| 565 | - for (int fi = 0, nfi = (int)tif->tif_nfields; nfi > 0; nfi--, fi++) {
|
| 566 | - const TIFFField *fld = tif->tif_fields[fi];
|
| 567 | -
|
| 568 | - const uint32 tag_id = TIFFFieldTag(fld);
|
| 569 | -
|
| 570 | - if(tag_id == lastTag) {
|
| 571 | - continue;
|
| 572 | - }
|
| 573 | -
|
| 574 | - // test if tag value is set
|
| 575 | - // (lifted directly from LibTiff _TIFFWriteDirectory)
|
| 576 | -
|
| 577 | - if( fld->field_bit == FIELD_CUSTOM ) {
|
| 578 | - int is_set = FALSE;
|
| 579 | -
|
| 580 | - for(int ci = 0; ci < td->td_customValueCount; ci++ ) {
|
| 581 | - is_set |= (td->td_customValues[ci].info == fld);
|
| 582 | - }
|
| 583 | -
|
| 584 | - if( !is_set ) {
|
| 585 | - continue;
|
| 586 | - }
|
| 587 | -
|
| 588 | - } else if(!TIFFFieldSet(tif, fld->field_bit)) {
|
| 589 | - continue;
|
| 590 | - }
|
| 591 | -
|
| 592 | - // process *all* other tags (some will be ignored)
|
| 593 | -
|
| 594 | - tiff_read_exif_tag(tif, tag_id, dib, md_model);
|
| 595 | -
|
| 596 | - lastTag = tag_id;
|
| 597 | + for (int i = 0; i < nExifTags; ++i) {
|
| 598 | + tiff_read_exif_tag(tif, exif_tag_ids[i], dib, md_model);
|
| 599 | }
|
| 600 | -
|
| 601 | }
|
| 602 |
|
| 603 | return TRUE;
|
| 604 | @@ -723,10 +721,9 @@ tiff_write_exif_tags(TIFF *tif, TagLib::
|
| 605 |
|
| 606 | TagLib& tag_lib = TagLib::instance();
|
| 607 |
|
| 608 | - for (int fi = 0, nfi = (int)tif->tif_nfields; nfi > 0; nfi--, fi++) {
|
| 609 | - const TIFFField *fld = tif->tif_fields[fi];
|
| 610 | -
|
| 611 | - const uint32 tag_id = TIFFFieldTag(fld);
|
| 612 | + for (int fi = 0; fi < nExifTags; fi++) {
|
| 613 | + const uint32 tag_id = exif_tag_ids[fi];
|
| 614 | + const TIFFField *fld = TIFFFieldWithTag(tif, tag_id);
|
| 615 |
|
| 616 | if(skip_write_field(tif, tag_id)) {
|
| 617 | // skip tags that are already handled by the LibTIFF writing process
|
| 618 | diff -rupN FreeImage/Source/Utilities.h FreeImage-new/Source/Utilities.h
|
| 619 | |
| 620 | |
| 621 | @@ -446,12 +446,12 @@ SwapLong(DWORD *lp) {
|
| 622 | }
|
| 623 |
|
| 624 | inline void
|
| 625 | -SwapInt64(UINT64 *arg) {
|
| 626 | +SwapInt64(uint64_t *arg) {
|
| 627 | #if defined(_MSC_VER) && _MSC_VER >= 1310
|
| 628 | *arg = _byteswap_uint64(*arg);
|
| 629 | #else
|
| 630 | union Swap {
|
| 631 | - UINT64 sv;
|
| 632 | + uint64_t sv;
|
| 633 | DWORD ul[2];
|
| 634 | } tmp, result;
|
| 635 | tmp.sv = *arg;
|