summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim A. Misbakh-Soloviov <git@mva.name>2019-02-06 15:32:55 +0700
committerVadim A. Misbakh-Soloviov <git@mva.name>2019-02-06 15:38:55 +0700
commitb2b14ab99ae8273cf4cf1cf15458294663d444c5 (patch)
tree60fd2836c952babc3887573529696875819db502
parentgames-action/ardentryst: fix installation (diff)
downloadgamerlay-b2b14ab99ae8273cf4cf1cf15458294663d444c5.tar.gz
gamerlay-b2b14ab99ae8273cf4cf1cf15458294663d444c5.tar.bz2
gamerlay-b2b14ab99ae8273cf4cf1cf15458294663d444c5.zip
stuntrally: fix mygui dep (thanks to Graham for report). Beware, project developed is stopped
Signed-off-by: Vadim A. Misbakh-Soloviov <git@mva.name>
-rw-r--r--games-sports/stuntrally/stuntrally-2.6.ebuild2
-rw-r--r--games-sports/stuntrally/stuntrally-9999.ebuild6
-rw-r--r--media-libs/freeimage/Manifest2
-rw-r--r--media-libs/freeimage/files/freeimage-3.18.0-libjpeg-turbo.patch481
-rw-r--r--media-libs/freeimage/files/freeimage-3.18.0-raw.patch16
-rw-r--r--media-libs/freeimage/files/freeimage-3.18.0-unbundling.patch639
-rw-r--r--media-libs/freeimage/freeimage-3.18.0.ebuild112
-rw-r--r--media-libs/freeimage/metadata.xml11
8 files changed, 1267 insertions, 2 deletions
diff --git a/games-sports/stuntrally/stuntrally-2.6.ebuild b/games-sports/stuntrally/stuntrally-2.6.ebuild
index 5d2f22d..73b57fb 100644
--- a/games-sports/stuntrally/stuntrally-2.6.ebuild
+++ b/games-sports/stuntrally/stuntrally-2.6.ebuild
@@ -27,7 +27,7 @@ fi
DEPEND="
game? (
dev-games/ogre[cg,boost,ois,freeimage,opengl,zip,-double-precision]
- dev-games/mygui[ogre]
+ dev-games/mygui[ogre,plugins]
media-libs/libsdl2[haptic]
media-libs/libvorbis
media-libs/libogg
diff --git a/games-sports/stuntrally/stuntrally-9999.ebuild b/games-sports/stuntrally/stuntrally-9999.ebuild
index 0bd380b..bbf601b 100644
--- a/games-sports/stuntrally/stuntrally-9999.ebuild
+++ b/games-sports/stuntrally/stuntrally-9999.ebuild
@@ -18,6 +18,10 @@ if [[ ${PV} = 9999* ]]; then
SRC_URI=""
KEYWORDS=""
EGIT_REPO_URI="https://github.com/stuntrally/stuntrally"
+# ^ dead
+# EGIT_REPO_URI="https://github.com/akien-mga/stuntrally"
+# EGIT_BRANCH="ogre-1.11"
+# ^ TODO (ogre-1.11 is hardmasked for now)
LIVE_PDEPEND="~${CATEGORY}/${PN}-tracks-${PV}"
else
KEYWORDS="~amd64 ~x86"
@@ -27,7 +31,7 @@ fi
DEPEND="
game? (
dev-games/ogre[cg,boost,ois,freeimage,opengl,zip,-double-precision]
- dev-games/mygui[ogre]
+ dev-games/mygui[ogre,plugins]
media-libs/libsdl2[haptic]
media-libs/libvorbis
media-libs/libogg
diff --git a/media-libs/freeimage/Manifest b/media-libs/freeimage/Manifest
new file mode 100644
index 0000000..292f9ee
--- /dev/null
+++ b/media-libs/freeimage/Manifest
@@ -0,0 +1,2 @@
+DIST FreeImage3180.pdf 1665541 BLAKE2B 5d40ee6fa0a1e73df0cc961edbd70a2835ef88fb540f123fd81f2bb826d4c949d2a60dfe3fc02406ce632a389935abac0d471c963c9803b8c2aece2b48afb003 SHA512 632f68b14f7a5916a1b95bbf86c268d0afe786a2537472301bb002254aa3195f046efb41f073133633211e985e90edbb99285ab6f42bc55501c756292a3c4c03
+DIST FreeImage3180.zip 7415716 BLAKE2B b695271f4e80eb304eccde66e38b5095eceae51fbe0dd97df69c55f364f8440d8c97139b8edc2f01c400f5c53a7336fdfab1e28aa3ea04f485901d5def443d25 SHA512 9d9cc7e2d57552c3115e277aeb036e0455204d389026b17a3f513da5be1fd595421655488bb1ec2f76faebed66049119ca55e26e2a6d37024b3fb7ef36ad4818
diff --git a/media-libs/freeimage/files/freeimage-3.18.0-libjpeg-turbo.patch b/media-libs/freeimage/files/freeimage-3.18.0-libjpeg-turbo.patch
new file mode 100644
index 0000000..3e152e0
--- /dev/null
+++ b/media-libs/freeimage/files/freeimage-3.18.0-libjpeg-turbo.patch
@@ -0,0 +1,481 @@
+--- /dev/null
++++ b/LibJPEG/jpegcomp.h
+@@ -0,0 +1,26 @@
++/*
++ * jpegcomp.h
++ *
++ * Copyright (C) 2010, D. R. Commander
++ * For conditions of distribution and use, see the accompanying README file.
++ *
++ * JPEG compatibility macros
++ * These declarations are considered internal to the JPEG library; most
++ * applications using the library shouldn't need to include this file.
++ */
++
++#if JPEG_LIB_VERSION >= 70
++#define _DCT_scaled_size DCT_h_scaled_size
++#define _min_DCT_scaled_size min_DCT_h_scaled_size
++#define _min_DCT_h_scaled_size min_DCT_h_scaled_size
++#define _min_DCT_v_scaled_size min_DCT_v_scaled_size
++#define _jpeg_width jpeg_width
++#define _jpeg_height jpeg_height
++#else
++#define _DCT_scaled_size DCT_scaled_size
++#define _min_DCT_scaled_size min_DCT_scaled_size
++#define _min_DCT_h_scaled_size min_DCT_scaled_size
++#define _min_DCT_v_scaled_size min_DCT_scaled_size
++#define _jpeg_width image_width
++#define _jpeg_height image_height
++#endif
+--- a/LibJPEG/jpegint.h
++++ b/LibJPEG/jpegint.h
+@@ -100,16 +100,14 @@
+ };
+
+ /* Forward DCT (also controls coefficient quantization) */
+-typedef JMETHOD(void, forward_DCT_ptr,
+- (j_compress_ptr cinfo, jpeg_component_info * compptr,
+- JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
+- JDIMENSION start_row, JDIMENSION start_col,
+- JDIMENSION num_blocks));
+-
+ struct jpeg_forward_dct {
+ JMETHOD(void, start_pass, (j_compress_ptr cinfo));
+- /* It is useful to allow each component to have a separate FDCT method. */
+- forward_DCT_ptr forward_DCT[MAX_COMPONENTS];
++ /* perhaps this should be an array??? */
++ JMETHOD(void, forward_DCT, (j_compress_ptr cinfo,
++ jpeg_component_info * compptr,
++ JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
++ JDIMENSION start_row, JDIMENSION start_col,
++ JDIMENSION num_blocks));
+ };
+
+ /* Entropy encoding */
+@@ -213,6 +211,10 @@
+ JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
+ JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo, JBLOCKROW *MCU_data));
+ JMETHOD(void, finish_pass, (j_decompress_ptr cinfo));
++
++ /* This is here to share code between baseline and progressive decoders; */
++ /* other modules probably should not use it */
++ boolean insufficient_data; /* set TRUE after emitting warning */
+ };
+
+ /* Inverse DCT (also performs dequantization) */
+@@ -302,6 +304,7 @@
+ #define jinit_downsampler jIDownsampler
+ #define jinit_forward_dct jIFDCT
+ #define jinit_huff_encoder jIHEncoder
++#define jinit_phuff_encoder jIPHEncoder
+ #define jinit_arith_encoder jIAEncoder
+ #define jinit_marker_writer jIMWriter
+ #define jinit_master_decompress jIDMaster
+@@ -311,6 +314,7 @@
+ #define jinit_input_controller jIInCtlr
+ #define jinit_marker_reader jIMReader
+ #define jinit_huff_decoder jIHDecoder
++#define jinit_phuff_decoder jIPHDecoder
+ #define jinit_arith_decoder jIADecoder
+ #define jinit_inverse_dct jIIDCT
+ #define jinit_upsampler jIUpsampler
+@@ -321,41 +325,15 @@
+ #define jinit_memory_mgr jIMemMgr
+ #define jdiv_round_up jDivRound
+ #define jround_up jRound
+-#define jzero_far jZeroFar
+ #define jcopy_sample_rows jCopySamples
+ #define jcopy_block_row jCopyBlocks
++#define jzero_far jZeroFar
+ #define jpeg_zigzag_order jZIGTable
+ #define jpeg_natural_order jZAGTable
+-#define jpeg_natural_order7 jZAG7Table
+-#define jpeg_natural_order6 jZAG6Table
+-#define jpeg_natural_order5 jZAG5Table
+-#define jpeg_natural_order4 jZAG4Table
+-#define jpeg_natural_order3 jZAG3Table
+-#define jpeg_natural_order2 jZAG2Table
+ #define jpeg_aritab jAriTab
+ #endif /* NEED_SHORT_EXTERNAL_NAMES */
+
+
+-/* On normal machines we can apply MEMCOPY() and MEMZERO() to sample arrays
+- * and coefficient-block arrays. This won't work on 80x86 because the arrays
+- * are FAR and we're assuming a small-pointer memory model. However, some
+- * DOS compilers provide far-pointer versions of memcpy() and memset() even
+- * in the small-model libraries. These will be used if USE_FMEM is defined.
+- * Otherwise, the routines in jutils.c do it the hard way.
+- */
+-
+-#ifndef NEED_FAR_POINTERS /* normal case, same as regular macro */
+-#define FMEMZERO(target,size) MEMZERO(target,size)
+-#else /* 80x86 case */
+-#ifdef USE_FMEM
+-#define FMEMZERO(target,size) _fmemset((void FAR *)(target), 0, (size_t)(size))
+-#else
+-EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero));
+-#define FMEMZERO(target,size) jzero_far(target, size)
+-#endif
+-#endif
+-
+-
+ /* Compression module initialization routines */
+ EXTERN(void) jinit_compress_master JPP((j_compress_ptr cinfo));
+ EXTERN(void) jinit_c_master_control JPP((j_compress_ptr cinfo,
+@@ -370,6 +348,7 @@
+ EXTERN(void) jinit_downsampler JPP((j_compress_ptr cinfo));
+ EXTERN(void) jinit_forward_dct JPP((j_compress_ptr cinfo));
+ EXTERN(void) jinit_huff_encoder JPP((j_compress_ptr cinfo));
++EXTERN(void) jinit_phuff_encoder JPP((j_compress_ptr cinfo));
+ EXTERN(void) jinit_arith_encoder JPP((j_compress_ptr cinfo));
+ EXTERN(void) jinit_marker_writer JPP((j_compress_ptr cinfo));
+ /* Decompression module initialization routines */
+@@ -383,6 +362,7 @@
+ EXTERN(void) jinit_input_controller JPP((j_decompress_ptr cinfo));
+ EXTERN(void) jinit_marker_reader JPP((j_decompress_ptr cinfo));
+ EXTERN(void) jinit_huff_decoder JPP((j_decompress_ptr cinfo));
++EXTERN(void) jinit_phuff_decoder JPP((j_decompress_ptr cinfo));
+ EXTERN(void) jinit_arith_decoder JPP((j_decompress_ptr cinfo));
+ EXTERN(void) jinit_inverse_dct JPP((j_decompress_ptr cinfo));
+ EXTERN(void) jinit_upsampler JPP((j_decompress_ptr cinfo));
+@@ -401,17 +381,12 @@
+ int num_rows, JDIMENSION num_cols));
+ EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row,
+ JDIMENSION num_blocks));
++EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero));
+ /* Constant tables in jutils.c */
+ #if 0 /* This table is not actually needed in v6a */
+ extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */
+ #endif
+ extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */
+-extern const int jpeg_natural_order7[]; /* zz to natural order for 7x7 block */
+-extern const int jpeg_natural_order6[]; /* zz to natural order for 6x6 block */
+-extern const int jpeg_natural_order5[]; /* zz to natural order for 5x5 block */
+-extern const int jpeg_natural_order4[]; /* zz to natural order for 4x4 block */
+-extern const int jpeg_natural_order3[]; /* zz to natural order for 3x3 block */
+-extern const int jpeg_natural_order2[]; /* zz to natural order for 2x2 block */
+
+ /* Arithmetic coding probability estimation tables in jaricom.c */
+ extern const INT32 jpeg_aritab[];
+--- a/LibJPEG/transupp.h
++++ b/LibJPEG/transupp.h
+@@ -107,15 +106,13 @@
+
+ /*
+ * Codes for crop parameters, which can individually be unspecified,
+- * positive or negative for xoffset or yoffset,
+- * positive or forced for width or height.
++ * positive, or negative. (Negative width or height makes no sense, though.)
+ */
+
+ typedef enum {
+- JCROP_UNSET,
+- JCROP_POS,
+- JCROP_NEG,
+- JCROP_FORCE
++ JCROP_UNSET,
++ JCROP_POS,
++ JCROP_NEG
+ } JCROP_CODE;
+
+ /*
+@@ -133,6 +133,13 @@ typedef struct {
+ boolean trim; /* if TRUE, trim partial MCUs as needed */
+ boolean force_grayscale; /* if TRUE, convert color image to grayscale */
+ boolean crop; /* if TRUE, crop or wipe source image */
++ boolean slow_hflip; /* For best performance, the JXFORM_FLIP_H transform
++ normally modifies the source coefficients in place.
++ Setting this to TRUE will instead use a slower,
++ double-buffered algorithm, which leaves the source
++ coefficients in tact (necessary if other transformed
++ images must be generated from the same set of
++ coefficients. */
+
+ /* Crop parameters: application need not set these unless crop is TRUE.
+ * These can be filled in by jtransform_parse_crop_spec().
+--- a/LibJPEG/transupp.c
++++ b/LibJPEG/transupp.c
+@@ -20,9 +21,19 @@
+ #include "jinclude.h"
+ #include "jpeglib.h"
+ #include "transupp.h" /* My own external interface */
++#include "jpegcomp.h"
+ #include <ctype.h> /* to declare isdigit() */
+
+
++#if JPEG_LIB_VERSION >= 70
++#define dstinfo_min_DCT_h_scaled_size dstinfo->min_DCT_h_scaled_size
++#define dstinfo_min_DCT_v_scaled_size dstinfo->min_DCT_v_scaled_size
++#else
++#define dstinfo_min_DCT_h_scaled_size DCTSIZE
++#define dstinfo_min_DCT_v_scaled_size DCTSIZE
++#endif
++
++
+ #if TRANSFORMS_SUPPORTED
+
+ /*
+@@ -134,7 +145,7 @@
+ * Partial iMCUs at the right edge are left untouched.
+ */
+ MCU_cols = srcinfo->output_width /
+- (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size);
++ (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size);
+
+ for (ci = 0; ci < dstinfo->num_components; ci++) {
+ compptr = dstinfo->comp_info + ci;
+@@ -200,7 +211,7 @@
+ * this is essentially the same as the routine above.
+ */
+ MCU_cols = srcinfo->output_width /
+- (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size);
++ (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size);
+
+ for (ci = 0; ci < dstinfo->num_components; ci++) {
+ compptr = dstinfo->comp_info + ci;
+@@ -265,7 +276,7 @@
+ * Partial iMCUs at the bottom edge are copied verbatim.
+ */
+ MCU_rows = srcinfo->output_height /
+- (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size);
++ (dstinfo->max_v_samp_factor * dstinfo_min_DCT_v_scaled_size);
+
+ for (ci = 0; ci < dstinfo->num_components; ci++) {
+ compptr = dstinfo->comp_info + ci;
+@@ -393,7 +404,7 @@
+ * not mirrored.
+ */
+ MCU_cols = srcinfo->output_height /
+- (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size);
++ (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size);
+
+ for (ci = 0; ci < dstinfo->num_components; ci++) {
+ compptr = dstinfo->comp_info + ci;
+@@ -474,7 +485,7 @@
+ * not mirrored.
+ */
+ MCU_rows = srcinfo->output_width /
+- (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size);
++ (dstinfo->max_v_samp_factor * dstinfo_min_DCT_v_scaled_size);
+
+ for (ci = 0; ci < dstinfo->num_components; ci++) {
+ compptr = dstinfo->comp_info + ci;
+@@ -542,9 +553,9 @@
+ jpeg_component_info *compptr;
+
+ MCU_cols = srcinfo->output_width /
+- (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size);
++ (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size);
+ MCU_rows = srcinfo->output_height /
+- (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size);
++ (dstinfo->max_v_samp_factor * dstinfo_min_DCT_v_scaled_size);
+
+ for (ci = 0; ci < dstinfo->num_components; ci++) {
+ compptr = dstinfo->comp_info + ci;
+@@ -653,9 +664,9 @@
+ jpeg_component_info *compptr;
+
+ MCU_cols = srcinfo->output_height /
+- (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size);
++ (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size);
+ MCU_rows = srcinfo->output_width /
+- (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size);
++ (dstinfo->max_v_samp_factor * dstinfo_min_DCT_v_scaled_size);
+
+ for (ci = 0; ci < dstinfo->num_components; ci++) {
+ compptr = dstinfo->comp_info + ci;
+@@ -771,7 +782,7 @@
+ * The routine returns TRUE if the spec string is valid, FALSE if not.
+ *
+ * The crop spec string should have the format
+- * <width>[f]x<height>[f]{+-}<xoffset>{+-}<yoffset>
++ * <width>x<height>{+-}<xoffset>{+-}<yoffset>
+ * where width, height, xoffset, and yoffset are unsigned integers.
+ * Each of the elements can be omitted to indicate a default value.
+ * (A weakness of this style is that it is not possible to omit xoffset
+@@ -793,22 +804,14 @@
+ /* fetch width */
+ if (! jt_read_integer(&spec, &info->crop_width))
+ return FALSE;
+- if (*spec == 'f' || *spec == 'F') {
+- spec++;
+- info->crop_width_set = JCROP_FORCE;
+- } else
+- info->crop_width_set = JCROP_POS;
++ info->crop_width_set = JCROP_POS;
+ }
+- if (*spec == 'x' || *spec == 'X') {
++ if (*spec == 'x' || *spec == 'X') {
+ /* fetch height */
+ spec++;
+ if (! jt_read_integer(&spec, &info->crop_height))
+ return FALSE;
+- if (*spec == 'f' || *spec == 'F') {
+- spec++;
+- info->crop_height_set = JCROP_FORCE;
+- } else
+- info->crop_height_set = JCROP_POS;
++ info->crop_height_set = JCROP_POS;
+ }
+ if (*spec == '+' || *spec == '-') {
+ /* fetch xoffset */
+@@ -897,7 +900,12 @@
+ info->num_components = srcinfo->num_components;
+
+ /* Compute output image dimensions and related values. */
++#if JPEG_LIB_VERSION >= 80
+ jpeg_core_output_dimensions(srcinfo);
++#else
++ srcinfo->output_width = srcinfo->image_width;
++ srcinfo->output_height = srcinfo->image_height;
++#endif
+
+ /* Return right away if -perfect is given and transformation is not perfect.
+ */
+@@ -905,15 +913,15 @@
+ if (info->num_components == 1) {
+ if (!jtransform_perfect_transform(srcinfo->output_width,
+ srcinfo->output_height,
+- srcinfo->min_DCT_h_scaled_size,
+- srcinfo->min_DCT_v_scaled_size,
++ srcinfo->_min_DCT_h_scaled_size,
++ srcinfo->_min_DCT_v_scaled_size,
+ info->transform))
+ return FALSE;
+ } else {
+ if (!jtransform_perfect_transform(srcinfo->output_width,
+ srcinfo->output_height,
+- srcinfo->max_h_samp_factor * srcinfo->min_DCT_h_scaled_size,
+- srcinfo->max_v_samp_factor * srcinfo->min_DCT_v_scaled_size,
++ srcinfo->max_h_samp_factor * srcinfo->_min_DCT_h_scaled_size,
++ srcinfo->max_v_samp_factor * srcinfo->_min_DCT_v_scaled_size,
+ info->transform))
+ return FALSE;
+ }
+@@ -932,26 +940,26 @@
+ info->output_width = srcinfo->output_height;
+ info->output_height = srcinfo->output_width;
+ if (info->num_components == 1) {
+- info->iMCU_sample_width = srcinfo->min_DCT_v_scaled_size;
+- info->iMCU_sample_height = srcinfo->min_DCT_h_scaled_size;
++ info->iMCU_sample_width = srcinfo->_min_DCT_v_scaled_size;
++ info->iMCU_sample_height = srcinfo->_min_DCT_h_scaled_size;
+ } else {
+ info->iMCU_sample_width =
+- srcinfo->max_v_samp_factor * srcinfo->min_DCT_v_scaled_size;
++ srcinfo->max_v_samp_factor * srcinfo->_min_DCT_v_scaled_size;
+ info->iMCU_sample_height =
+- srcinfo->max_h_samp_factor * srcinfo->min_DCT_h_scaled_size;
++ srcinfo->max_h_samp_factor * srcinfo->_min_DCT_h_scaled_size;
+ }
+ break;
+ default:
+ info->output_width = srcinfo->output_width;
+ info->output_height = srcinfo->output_height;
+ if (info->num_components == 1) {
+- info->iMCU_sample_width = srcinfo->min_DCT_h_scaled_size;
+- info->iMCU_sample_height = srcinfo->min_DCT_v_scaled_size;
++ info->iMCU_sample_width = srcinfo->_min_DCT_h_scaled_size;
++ info->iMCU_sample_height = srcinfo->_min_DCT_v_scaled_size;
+ } else {
+ info->iMCU_sample_width =
+- srcinfo->max_h_samp_factor * srcinfo->min_DCT_h_scaled_size;
++ srcinfo->max_h_samp_factor * srcinfo->_min_DCT_h_scaled_size;
+ info->iMCU_sample_height =
+- srcinfo->max_v_samp_factor * srcinfo->min_DCT_v_scaled_size;
++ srcinfo->max_v_samp_factor * srcinfo->_min_DCT_v_scaled_size;
+ }
+ break;
+ }
+@@ -988,16 +996,8 @@
+ (long) info->iMCU_sample_height);
+ } else {
+ /* Ensure the effective crop region will cover the requested */
+- if (info->crop_width_set == JCROP_FORCE ||
+- info->crop_width > info->output_width)
+- info->output_width = info->crop_width;
+- else
+ info->output_width =
+ info->crop_width + (xoffset % info->iMCU_sample_width);
+- if (info->crop_height_set == JCROP_FORCE ||
+- info->crop_height > info->output_height)
+- info->output_height = info->crop_height;
+- else
+ info->output_height =
+ info->crop_height + (yoffset % info->iMCU_sample_height);
+ }
+@@ -1020,7 +1022,7 @@
+ case JXFORM_FLIP_H:
+ if (info->trim)
+ trim_right_edge(info, srcinfo->output_width);
+- if (info->y_crop_offset != 0)
++ if (info->y_crop_offset != 0 || info->slow_hflip)
+ need_workspace = TRUE;
+ /* do_flip_h_no_crop doesn't need a workspace array */
+ break;
+@@ -1124,9 +1126,11 @@
+ jtemp = dstinfo->image_width;
+ dstinfo->image_width = dstinfo->image_height;
+ dstinfo->image_height = jtemp;
++#if JPEG_LIB_VERSION >= 70
+ itemp = dstinfo->min_DCT_h_scaled_size;
+ dstinfo->min_DCT_h_scaled_size = dstinfo->min_DCT_v_scaled_size;
+ dstinfo->min_DCT_v_scaled_size = itemp;
++#endif
+
+ /* Transpose sampling factors */
+ for (ci = 0; ci < dstinfo->num_components; ci++) {
+@@ -1362,8 +1366,10 @@
+ /* Correct the destination's image dimensions as necessary
+ * for rotate/flip, resize, and crop operations.
+ */
++#if JPEG_LIB_VERSION >= 70
+ dstinfo->jpeg_width = info->output_width;
+ dstinfo->jpeg_height = info->output_height;
++#endif
+
+ /* Transpose destination image parameters */
+ switch (info->transform) {
+@@ -1371,9 +1377,17 @@
+ case JXFORM_TRANSVERSE:
+ case JXFORM_ROT_90:
+ case JXFORM_ROT_270:
++#if JPEG_LIB_VERSION < 70
++ dstinfo->image_width = info->output_height;
++ dstinfo->image_height = info->output_width;
++#endif
+ transpose_critical_parameters(dstinfo);
+ break;
+ default:
++#if JPEG_LIB_VERSION < 70
++ dstinfo->image_width = info->output_width;
++ dstinfo->image_height = info->output_height;
++#endif
+ break;
+ }
+
+@@ -1389,6 +1403,7 @@
+ GETJOCTET(srcinfo->marker_list->data[5]) == 0) {
+ /* Suppress output of JFIF marker */
+ dstinfo->write_JFIF_header = FALSE;
++#if JPEG_LIB_VERSION >= 70
+ /* Adjust Exif image parameters */
+ if (dstinfo->jpeg_width != srcinfo->image_width ||
+ dstinfo->jpeg_height != srcinfo->image_height)
+@@ -1396,6 +1411,7 @@
+ adjust_exif_parameters(srcinfo->marker_list->data + 6,
+ srcinfo->marker_list->data_length - 6,
+ dstinfo->jpeg_width, dstinfo->jpeg_height);
++#endif
+ }
+
+ /* Return the appropriate output data set */
+@@ -1432,7 +1448,7 @@
+ src_coef_arrays, dst_coef_arrays);
+ break;
+ case JXFORM_FLIP_H:
+- if (info->y_crop_offset != 0)
++ if (info->y_crop_offset != 0 || info->slow_hflip)
+ do_flip_h(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset,
+ src_coef_arrays, dst_coef_arrays);
+ else
diff --git a/media-libs/freeimage/files/freeimage-3.18.0-raw.patch b/media-libs/freeimage/files/freeimage-3.18.0-raw.patch
new file mode 100644
index 0000000..44f5666
--- /dev/null
+++ b/media-libs/freeimage/files/freeimage-3.18.0-raw.patch
@@ -0,0 +1,16 @@
+https://bugs.gentoo.org/show_bug.cgi?id=458516
+
+--- FreeImage/Source/FreeImage.h
++++ FreeImage/Source/FreeImage.h
+@@ -141,8 +141,10 @@
+ typedef uint16_t WORD;
+ typedef uint32_t DWORD;
+ typedef int32_t LONG;
++#ifndef _LIBRAW_TYPES_H
+ typedef int64_t INT64;
+ typedef uint64_t UINT64;
++#endif
+ #else
+ // MS is not C99 ISO compliant
+ typedef long BOOL;
+
diff --git a/media-libs/freeimage/files/freeimage-3.18.0-unbundling.patch b/media-libs/freeimage/files/freeimage-3.18.0-unbundling.patch
new file mode 100644
index 0000000..8f76d59
--- /dev/null
+++ b/media-libs/freeimage/files/freeimage-3.18.0-unbundling.patch
@@ -0,0 +1,639 @@
+lots of fixes here:
+ - use system graphics libraries
+ - make all of them optional
+ - drop root users from install (fix user installs)
+ - make static lib build optional
+ - link with CXX and CXXFLAGS (since this is C++ code)
+
+--- a/Makefile.gnu
++++ b/Makefile.gnu
+@@ -11,7 +11,24 @@
+ # Converts cr/lf to just lf
+ DOS2UNIX = dos2unix
+
+-LIBRARIES = -lstdc++
++PKG_CONFIG ?= pkg-config
++
++USE_EXR ?= yes
++USE_JPEG ?= yes
++USE_JPEG2K ?= yes
++USE_MNG ?= yes
++USE_PNG ?= yes
++USE_TIFF ?= yes
++USE_RAW ?= yes
++
++LIBRARIES-yes = $(shell $(PKG_CONFIG) --libs zlib)
++LIBRARIES-$(USE_EXR) += $(shell $(PKG_CONFIG) --libs OpenEXR)
++LIBRARIES-$(USE_JPEG) += -ljpeg
++LIBRARIES-$(USE_JPEG2K) += $(shell $(PKG_CONFIG) --libs libopenjpeg)
++LIBRARIES-$(USE_MNG) += -lmng
++LIBRARIES-$(USE_PNG) += $(shell $(PKG_CONFIG) --libs libpng)
++LIBRARIES-$(USE_TIFF) += $(shell $(PKG_CONFIG) --libs libtiff-4 IlmBase)
++LIBRARIES-$(USE_RAW) += $(shell $(PKG_CONFIG) --libs libraw)
+
+ MODULES = $(SRCS:.c=.o)
+ MODULES := $(MODULES:.cpp=.o)
+@@ -64,13 +81,15 @@
+ $(AR) r $@ $(MODULES)
+
+ $(SHAREDLIB): $(MODULES)
+- $(CC) -s -shared -Wl,-soname,$(VERLIBNAME) $(LDFLAGS) -o $@ $(MODULES) $(LIBRARIES)
++ $(CXX) $(CXXFLAGS) -shared -Wl,-soname,$(VERLIBNAME) $(LDFLAGS) -o $@ $(MODULES) $(LIBRARIES-yes)
+
+ install:
+ install -d $(INCDIR) $(INSTALLDIR)
+- install -m 644 -o root -g root $(HEADER) $(INCDIR)
+- install -m 644 -o root -g root $(STATICLIB) $(INSTALLDIR)
+- install -m 755 -o root -g root $(SHAREDLIB) $(INSTALLDIR)
++ install -m 644 $(HEADER) $(INCDIR)
++ifneq ($(STATICLIB),)
++ install -m 644 $(STATICLIB) $(INSTALLDIR)
++endif
++ install -m 755 $(SHAREDLIB) $(INSTALLDIR)
+ ln -sf $(SHAREDLIB) $(INSTALLDIR)/$(VERLIBNAME)
+ ln -sf $(VERLIBNAME) $(INSTALLDIR)/$(LIBNAME)
+ # ldconfig
+--- a/Source/FreeImage/J2KHelper.cpp
++++ b/Source/FreeImage/J2KHelper.cpp
+@@ -21,7 +21,7 @@
+
+ #include "FreeImage.h"
+ #include "Utilities.h"
+-#include "../LibOpenJPEG/openjpeg.h"
++#include <openjpeg.h>
+ #include "J2KHelper.h"
+
+ // --------------------------------------------------------------------------
+--- a/Source/FreeImage/PluginEXR.cpp
++++ b/Source/FreeImage/PluginEXR.cpp
+@@ -28,16 +28,16 @@
+ #pragma warning (disable : 4800) // ImfVersion.h - 'const int' : forcing value to bool 'true' or 'false' (performance warning)
+ #endif
+
+-#include "../OpenEXR/IlmImf/ImfIO.h"
+-#include "../OpenEXR/Iex/Iex.h"
+-#include "../OpenEXR/IlmImf/ImfOutputFile.h"
+-#include "../OpenEXR/IlmImf/ImfInputFile.h"
+-#include "../OpenEXR/IlmImf/ImfRgbaFile.h"
+-#include "../OpenEXR/IlmImf/ImfChannelList.h"
+-#include "../OpenEXR/IlmImf/ImfRgba.h"
+-#include "../OpenEXR/IlmImf/ImfArray.h"
+-#include "../OpenEXR/IlmImf/ImfPreviewImage.h"
+-#include "../OpenEXR/Half/half.h"
++#include <ImfIO.h>
++#include <Iex.h>
++#include <ImfOutputFile.h>
++#include <ImfInputFile.h>
++#include <ImfRgbaFile.h>
++#include <ImfChannelList.h>
++#include <ImfRgba.h>
++#include <ImfArray.h>
++#include <ImfPreviewImage.h>
++#include <half.h>
+
+
+ // ==========================================================
+--- a/Source/FreeImage/PluginJ2K.cpp
++++ b/Source/FreeImage/PluginJ2K.cpp
+@@ -21,7 +21,7 @@
+
+ #include "FreeImage.h"
+ #include "Utilities.h"
+-#include "../LibOpenJPEG/openjpeg.h"
++#include <openjpeg.h>
+ #include "J2KHelper.h"
+
+ // ==========================================================
+--- a/Source/FreeImage/PluginJP2.cpp
++++ b/Source/FreeImage/PluginJP2.cpp
+@@ -21,7 +21,7 @@
+
+ #include "FreeImage.h"
+ #include "Utilities.h"
+-#include "../LibOpenJPEG/openjpeg.h"
++#include <openjpeg.h>
+ #include "J2KHelper.h"
+
+ // ==========================================================
+--- a/Source/FreeImage/PluginPNG.cpp
++++ b/Source/FreeImage/PluginPNG.cpp
+@@ -37,8 +37,8 @@
+
+ // ----------------------------------------------------------
+
+-#include "../ZLib/zlib.h"
+-#include "../LibPNG/png.h"
++#include <zlib.h>
++#include <png.h>
+
+ // ----------------------------------------------------------
+
+--- a/Source/transupp.c
++++ b/Source/transupp.c
+@@ -15,8 +15,7 @@
+ /* Although this file really shouldn't have access to the library internals,
+ * it's helpful to let it call jround_up() and jcopy_block_row().
+ */
+-#define JPEG_INTERNALS
+-
++#include <jerror.h>
+ #include "jinclude.h"
+ #include "jpeglib.h"
+ #include "transupp.h" /* My own external interface */
+--- a/Source/FreeImage/ZLibInterface.cpp
++++ b/Source/FreeImage/ZLibInterface.cpp
+@@ -19,10 +19,10 @@
+ // Use at your own risk!
+ // ==========================================================
+
+-#include "../ZLib/zlib.h"
++#include <zlib.h>
+ #include "FreeImage.h"
+ #include "Utilities.h"
+-#include "../ZLib/zutil.h" /* must be the last header because of error C3163 in VS2008 (_vsnprintf defined in stdio.h) */
++#define OS_CODE 0x03
+
+ /**
+ Compresses a source buffer into a target buffer, using the ZLib library.
+--- a/Source/FreeImage/PluginG3.cpp
++++ b/Source/FreeImage/PluginG3.cpp
+@@ -20,7 +20,7 @@
+ // Use at your own risk!
+ // ==========================================================
+
+-#include "../LibTIFF4/tiffiop.h"
++#include "tiffiop.h"
+
+ #include "FreeImage.h"
+ #include "Utilities.h"
+--- a/Source/FreeImage/PluginJPEG.cpp
++++ b/Source/FreeImage/PluginJPEG.cpp
+@@ -35,11 +35,15 @@
+ #undef FAR
+ #include <setjmp.h>
+
+-#include "../LibJPEG/jinclude.h"
+-#include "../LibJPEG/jpeglib.h"
+-#include "../LibJPEG/jerror.h"
++#include <string.h>
++#include <stdio.h>
++#include <jconfig.h>
++#include <jpeglib.h>
++#include <jerror.h>
+ }
+
++#define SIZEOF(object) ((size_t) sizeof(object))
++
+ #include "FreeImage.h"
+ #include "Utilities.h"
+
+--- a/Source/FreeImageToolkit/JPEGTransform.cpp
++++ b/Source/FreeImageToolkit/JPEGTransform.cpp
+@@ -25,10 +25,11 @@
+ #undef FAR
+ #include <setjmp.h>
+
+-#include "../LibJPEG/jinclude.h"
+-#include "../LibJPEG/jpeglib.h"
+-#include "../LibJPEG/jerror.h"
+-#include "../LibJPEG/transupp.h"
++#include <string.h>
++#include <stdio.h>
++#include <jpeglib.h>
++#include <jerror.h>
++#include "transupp.h"
+ }
+
+ #include "FreeImage.h"
+--- a/Makefile.fip
++++ b/Makefile.fip
+@@ -11,7 +11,24 @@
+ # Converts cr/lf to just lf
+ DOS2UNIX = dos2unix
+
+-LIBRARIES = -lstdc++
++PKG_CONFIG ?= pkg-config
++
++USE_EXR ?= yes
++USE_JPEG ?= yes
++USE_JPEG2K ?= yes
++USE_MNG ?= yes
++USE_PNG ?= yes
++USE_TIFF ?= yes
++USE_RAW ?= yes
++
++LIBRARIES-yes = $(shell $(PKG_CONFIG) --libs zlib)
++LIBRARIES-$(USE_EXR) += $(shell $(PKG_CONFIG) --libs OpenEXR)
++LIBRARIES-$(USE_JPEG) += -ljpeg
++LIBRARIES-$(USE_JPEG2K) += $(shell $(PKG_CONFIG) --libs libopenjpeg)
++LIBRARIES-$(USE_MNG) += -lmng
++LIBRARIES-$(USE_PNG) += $(shell $(PKG_CONFIG) --libs libpng)
++LIBRARIES-$(USE_TIFF) += $(shell $(PKG_CONFIG) --libs libtiff-4 IlmBase)
++LIBRARIES-$(USE_RAW) += $(shell $(PKG_CONFIG) --libs libraw)
+
+ MODULES = $(SRCS:.c=.o)
+ MODULES := $(MODULES:.cpp=.o)
+@@ -65,14 +82,16 @@
+ $(AR) r $@ $(MODULES)
+
+ $(SHAREDLIB): $(MODULES)
+- $(CC) -s -shared -Wl,-soname,$(VERLIBNAME) $(LDFLAGS) -o $@ $(MODULES) $(LIBRARIES)
++ $(CXX) $(CXXFLAGS) -shared -Wl,-soname,$(VERLIBNAME) $(LDFLAGS) -o $@ $(MODULES) $(LIBRARIES-yes)
+
+ install:
+ install -d $(INCDIR) $(INSTALLDIR)
+- install -m 644 -o root -g root $(HEADER) $(INCDIR)
+- install -m 644 -o root -g root $(HEADERFIP) $(INCDIR)
+- install -m 644 -o root -g root $(STATICLIB) $(INSTALLDIR)
+- install -m 755 -o root -g root $(SHAREDLIB) $(INSTALLDIR)
++ install -m 644 $(HEADER) $(INCDIR)
++ install -m 644 $(HEADERFIP) $(INCDIR)
++ifneq ($(STATICLIB),)
++ install -m 644 $(STATICLIB) $(INSTALLDIR)
++endif
++ install -m 755 $(SHAREDLIB) $(INSTALLDIR)
+ ln -sf $(SHAREDLIB) $(INSTALLDIR)/$(VERLIBNAME)
+ ln -sf $(VERLIBNAME) $(INSTALLDIR)/$(LIBNAME)
+
+--- a/Makefile.srcs
++++ b/Makefile.srcs
+@@ -1,6 +1,14 @@
++USE_EXR ?= yes
++USE_JPEG ?= yes
++USE_JPEG2K ?= yes
++USE_MNG ?= yes
++USE_PNG ?= yes
++USE_TIFF ?= yes
++USE_RAW ?= yes
++
+ VER_MAJOR = 3
+ VER_MINOR = 18.0
+-SRCS = \
++SRCS-yes = \
+ Source/FreeImage/BitmapAccess.cpp \
+ Source/FreeImage/ColorLookup.cpp \
+ Source/FreeImage/ConversionRGBA16.cpp \
+@@ -17,36 +25,74 @@ SRCS = \
+ Source/FreeImage/LFPQuantizer.cpp \
+ Source/FreeImage/MemoryIO.cpp \
+ Source/FreeImage/PixelAccess.cpp \
++
++SRCS-$(USE_JPEG2K) += \
+ Source/FreeImage/J2KHelper.cpp \
++
++SRCS-$(USE_MNG) += \
+ Source/FreeImage/MNGHelper.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/Plugin.cpp \
+ Source/FreeImage/PluginBMP.cpp \
+ Source/FreeImage/PluginCUT.cpp \
+ Source/FreeImage/PluginDDS.cpp \
++
++SRCS-$(USE_EXR) += \
+ Source/FreeImage/PluginEXR.cpp \
++
++SRCS-$(USE_TIFF) += \
+ Source/FreeImage/PluginG3.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/PluginGIF.cpp \
+ Source/FreeImage/PluginHDR.cpp \
+ Source/FreeImage/PluginICO.cpp \
+ Source/FreeImage/PluginIFF.cpp \
++
++SRCS-$(USE_JPEG2K) += \
+ Source/FreeImage/PluginJ2K.cpp \
++
++SRCS-$(USE_MNG) += \
+ Source/FreeImage/PluginJNG.cpp \
++
++SRCS-$(USE_JPEG2K) += \
+ Source/FreeImage/PluginJP2.cpp \
++
++SRCS-$(USE_JPEG) += \
+ Source/FreeImage/PluginJPEG.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/PluginJXR.cpp \
+ Source/FreeImage/PluginKOALA.cpp \
++
++SRCS-$(USE_MNG) += \
+ Source/FreeImage/PluginMNG.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/PluginPCD.cpp \
+ Source/FreeImage/PluginPCX.cpp \
+ Source/FreeImage/PluginPFM.cpp \
+ Source/FreeImage/PluginPICT.cpp \
++
++SRCS-$(USE_PNG) += \
+ Source/FreeImage/PluginPNG.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/PluginPNM.cpp \
+ Source/FreeImage/PluginPSD.cpp \
+ Source/FreeImage/PluginRAS.cpp \
++
++SRCS-$(USE_RAW) += \
+ Source/FreeImage/PluginRAW.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/PluginSGI.cpp \
+ Source/FreeImage/PluginTARGA.cpp \
++
++SRCS-$(USE_TIFF) += \
+ Source/FreeImage/PluginTIFF.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/PluginWBMP.cpp \
+ Source/FreeImage/PluginXBM.cpp \
+ Source/FreeImage/PluginXPM.cpp \
+@@ -83,7 +129,11 @@ SRCS = \
+ Source/Metadata/IPTC.cpp \
+ Source/Metadata/TagConversion.cpp \
+ Source/Metadata/TagLib.cpp \
++
++SRCS-$(USE_TIFF) += \
+ Source/Metadata/XTIFF.cpp \
++
++SRCS-yes += \
+ Source/FreeImageToolkit/Background.cpp \
+ Source/FreeImageToolkit/BSplineRotate.cpp \
+ Source/FreeImageToolkit/Channels.cpp \
+@@ -92,10 +142,18 @@ SRCS = \
+ Source/FreeImageToolkit/CopyPaste.cpp \
+ Source/FreeImageToolkit/Display.cpp \
+ Source/FreeImageToolkit/Flip.cpp \
++
++SRCS-$(USE_JPEG) += \
+ Source/FreeImageToolkit/JPEGTransform.cpp \
++
++SRCS-yes += \
+ Source/FreeImageToolkit/MultigridPoissonSolver.cpp \
+ Source/FreeImageToolkit/Rescale.cpp \
+ Source/FreeImageToolkit/Resize.cpp \
++
++SRCS-$(USE_JPEG) += \
++ Source/transupp.c
++SRCS = $(SRCS-yes)
+ INCLS = \
+ Examples/OpenGL/TextureManager/TextureManager.h \
+ Examples/Plugin/PluginCradle.h \
+@@ -116,7 +174,17 @@
+ Wrapper/FreeImagePlus/test/fipTest.h \
+ TestAPI/TestSuite.h
+
+-INCLUDE = -I. \
++INCLUDE-yes = -I. \
+ -ISource \
+ -ISource/Metadata \
+ -ISource/FreeImageToolkit \
++
++INCLUDE-yes += $(shell $(PKG_CONFIG) --cflags-only-I zlib)
++INCLUDE-$(USE_EXR) += -DUSE_EXR $(shell $(PKG_CONFIG) --cflags-only-I OpenEXR)
++INCLUDE-$(USE_JPEG) += -DUSE_JPEG
++INCLUDE-$(USE_JPEG2K) += -DUSE_JPEG2K $(shell $(PKG_CONFIG) --cflags-only-I libopenjpeg)
++INCLUDE-$(USE_MNG) += -DUSE_MNG
++INCLUDE-$(USE_PNG) += -DUSE_PNG $(shell $(PKG_CONFIG) --cflags-only-I libpng)
++INCLUDE-$(USE_TIFF) += -DUSE_TIFF $(shell $(PKG_CONFIG) --cflags-only-I libtiff-4 IlmBase)
++INCLUDE-$(USE_RAW) += -DUSE_RAW $(shell $(PKG_CONFIG) --cflags-only-I libraw)
++INCLUDE = $(INCLUDE-yes)
+--- a/fipMakefile.srcs
++++ b/fipMakefile.srcs
+@@ -1,6 +1,14 @@
++USE_EXR ?= yes
++USE_JPEG ?= yes
++USE_JPEG2K ?= yes
++USE_MNG ?= yes
++USE_PNG ?= yes
++USE_TIFF ?= yes
++USE_RAW ?= yes
++
+ VER_MAJOR = 3
+ VER_MINOR = 18.0
+-SRCS = \
++SRCS-yes = \
+ Source/FreeImage/BitmapAccess.cpp \
+ Source/FreeImage/ColorLookup.cpp \
+ Source/FreeImage/ConversionRGBA16.cpp \
+@@ -9,36 +17,74 @@
+ Source/FreeImage/LFPQuantizer.cpp \
+ Source/FreeImage/MemoryIO.cpp \
+ Source/FreeImage/PixelAccess.cpp \
++
++SRCS-$(USE_JPEG2K) += \
+ Source/FreeImage/J2KHelper.cpp \
++
++SRCS-$(USE_MNG) += \
+ Source/FreeImage/MNGHelper.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/Plugin.cpp \
+ Source/FreeImage/PluginBMP.cpp \
+ Source/FreeImage/PluginCUT.cpp \
+ Source/FreeImage/PluginDDS.cpp \
++
++SRCS-$(USE_EXR) += \
+ Source/FreeImage/PluginEXR.cpp \
++
++SRCS-$(USE_TIFF) += \
+ Source/FreeImage/PluginG3.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/PluginGIF.cpp \
+ Source/FreeImage/PluginHDR.cpp \
+ Source/FreeImage/PluginICO.cpp \
+ Source/FreeImage/PluginIFF.cpp \
++
++SRCS-$(USE_JPEG2K) += \
+ Source/FreeImage/PluginJ2K.cpp \
++
++SRCS-$(USE_MNG) += \
+ Source/FreeImage/PluginJNG.cpp \
++
++SRCS-$(USE_JPEG2K) += \
+ Source/FreeImage/PluginJP2.cpp \
++
++SRCS-$(USE_JPEG) += \
+ Source/FreeImage/PluginJPEG.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/PluginJXR.cpp \
+ Source/FreeImage/PluginKOALA.cpp \
++
++SRCS-$(USE_MNG) += \
+ Source/FreeImage/PluginMNG.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/PluginPCD.cpp \
+ Source/FreeImage/PluginPCX.cpp \
+ Source/FreeImage/PluginPFM.cpp \
+ Source/FreeImage/PluginPICT.cpp \
++
++SRCS-$(USE_PNG) += \
+ Source/FreeImage/PluginPNG.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/PluginPNM.cpp \
+ Source/FreeImage/PluginPSD.cpp \
+ Source/FreeImage/PluginRAS.cpp \
++
++SRCS-$(USE_RAW) += \
+ Source/FreeImage/PluginRAW.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/PluginSGI.cpp \
+ Source/FreeImage/PluginTARGA.cpp \
++
++SRCS-$(USE_TIFF) += \
+ Source/FreeImage/PluginTIFF.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/PluginWBMP.cpp \
+ Source/FreeImage/PluginXBM.cpp \
+ Source/FreeImage/PluginXPM.cpp \
+@@ -75,7 +121,11 @@
+ Source/Metadata/IPTC.cpp \
+ Source/Metadata/TagConversion.cpp \
+ Source/Metadata/TagLib.cpp \
++
++SRCS-$(USE_TIFF) += \
+ Source/Metadata/XTIFF.cpp \
++
++SRCS-yes += \
+ Source/FreeImageToolkit/Background.cpp \
+ Source/FreeImageToolkit/BSplineRotate.cpp \
+ Source/FreeImageToolkit/Channels.cpp \
+@@ -84,7 +134,11 @@
+ Source/FreeImageToolkit/CopyPaste.cpp \
+ Source/FreeImageToolkit/Display.cpp \
+ Source/FreeImageToolkit/Flip.cpp \
++
++SRCS-$(USE_JPEG) += \
+ Source/FreeImageToolkit/JPEGTransform.cpp \
++
++SRCS-yes += \
+ Source/FreeImageToolkit/MultigridPoissonSolver.cpp \
+ Source/FreeImageToolkit/Rescale.cpp \
+ Source/FreeImageToolkit/Resize.cpp \
+@@ -95,6 +149,11 @@
+ Wrapper/FreeImagePlus/src/fipTag.cpp \
+ Wrapper/FreeImagePlus/src/fipWinImage.cpp \
+ Wrapper/FreeImagePlus/src/FreeImagePlus.cpp
++
++SRCS-$(USE_JPEG) += \
++ Source/transupp.c
++
++SRCS = $(SRCS-yes)
+ INCLUDE = -I. \
+ -ISource \
+ -ISource/Metadata \
+--- a/Source/FreeImage/PluginRAW.cpp
++++ b/Source/FreeImage/PluginRAW.cpp
+@@ -19,7 +19,7 @@
+ // Use at your own risk!
+ // ==========================================================
+
+-#include "../LibRawLite/libraw/libraw.h"
++#include <libraw.h>
+
+ #include "FreeImage.h"
+ #include "Utilities.h"
+--- a/Source/Metadata/XTIFF.cpp
++++ b/Source/Metadata/XTIFF.cpp
+@@ -29,7 +29,7 @@
+ #pragma warning (disable : 4786) // identifier was truncated to 'number' characters
+ #endif
+
+-#include "../LibTIFF4/tiffiop.h"
++#include "tiffiop.h"
+
+ #include "FreeImage.h"
+ #include "Utilities.h"
+--- a/Source/FreeImage/PluginTIFF.cpp
++++ b/Source/FreeImage/PluginTIFF.cpp
+@@ -37,9 +37,9 @@
+
+ #include "FreeImage.h"
+ #include "Utilities.h"
+-#include "../LibTIFF4/tiffiop.h"
++#include "tiffiop.h"
+ #include "../Metadata/FreeImageTag.h"
+-#include "../OpenEXR/Half/half.h"
++#include <half.h>
+
+ #include "FreeImageIO.h"
+ #include "PSDParser.h"
+--- a/Source/tiffiop.h
++++ b/Source/tiffiop.h
+@@ -30,7 +30,9 @@
+ * ``Library-private'' definitions.
+ */
+
+-#include "tif_config.h"
++#include <tiffconf.h>
++#define HAVE_SEARCH_H
++#define HAVE_FCNTL_H
+
+ #ifdef HAVE_FCNTL_H
+ # include <fcntl.h>
+--- a/Source/FreeImage/Plugin.cpp
++++ b/Source/FreeImage/Plugin.cpp
+@@ -223,23 +223,33 @@
+ */
+ s_plugins->AddNode(InitBMP);
+ s_plugins->AddNode(InitICO);
++#ifdef USE_JPEG
+ s_plugins->AddNode(InitJPEG);
++#endif
++#ifdef USE_MNG
+ s_plugins->AddNode(InitJNG);
++#endif
+ s_plugins->AddNode(InitKOALA);
+ s_plugins->AddNode(InitIFF);
++#ifdef USE_MNG
+ s_plugins->AddNode(InitMNG);
++#endif
+ s_plugins->AddNode(InitPNM, NULL, "PBM", "Portable Bitmap (ASCII)", "pbm", "^P1");
+ s_plugins->AddNode(InitPNM, NULL, "PBMRAW", "Portable Bitmap (RAW)", "pbm", "^P4");
+ s_plugins->AddNode(InitPCD);
+ s_plugins->AddNode(InitPCX);
+ s_plugins->AddNode(InitPNM, NULL, "PGM", "Portable Greymap (ASCII)", "pgm", "^P2");
+ s_plugins->AddNode(InitPNM, NULL, "PGMRAW", "Portable Greymap (RAW)", "pgm", "^P5");
++#ifdef USE_PNG
+ s_plugins->AddNode(InitPNG);
++#endif
+ s_plugins->AddNode(InitPNM, NULL, "PPM", "Portable Pixelmap (ASCII)", "ppm", "^P3");
+ s_plugins->AddNode(InitPNM, NULL, "PPMRAW", "Portable Pixelmap (RAW)", "ppm", "^P6");
+ s_plugins->AddNode(InitRAS);
+ s_plugins->AddNode(InitTARGA);
++#ifdef USE_TIFF
+ s_plugins->AddNode(InitTIFF);
++#endif
+ s_plugins->AddNode(InitWBMP);
+ s_plugins->AddNode(InitPSD);
+ s_plugins->AddNode(InitCUT);
+@@ -248,14 +258,22 @@
+ s_plugins->AddNode(InitDDS);
+ s_plugins->AddNode(InitGIF);
+ s_plugins->AddNode(InitHDR);
++#ifdef USE_TIFF
+ s_plugins->AddNode(InitG3);
++#endif
+ s_plugins->AddNode(InitSGI);
++#ifdef USE_EXR
+ s_plugins->AddNode(InitEXR);
++#endif
++#ifdef USE_JPEG2K
+ s_plugins->AddNode(InitJ2K);
+ s_plugins->AddNode(InitJP2);
++#endif
+ s_plugins->AddNode(InitPFM);
+ s_plugins->AddNode(InitPICT);
++#ifdef USE_RAW
+ s_plugins->AddNode(InitRAW);
++#endif
+ s_plugins->AddNode(InitWEBP);
+ #if !(defined(_MSC_VER) && (_MSC_VER <= 1310))
+ s_plugins->AddNode(InitJXR);
diff --git a/media-libs/freeimage/freeimage-3.18.0.ebuild b/media-libs/freeimage/freeimage-3.18.0.ebuild
new file mode 100644
index 0000000..ddaae13
--- /dev/null
+++ b/media-libs/freeimage/freeimage-3.18.0.ebuild
@@ -0,0 +1,112 @@
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+inherit eutils toolchain-funcs
+
+MY_PN=FreeImage
+MY_PV=${PV//.}
+MY_P=${MY_PN}${MY_PV}
+
+DESCRIPTION="Image library supporting many formats"
+HOMEPAGE="http://freeimage.sourceforge.net/"
+SRC_URI="mirror://sourceforge/${PN}/${MY_P}.zip
+ mirror://sourceforge/${PN}/${MY_P}.pdf"
+
+LICENSE="|| ( GPL-2 FIPL-1.0 )"
+SLOT="0"
+KEYWORDS="amd64 ~arm ~arm64 x86 ~amd64-linux ~x86-linux"
+IUSE="jpeg jpeg2k mng openexr png raw static-libs tiff"
+
+# The tiff/ilmbase isn't a typo. The TIFF plugin cheats and
+# uses code from it to handle 16bit<->float conversions.
+RDEPEND="
+ sys-libs/zlib
+ jpeg? ( virtual/jpeg:0 )
+ jpeg2k? ( media-libs/openjpeg:0= )
+ mng? ( media-libs/libmng:= )
+ openexr? ( media-libs/openexr:= )
+ png? ( media-libs/libpng:0= )
+ raw? ( media-libs/libraw:= )
+ tiff? (
+ media-libs/ilmbase:=
+ media-libs/tiff:0
+ )"
+DEPEND="${RDEPEND}
+ virtual/pkgconfig
+ app-arch/unzip"
+
+S=${WORKDIR}/${MY_PN}
+
+DOCS=( "${DISTDIR}"/${MY_P}.pdf README.linux Whatsnew.txt )
+PATCHES=(
+ "${FILESDIR}"/${P}-{unbundling,raw}.patch
+)
+
+src_prepare() {
+ pushd Source >/dev/null || die
+ if has_version ">=media-libs/libjpeg-turbo-1.2.1"; then
+ # Patch from Christian Heimes's fork (thanks)
+ # https://bitbucket.org/tiran/freeimageturbo
+ eapply "${FILESDIR}"/${P}-libjpeg-turbo.patch
+ cp LibJPEG/{jpegcomp.h,jpegint.h} . || die
+ fi
+ cp LibJPEG/{transupp.c,transupp.h,jinclude.h} . || die
+ cp LibTIFF4/{tiffiop,tif_dir}.h . || die
+ rm -rf LibPNG LibMNG LibOpenJPEG ZLib OpenEXR LibRawLite LibTIFF4 LibJPEG || die
+ popd >/dev/null || die
+
+ edos2unix Makefile.{gnu,fip,srcs} fipMakefile.srcs */*.h */*/*.cpp
+ sed -i \
+ -e "s:/./:/:g" \
+ -e "s: ./: :g" \
+ -e 's: Source: \\\n\tSource:g' \
+ -e 's: Wrapper: \\\n\tWrapper:g' \
+ -e 's: Examples: \\\n\tExamples:g' \
+ -e 's: TestAPI: \\\n\tTestAPI:g' \
+ -e 's: -ISource: \\\n\t-ISource:g' \
+ -e 's: -IWrapper: \\\n\t-IWrapper:g' \
+ Makefile.srcs fipMakefile.srcs || die
+ sed -i \
+ -e "/LibJPEG/d" \
+ -e "/LibPNG/d" \
+ -e "/LibTIFF/d" \
+ -e "/Source\/ZLib/d" \
+ -e "/LibOpenJPEG/d" \
+ -e "/OpenEXR/d" \
+ -e "/LibRawLite/d" \
+ -e "/LibMNG/d" \
+ Makefile.srcs fipMakefile.srcs || die
+
+ default
+}
+
+foreach_make() {
+ local m
+ for m in Makefile.{gnu,fip} ; do
+ emake -f ${m} \
+ USE_EXR=$(usex openexr) \
+ USE_JPEG=$(usex jpeg) \
+ USE_JPEG2K=$(usex jpeg2k) \
+ USE_MNG=$(usex mng) \
+ USE_PNG=$(usex png) \
+ USE_TIFF=$(usex tiff) \
+ USE_RAW=$(usex raw) \
+ $(usex static-libs '' STATICLIB=) \
+ "$@"
+ done
+}
+
+src_compile() {
+ tc-export AR PKG_CONFIG
+ foreach_make \
+ CXX="$(tc-getCXX) -fPIC" \
+ CC="$(tc-getCC) -fPIC" \
+ ${MY_PN}
+}
+
+src_install() {
+ foreach_make install DESTDIR="${ED}" INSTALLDIR="${ED%/}"/usr/$(get_libdir)
+ einstalldocs
+}
diff --git a/media-libs/freeimage/metadata.xml b/media-libs/freeimage/metadata.xml
new file mode 100644
index 0000000..fec6409
--- /dev/null
+++ b/media-libs/freeimage/metadata.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="project">
+ <email>games@gentoo.org</email>
+ <name>Gentoo Games Project</name>
+ </maintainer>
+ <upstream>
+ <remote-id type="sourceforge">freeimage</remote-id>
+ </upstream>
+</pkgmetadata>