/*
#
# File : CImg.h
# ( C++ header file )
#
# Description : The C++ Template Image Processing Toolkit.
# This file is the main component of the CImg Library project.
# ( http://cimg.sourceforge.net )
#
# Project manager : David Tschumperle.
# ( http://www.greyc.ensicaen.fr/~dtschump/ )
#
# The complete list of contributors is available in file 'README.txt'.
#
# Licenses : This file is 'dual-licensed', you have to choose one
# of the two licenses below to apply.
#
# CeCILL-C
# The CeCILL-C license is close to the GNU LGPL.
# ( http://www.cecill.info/licences/Licence_CeCILL-C_V1-en.html )
#
# or CeCILL v2.0
# The CeCILL license is compatible with the GNU GPL.
# ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
#
# This software is governed either by the CeCILL or the CeCILL-C license
# under French law and abiding by the rules of distribution of free software.
# You can use, modify and or redistribute the software under the terms of
# the CeCILL or CeCILL-C licenses as circulated by CEA, CNRS and INRIA
# at the following URL : "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL and CeCILL-C licenses and that you accept its terms.
#
*/
// Define version number of the library file.
#ifndef cimg_version
#define cimg_version 132
/*-----------------------------------------------------------
#
# Test and auto-set CImg configuration variables
# and include required headers.
#
# If you find that default configuration variables are
# not adapted to your case, you can override their values
# before including the header file "CImg.h"
# (use the #define directive).
#
------------------------------------------------------------*/
// Include required standard C++ headers.
#include <cstdio>
#include <cstdlib>
#include <cstdarg>
#include <cstring>
#include <cmath>
#include <ctime>
// Operating system configuration.
//
// Define 'cimg_OS' to : '0' for an unknown OS (will try to minize library dependancies).
// '1' for a Unix-like OS (Linux, Solaris, BSD, MacOSX, Irix, ...).
// '2' for Microsoft Windows.
// (autodetection is done by default).
#ifndef cimg_OS
#if defined(unix) || defined(__unix) || defined(__unix__) \
|| defined(linux) || defined(__linux) || defined(__linux__) \
|| defined(sun) || defined(__sun) \
|| defined(BSD) || defined(__OpenBSD__) || defined(__NetBSD__) \
|| defined(__FreeBSD__) || defined __DragonFly__ \
|| defined(sgi) || defined(__sgi) \
|| defined(__MACOSX__) || defined(__APPLE__) \
|| defined(__CYGWIN__)
#define cimg_OS 1
#elif defined(_MSC_VER) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) \
|| defined(WIN64) || defined(_WIN64) || defined(__WIN64__)
#define cimg_OS 2
#else
#define cimg_OS 0
#endif
#elif !(cimg_OS==0 || cimg_OS==1 || cimg_OS==2)
#error CImg Library : Configuration variable 'cimg_OS' is badly defined.
#error (valid values are '0 = unknown OS', '1 = Unix-like OS', '2 = Microsoft Windows').
#endif
// Disable silly warnings on Microsoft VC++ compilers.
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4311)
#pragma warning(disable:4312)
#pragma warning(disable:4800)
#pragma warning(disable:4804)
#pragma warning(disable:4996)
#define _CRT_SECURE_NO_DEPRECATE 1
#define _CRT_NONSTDC_NO_DEPRECATE 1
#endif
// Include OS-specific headers for system management.
#if cimg_OS==1
#include <sys/time.h>
#include <unistd.h>
#elif cimg_OS==2
#include <windows.h>
#ifndef _WIN32_IE
#define _WIN32_IE 0x0400
#endif
#include <shlobj.h>
#endif
// Filename separator configuration.
//
// Default separator is '/' for Unix-based OS, and '\' or Windows.
#ifndef cimg_file_separator
#if cimg_OS==2
#define cimg_file_separator '\\'
#else
#define cimg_file_separator '/'
#endif
#endif
// Output messages verbosity configuration.
//
// Define 'cimg_verbosity' to : '0' to hide library messages (quiet mode).
// '1' to print library messages on the console.
// '2' to display library messages on a dialog window (default behavior).
// '3' to do as '1' + add extra warnings (may slow down the code !).
// '4' to do as '2' + add extra warnings (may slow down the code !).
//
// Define 'cimg_strict_warnings' to replace warning messages by exception throwns.
//
// Define 'cimg_use_vt100' to allow output of color messages (require VT100-compatible terminal).
#ifndef cimg_verbosity
#define cimg_verbosity 2
#elif !(cimg_verbosity==0 || cimg_verbosity==1 || cimg_verbosity==2 || cimg_verbosity==3 || cimg_verbosity==4)
#error CImg Library : Configuration variable 'cimg_verbosity' is badly defined.
#error (valid values are '0 = quiet', '1 = console', '2 = dialog', '3 = console+warnings', '4 = dialog+warnings').
#endif
// Display framework configuration.
//
// Define 'cimg_display' to : '0' to disable display capabilities.
// '1' to use X-Window framework (X11).
// '2' to use Microsoft GDI32 framework.
// '3' to use Apple Carbon framework (still experimental!).
#ifndef cimg_display
#if cimg_OS==0
#define cimg_display 0
#elif cimg_OS==1
#if defined(__MACOSX__) || defined(__APPLE__)
#define cimg_display 1
#else
#define cimg_display 1
#endif
#elif cimg_OS==2
#define cimg_display 2
#endif
#elif !(cimg_display==0 || cimg_display==1 || cimg_display==2 || cimg_display==3)
#error CImg Library : Configuration variable 'cimg_display' is badly defined.
#error (valid values are '0 = disable', '1 = X-Window (X11)', '2 = Microsoft GDI32', '3 = Apple Carbon').
#endif
// Include display-specific headers.
#if cimg_display==1
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <pthread.h>
#ifdef cimg_use_xshm
#include <sys/ipc.h>
#include <sys/shm.h>
#include <X11/extensions/XShm.h>
#endif
#ifdef cimg_use_xrandr
#include <X11/extensions/Xrandr.h>
#endif
#elif cimg_display==3
#include <Carbon/Carbon.h>
#include <pthread.h>
#endif
// OpenMP configuration.
// (http://www.openmp.org)
//
// Define 'cimg_use_openmp' to enable OpenMP support.
//
// OpenMP directives can be used in few CImg functions to get
// advantages of multi-core CPUs. Using OpenMP is not mandatory.
#ifdef cimg_use_openmp
#include "omp.h"
#endif
// LibPNG configuration.
// (http://www.libpng.org)
//
// Define 'cimg_use_png' to enable LibPNG support.
//
// LibPNG can be used in functions 'CImg<T>::{load,save}_png()'
// to get a builtin support of PNG files. Using Li