📄 cimg.h
字号:
/*
#
# File : CImg.h
#
# Description : The C++ Template Image Processing Library
# ( http://cimg.sourceforge.net )
#
# Copyright : David Tschumperle
# ( http://www.greyc.ensicaen.fr/~dtschump/ )
#
# This software is governed by the CeCILL 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
# license 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 license and that you accept its terms.
#
*/
// Summary for YARP
// CopyPolicy: CeCILL license (use, modify, redistribute)
// Copyright: David Tschumperle
#ifndef cimg_version
#define cimg_version 1.14
// Avoid strange warning messages on Visual C++ express 2005.
#if ( defined(_MSC_VER) && _MSC_VER>=1400 )
#define _CRT_SECURE_NO_DEPRECATE 1
#define _CRT_NONSTDC_NO_DEPRECATE 1
#endif
// Standard C++ includes
#include <cstdio>
#include <cstdlib>
#include <cstdarg>
#include <cstring>
#include <cmath>
#include <ctime>
// Overcome VisualC++ 6.0 and DMC compilers namespace 'std::' bug
#if ( defined(_MSC_VER) && _MSC_VER<=1200 ) || defined(__DMC__)
#define std
#endif
/*
#
# Set CImg configuration flags.
#
# If compilation flags are not adapted to your system,
# you may override their values, before including
# the header file "CImg.h" (use the #define directive).
#
*/
// Try to detect the current system and set value of 'cimg_OS'.
#ifndef cimg_OS
#if defined(sun) || defined(__sun) || defined(linux) || defined(__linux) \
|| defined(__linux__) || defined(__CYGWIN__) || defined(BSD) || defined(__FreeBSD__) \
|| defined(__OPENBSD__) || defined(__MACOSX__) || defined(__APPLE__) || defined(sgi) \
|| defined(__sgi)
// Unix-like (Linux, Solaris, BSD, Irix,...)
#define cimg_OS 1
#ifndef cimg_display_type
#define cimg_display_type 1
#endif
#ifndef cimg_color_terminal
#define cimg_color_terminal
#endif
#elif defined(_WIN32) || defined(__WIN32__)
// Windows
#define cimg_OS 2
#ifndef cimg_display_type
#define cimg_display_type 2
#endif
#else
// Unknown configuration : will compile with minimal dependencies.
#define cimg_OS 0
#ifndef cimg_display_type
#define cimg_display_type 0
#endif
#endif
#endif
// Debug configuration.
//
// Define 'cimg_debug' to : 0 to remove dynamic debug messages (exceptions are still thrown)
// 1 to display dynamic debug messages (default behavior).
// 2 to add memory access controls (may slow down the code, but display extra warning messages)
#ifndef cimg_debug
#define cimg_debug 1
#endif
// Architecture-dependent includes.
#if cimg_OS==1
#include <sys/time.h>
#include <unistd.h>
#elif cimg_OS==2
#include <windows.h>
// Discard unuseful macros in windows.h
// to allow compilation with VC++ 6.0.
#ifdef min
#undef min
#undef max
#undef abs
#endif
#endif
#if cimg_display_type==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
#endif
// Configuration for native PNG and JPEG support
// Define 'cimg_use_png' or 'cimg_use_jpeg' to enable native PNG or JPEG files support.
// This requires you link your code with the zlib/png or jpeg libraries.
// Without these libraries, PNG and JPEG support will be done by the Image Magick's 'convert' tool, if installed
// (this is the case on most unix plateforms).
#ifdef cimg_use_png
extern "C" {
#include "png.h"
}
#endif
#ifdef cimg_use_jpeg
extern "C" {
#include "jpeglib.h"
}
#endif
/*
#
#
# Define some useful macros. Macros of the CImg Library are prefixed by 'cimg_'
# Documented macros below may be safely used in your own code
# (particularly useful for option parsing, image loops and neighborhoods).
#
#
*/
// Macros used to describe the program usage, and retrieve command line arguments
// (See corresponding module 'Retrieving command line arguments' in the generated documentation).
#define cimg_usage(usage) cimg_library::cimg::option((const char*)0,argc,argv,(const char*)0,usage)
#define cimg_option(name,defaut,usage) cimg_library::cimg::option(name,argc,argv,defaut,usage)
// Macros used for neighborhood definitions and manipulations.
// (see module 'Using Image Loops' in the generated documentation).
#define CImg_2x2x1(I,T) T I##cc,I##nc=0,I##cn,I##nn=0
#define CImg_3x1x1(I,T) T I##pp,I##cp,I##np=0
#define CImg_3x3x1(I,T) T I##pp,I##cp,I##np=0,I##pc,I##cc,I##nc=0,I##pn,I##cn,I##nn=0
#define CImg_4x1x1(I,T) T I##pp,I##cp,I##np=0,I##ap=0
#define CImg_4x4x1(I,T) T I##pp,I##cp,I##np=0,I##ap=0, \
I##pc,I##cc,I##nc=0,I##ac=0, \
I##pn,I##cn,I##nn=0,I##an=0, \
I##pa,I##ca,I##na=0,I##aa=0
#define CImg_5x1x1(I,T) T I##bb,I##pb,I##cb,I##nb=0,I##ab=0
#define CImg_5x5x1(I,T) T I##bb,I##pb,I##cb,I##nb=0,I##ab=0, \
I##bp,I##pp,I##cp,I##np=0,I##ap=0, \
I##bc,I##pc,I##cc,I##nc=0,I##ac=0, \
I##bn,I##pn,I##cn,I##nn=0,I##an=0, \
I##ba,I##pa,I##ca,I##na=0,I##aa=0
#define CImg_2x2x2(I,T) T I##ccc,I##ncc=0,I##cnc,I##nnc=0, \
I##ccn,I##ncn=0,I##cnn,I##nnn=0
#define CImg_3x3x3(I,T) T I##ppp,I##cpp,I##npp=0,I##pcp,I##ccp,I##ncp=0,I##pnp,I##cnp,I##nnp=0, \
I##ppc,I##cpc,I##npc=0,I##pcc,I##ccc,I##ncc=0,I##pnc,I##cnc,I##nnc=0, \
I##ppn,I##cpn,I##npn=0,I##pcn,I##ccn,I##ncn=0,I##pnn,I##cnn,I##nnn=0
#define CImg_2x2x1_ref(I,T,tab) T &I##cc=(tab)[0],&I##nc=(tab)[1],&I##cn=(tab)[2],&I##nn=(tab)[3]
#define CImg_3x3x1_ref(I,T,tab) T &I##pp=(tab)[0],&I##cp=(tab)[1],&I##np=(tab)[2], \
&I##pc=(tab)[3],&I##cc=(tab)[4],&I##nc=(tab)[5], \
&I##pn=(tab)[6],&I##cn=(tab)[7],&I##nn=(tab)[8]
#define CImg_4x4x1_ref(I,T,tab) T &I##pp=(tab)[0],&I##cp=(tab)[1],&I##np=(tab)[2],&I##ap=(tab)[3], \
&I##pc=(tab)[4],&I##cc=(tab)[5],&I##nc=(tab)[6],&I##ap=(tab)[7], \
&I##pn=(tab)[8],&I##cn=(tab)[9],&I##nn=(tab)[10],&I##aa=(tab)[11], \
&I##pa=(tab)[12],&I##ca=(tab)[13],&I##na=(tab)[14],&I##aa=(tab)[15]
#define CImg_5x5x1_ref(I,T,tab) T &I##bb=(tab)[0],&I##pb=(tab)[1],&I##cb=(tab)[2],&I##nb=(tab)[3],&I##ab=(tab)[4], \
&I##bp=(tab)[5],&I##pp=(tab)[6],&I##cp=(tab)[7],&I##np=(tab)[8],&I##ap=(tab)[9], \
&I##bc=(tab)[10],&I##pc=(tab)[11],&I##cc=(tab)[12],&I##nc=(tab)[13],&I##ac=(tab)[14], \
&I##bn=(tab)[15],&I##pn=(tab)[16],&I##cn=(tab)[17],&I##nn=(tab)[18],&I##an=(tab)[19], \
&I##ba=(tab)[20],&I##pa=(tab)[21],&I##ca=(tab)[22],&I##na=(tab)[23],&I##aa=(tab)[24]
#define CImg_2x2x2_ref(I,T,tab) T &I##ccc=(tab)[0],&I##ncc=(tab)[1],&I##cnc=(tab)[2],&I##nnc=(tab)[3], \
&I##ccn=(tab)[4],&I##ncn=(tab)[5],&I##cnn=(tab)[6],&I##nnn=(tab)[7]
#define CImg_3x3x3_ref(I,T,tab) T &I##ppp=(tab)[0],&I##cpp=(tab)[1],&I##npp=(tab)[2], \
&I##pcp=(tab)[3],&I##ccp=(tab)[4],&I##ncp=(tab)[5], \
&I##pnp=(tab)[6],&I##cnp=(tab)[7],&I##nnp=(tab)[8], \
&I##ppc=(tab)[9],&I##cpc=(tab)[10],&I##npc=(tab)[11], \
&I##pcc=(tab)[12],&I##ccc=(tab)[13],&I##ncc=(tab)[14], \
&I##pnc=(tab)[15],&I##cnc=(tab)[16],&I##nnc=(tab)[17], \
&I##ppn=(tab)[18],&I##cpn=(tab)[19],&I##npn=(tab)[20], \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -