PTdecode/CImg-1.3.0/plugins/add_fileformat.h

changeset 5
1204ebf9340d
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/PTdecode/CImg-1.3.0/plugins/add_fileformat.h	Mon Aug 03 14:09:20 2009 +0100
     1.3 @@ -0,0 +1,79 @@
     1.4 +/*
     1.5 + #
     1.6 + #  File        : add_fileformat.h
     1.7 + #                ( C++ header file - CImg plug-in )
     1.8 + #
     1.9 + #  Description : CImg plug-in that adds loading/saving support for a personalized
    1.10 + #                file format (determined by its extension, here ".foo").
    1.11 + #                This file is a part of the CImg Library project.
    1.12 + #                ( http://cimg.sourceforge.net )
    1.13 + #
    1.14 + #  Copyright   : David Tschumperle
    1.15 + #                ( http://www.greyc.ensicaen.fr/~dtschump/ )
    1.16 + #
    1.17 + #  License     : CeCILL v2.0
    1.18 + #                ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
    1.19 + #
    1.20 + #  This software is governed by the CeCILL  license under French law and
    1.21 + #  abiding by the rules of distribution of free software.  You can  use,
    1.22 + #  modify and/ or redistribute the software under the terms of the CeCILL
    1.23 + #  license as circulated by CEA, CNRS and INRIA at the following URL
    1.24 + #  "http://www.cecill.info".
    1.25 + #
    1.26 + #  As a counterpart to the access to the source code and  rights to copy,
    1.27 + #  modify and redistribute granted by the license, users are provided only
    1.28 + #  with a limited warranty  and the software's author,  the holder of the
    1.29 + #  economic rights,  and the successive licensors  have only  limited
    1.30 + #  liability.
    1.31 + #
    1.32 + #  In this respect, the user's attention is drawn to the risks associated
    1.33 + #  with loading,  using,  modifying and/or developing or reproducing the
    1.34 + #  software by the user in light of its specific status of free software,
    1.35 + #  that may mean  that it is complicated to manipulate,  and  that  also
    1.36 + #  therefore means  that it is reserved for developers  and  experienced
    1.37 + #  professionals having in-depth computer knowledge. Users are therefore
    1.38 + #  encouraged to load and test the software's suitability as regards their
    1.39 + #  requirements in conditions enabling the security of their systems and/or
    1.40 + #  data to be ensured and,  more generally, to use and operate it in the
    1.41 + #  same conditions as regards security.
    1.42 + #
    1.43 + #  The fact that you are presently reading this means that you have had
    1.44 + #  knowledge of the CeCILL license and that you accept its terms.
    1.45 + #
    1.46 +*/
    1.47 +
    1.48 +#ifndef cimg_plugin_addfileformat
    1.49 +#define cimg_plugin_addfileformat
    1.50 +
    1.51 +// These functions load ".foo" filenames
    1.52 +//---------------------------------------
    1.53 +static CImg<T> get_load_foo(const char *filename) {
    1.54 +  std::fprintf(stderr,"Load '%s' here..\n",filename);
    1.55 +  return CImg<T>(512,512,1,3,0).noise(30);
    1.56 +}
    1.57 +
    1.58 +CImg& load_foo(const char *filename) {
    1.59 +  return get_load_foo(filename).swap(*this);
    1.60 +}
    1.61 +
    1.62 +// This function saves the instance image into a ".foo" file.
    1.63 +//-----------------------------------------------------------
    1.64 +const CImg& save_foo(const char *filename) const {
    1.65 +  std::fprintf(stderr,"Save '%s' here..\n",filename);
    1.66 +  return *this;
    1.67 +}
    1.68 +
    1.69 +// The code below allows to add the support for the specified extension.
    1.70 +//---------------------------------------------------------------------
    1.71 +#ifndef cimg_load_plugin
    1.72 +#define cimg_load_plugin(filename) \
    1.73 +  if (!cimg::strncasecmp(cimg::split_filename(filename),"foo",3)) return load_foo(filename);
    1.74 +#endif
    1.75 +#ifndef cimg_save_plugin
    1.76 +#define cimg_save_plugin(filename) \
    1.77 +  if (!cimg::strncasecmp(cimg::split_filename(filename),"foo",3)) return save_foo(filename);
    1.78 +#endif
    1.79 +
    1.80 +// End of the plugin.
    1.81 +//-------------------
    1.82 +#endif