PTdecode/CImg-1.3.0/examples/gmic.h

Wed, 05 Aug 2009 15:00:54 +0100

author
Philip Pemberton <philpem@philpem.me.uk>
date
Wed, 05 Aug 2009 15:00:54 +0100
changeset 12
96e1df9bd27c
parent 5
1204ebf9340d
permissions
-rwxr-xr-x

small changes to hexdump code to stop a gcc warning on platforms where sizeof(int) != sizeof(int*) e.g. x86_64

     1 /*
     2   #
     3   #  File        : gmic.h
     4   #                ( C++ header file )
     5   #
     6   #  Description : GREYC's Magic Image Converter
     7   #                ( http://gmic.sourceforge.net )
     8   #                This file is a part of the CImg Library project.
     9   #                ( http://cimg.sourceforge.net )
    10   #
    11   #  Note        : This file cannot be compiled on VC++ 6.
    12   #
    13   #  Copyright   : David Tschumperle
    14   #                ( http://www.greyc.ensicaen.fr/~dtschump/ )
    15   #
    16   #  License     : CeCILL v2.0
    17   #                ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
    18   #
    19   #  This software is governed by the CeCILL  license under French law and
    20   #  abiding by the rules of distribution of free software.  You can  use,
    21   #  modify and/ or redistribute the software under the terms of the CeCILL
    22   #  license as circulated by CEA, CNRS and INRIA at the following URL
    23   #  "http://www.cecill.info".
    24   #
    25   #  As a counterpart to the access to the source code and  rights to copy,
    26   #  modify and redistribute granted by the license, users are provided only
    27   #  with a limited warranty  and the software's author,  the holder of the
    28   #  economic rights,  and the successive licensors  have only  limited
    29   #  liability.
    30   #
    31   #  In this respect, the user's attention is drawn to the risks associated
    32   #  with loading,  using,  modifying and/or developing or reproducing the
    33   #  software by the user in light of its specific status of free software,
    34   #  that may mean  that it is complicated to manipulate,  and  that  also
    35   #  therefore means  that it is reserved for developers  and  experienced
    36   #  professionals having in-depth computer knowledge. Users are therefore
    37   #  encouraged to load and test the software's suitability as regards their
    38   #  requirements in conditions enabling the security of their systems and/or
    39   #  data to be ensured and,  more generally, to use and operate it in the
    40   #  same conditions as regards security.
    41   #
    42   #  The fact that you are presently reading this means that you have had
    43   #  knowledge of the CeCILL license and that you accept its terms.
    44   #
    45 */
    47 #ifndef gmic_version
    48 #include "CImg.h"
    49 #define gmic_version 1304
    51 // The lines below are necessary when using a non-standard compiler such as visualcpp6.
    52 #ifdef cimg_use_visualcpp6
    53 #define std
    54 #endif
    55 #ifdef min
    56 #undef min
    57 #undef max
    58 #endif
    60 // Define G'MIC Exception class.
    61 //------------------------------
    62 struct gmic_exception {
    63   char message[4096];
    64   gmic_exception();
    65   gmic_exception(const char *format, ...);
    66   gmic_exception(const char *format, std::va_list ap);
    67 };
    69 // Define G'MIC interpreter class.
    70 //--------------------------------
    71 struct gmic {
    73   // Internal variables.
    74   cimg_library::CImgList<char> command_line, filenames, macros, commands;
    75   cimg_library::CImgList<int> dowhile, repeatdone;
    76   bool is_released, is_debug, is_fullpath, is_begin, is_oriented3d;
    77   int verbosity_level, render3d, renderd3d;
    78   float focale3d, light3d_x, light3d_y, light3d_z, specular_light3d, specular_shine3d;
    79   unsigned char background3d[3];
    80   unsigned int position;
    82   // Constructors - Destructors.
    83   gmic();
    84   template<typename T> gmic(const int argc, const char *const *const argv, cimg_library::CImgList<T>& images,
    85                             const char *const custom_macros=0, const bool add_macros_at_start=true);
    86   template<typename T> gmic(const char *const command, cimg_library::CImgList<T>& images,
    87                             const char *const custom_macros=0, const bool add_macros_at_start=true);
    88   gmic& assign(const unsigned int size, const char *const custom_macros=0,
    89                const bool add_macros_at_start=true);
    91   // Messages procedures.
    92   const gmic& error(const char *format, ...) const;
    93   const gmic& warning(const char *format, ...) const;
    94   const gmic& debug(const char *format, ...) const;
    95   const gmic& print(const char *format, ...) const;
    97   // Add macros.
    98   gmic& add_macros(const char *const data_macros, const unsigned int data_size, const bool add_macros_at_start=true);
    99   gmic& add_macros(std::FILE *const file, const bool add_macros_at_start=true);
   101   // Return indices of the images from a string.
   102   cimg_library::CImg<unsigned int> indices2cimg(const char *const string, const unsigned int indice_max,
   103                                                 const char *const command) const;
   105   // Return stringified version of indices or filenames.
   106   char* indices2string(const cimg_library::CImg<unsigned int>& indices, const bool display_indices) const;
   108   // Display image data.
   109   template<typename T>
   110   bool display_images(const cimg_library::CImgList<T>& images, const cimg_library::CImg<unsigned int>& indices,
   111                       const bool verbose) const;
   112   template<typename T>
   113   bool display_objects3d(const cimg_library::CImgList<T>& images, const cimg_library::CImg<unsigned int>& indices,
   114                          const bool verbose) const;
   115   template<typename T>
   116   bool display_plots(const cimg_library::CImgList<T>& images, const cimg_library::CImg<unsigned int>& indices,
   117                      const unsigned int plot_type, const unsigned int vertex_type,
   118                      const double xmin, const double xmax,
   119                      const double ymin, const double ymax,
   120                      const bool verbose) const;
   122   // Substitute '@' expressions.
   123   template<typename T>
   124   cimg_library::CImg<char> substitute_arobace(const char *const argument, const cimg_library::CImgList<T>& images) const;
   126   // Main parsing procedure.
   127   template<typename T>
   128   gmic& parse(cimg_library::CImgList<T> &images);
   129   gmic& parse_bool(cimg_library::CImgList<bool>& images);
   130   gmic& parse_uchar(cimg_library::CImgList<unsigned char>& images);
   131   gmic& parse_char(cimg_library::CImgList<char>& images);
   132   gmic& parse_ushort(cimg_library::CImgList<unsigned short>& images);
   133   gmic& parse_short(cimg_library::CImgList<short>& images);
   134   gmic& parse_uint(cimg_library::CImgList<unsigned int>& images);
   135   gmic& parse_int(cimg_library::CImgList<int>& images);
   136   gmic& parse_float(cimg_library::CImgList<float>& images);
   137   gmic& parse_double(cimg_library::CImgList<double>& images);
   139 }; // End of the 'gmic' class.
   141 #endif
   143 // Local Variables:
   144 // mode: c++
   145 // End: