📄 cimg.3h
字号:
/*------------------------------------------------------------------------------------------------------ File : CImg.h Description : The C++ Template Image Processing Library ( http://cimg.sourceforge.net ) Author : 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. ----------------------------------------------------------------------------------------------------*/#ifndef cimg_version#define cimg_version 1.08#include <cstdio>#include <cstdlib>#include <cstdarg>#include <cmath>#include <cstring>#include <ctime>// Overcome VisualC++ 6.0 and DMC compilers namespace 'std::' bug#if ( defined(_MSC_VER) && _MSC_VER<=1200 ) || defined(__DMC__)#define std#endif/*------------------------------------------------------------- Auto-detect and set CImg Library 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). -------------------------------------------------------------*/#ifndef cimg_OS#if defined(sun) || defined(__sun) // Sun Unix#define cimg_OS 0#ifndef cimg_display_type#define cimg_display_type 1#endif#ifndef cimg_color_terminal#define cimg_color_terminal#endif#elif defined(linux) || defined(__linux) || defined(__CYGWIN__) || defined(__FreeBSD__)// PC Unix (including Linux and FreeBSD)#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__)// PC Windows#define cimg_OS 2#ifndef cimg_display_type#define cimg_display_type 2#endif#elif defined(__MACOSX__) || defined(__APPLE__)// Mac OS X#define cimg_OS 3#ifndef cimg_display_type#define cimg_display_type 1#endif#else// Unknown configuration : compile without dependencies.#define cimg_OS -1#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 extra memory access controls (may slow down the code)#ifndef cimg_debug#define cimg_debug 1#endif// Architecture-dependent includes//---------------------------------#if cimg_OS!=2#include <sys/time.h>#include <unistd.h>#else#include <windows.h>// Discard unuseful macros in windows.h#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>#endif/*----------------------------------------------------------------------------------- Define some macros. Macros of the CImg Library are prefixed by 'cimg_' Documented macros below may be safely used in your own code. ---------------------------------------------------------------------------------*/// 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((char*)NULL,(unsigned int)argc,(char**)argv,(char*)NULL,(char*)usage)#define cimg_option(name,defaut,usage) cimg_library::cimg::option((char*)name,(unsigned int)argc,(char**)argv,defaut,(char*)usage)// Macros used for dynamic debug messages. Shouldn't be used in your own source code.#define cimg_test(x,func) \ if(!(x).width || !(x).height || !(x).depth || !(x).dim || !(x).data) \ throw CImgInstanceException("(Instance error) : In function '%s()' ('%s', line %d), CImg<%s> %s = (%d,%d,%d,%d,%p) is empty", \ func,__FILE__,__LINE__,(x).pixel_type(),#x,(x).width,(x).height,(x).depth,(x).dim,(x).data)#define cimgl_test(x,func) \ if(!(x).size || !(x).data) \ throw CImgInstanceException("(Instance error) : In function '%s()' ('%s', line %d), CImgl<%s> %s = (%d,%p) is empty", \ func,__FILE__,__LINE__,(x).pixel_type(),#x,(x).size,(x).data)#define cimg_test_scalar(x,func) \ if(!(x).width || !(x).height || !(x).depth || (x).dim!=1 || !(x).data) \ throw CImgInstanceException("(Instance error) : In function '%s()' ('%s', line %d), CImg<%s> %s = (%d,%d,%d,%d,%p) is not scalar", \ func,__FILE__,__LINE__,(x).pixel_type(),#x,(x).width,(x).height,(x).depth,(x).dim,(x).data)#define cimg_test_matrix(x,func) \ if(!(x).width || !(x).height || (x).depth!=1 || (x).dim!=1 || !(x).data) \ throw CImgInstanceException("(Instance error) : In function '%s()' ('%s', line %d), CImg<%s> %s = (%d,%d,%d,%d,%p) is not a matrix", \ func,__FILE__,__LINE__,(x).pixel_type(),#x,(x).width,(x).height,(x).depth,(x).dim,(x).data)#define cimg_test_square(x,func) \ if(!(x).width || !(x).height || (x).depth!=1 || (x).dim!=1 || (x).width!=(x).height || !(x).data) \ throw CImgInstanceException("(Instance error) : In function '%s()' ('%s', line %d), CImg<%s> %s = (%d,%d,%d,%d,%p) is not a square matrix", \ func,__FILE__,__LINE__,(x).pixel_type,#x,(x).width,(x).height,(x).depth,(x).dim,(x).data)#define cimg_test_display(x,func) \ if (!(x).width || !(x).height) \ throw CImgInstanceException("(Instance error) : In function '%s()' ('%s', l.%d), CImgDisplay %s = (%d,%d) is not a valid display", \ func,__FILE__,__LINE__,#x,(x).width,(x).height) // Macros used for neighborhood definitions and manipulations (see module 'Using Image Loops' in the generated documentation).#define CImg_2x2(I,T) T I##cc,I##nc=0,I##cn,I##nn=0#define CImg_3x3(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_4x4(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_5x5(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_2x2_ref(I,T,tab) T &I##cc=(tab)[0],&I##nc=(tab)[1],&I##cn=(tab)[2],&I##nn=(tab)[3];#define CImg_3x3_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_4x4_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_5x5_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], \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -