PTdecode/CImg-1.3.0/plugins/add_fileformat.h

Tue, 18 Mar 2014 01:27:15 +0000

author
Philip Pemberton <philpem@philpem.me.uk>
date
Tue, 18 Mar 2014 01:27:15 +0000
changeset 23
f2c7acb4a258
parent 5
1204ebf9340d
permissions
-rwxr-xr-x

Update PTdecode to handle output from other Ptouch drivers

philpem@5 1 /*
philpem@5 2 #
philpem@5 3 # File : add_fileformat.h
philpem@5 4 # ( C++ header file - CImg plug-in )
philpem@5 5 #
philpem@5 6 # Description : CImg plug-in that adds loading/saving support for a personalized
philpem@5 7 # file format (determined by its extension, here ".foo").
philpem@5 8 # This file is a part of the CImg Library project.
philpem@5 9 # ( http://cimg.sourceforge.net )
philpem@5 10 #
philpem@5 11 # Copyright : David Tschumperle
philpem@5 12 # ( http://www.greyc.ensicaen.fr/~dtschump/ )
philpem@5 13 #
philpem@5 14 # License : CeCILL v2.0
philpem@5 15 # ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
philpem@5 16 #
philpem@5 17 # This software is governed by the CeCILL license under French law and
philpem@5 18 # abiding by the rules of distribution of free software. You can use,
philpem@5 19 # modify and/ or redistribute the software under the terms of the CeCILL
philpem@5 20 # license as circulated by CEA, CNRS and INRIA at the following URL
philpem@5 21 # "http://www.cecill.info".
philpem@5 22 #
philpem@5 23 # As a counterpart to the access to the source code and rights to copy,
philpem@5 24 # modify and redistribute granted by the license, users are provided only
philpem@5 25 # with a limited warranty and the software's author, the holder of the
philpem@5 26 # economic rights, and the successive licensors have only limited
philpem@5 27 # liability.
philpem@5 28 #
philpem@5 29 # In this respect, the user's attention is drawn to the risks associated
philpem@5 30 # with loading, using, modifying and/or developing or reproducing the
philpem@5 31 # software by the user in light of its specific status of free software,
philpem@5 32 # that may mean that it is complicated to manipulate, and that also
philpem@5 33 # therefore means that it is reserved for developers and experienced
philpem@5 34 # professionals having in-depth computer knowledge. Users are therefore
philpem@5 35 # encouraged to load and test the software's suitability as regards their
philpem@5 36 # requirements in conditions enabling the security of their systems and/or
philpem@5 37 # data to be ensured and, more generally, to use and operate it in the
philpem@5 38 # same conditions as regards security.
philpem@5 39 #
philpem@5 40 # The fact that you are presently reading this means that you have had
philpem@5 41 # knowledge of the CeCILL license and that you accept its terms.
philpem@5 42 #
philpem@5 43 */
philpem@5 44
philpem@5 45 #ifndef cimg_plugin_addfileformat
philpem@5 46 #define cimg_plugin_addfileformat
philpem@5 47
philpem@5 48 // These functions load ".foo" filenames
philpem@5 49 //---------------------------------------
philpem@5 50 static CImg<T> get_load_foo(const char *filename) {
philpem@5 51 std::fprintf(stderr,"Load '%s' here..\n",filename);
philpem@5 52 return CImg<T>(512,512,1,3,0).noise(30);
philpem@5 53 }
philpem@5 54
philpem@5 55 CImg& load_foo(const char *filename) {
philpem@5 56 return get_load_foo(filename).swap(*this);
philpem@5 57 }
philpem@5 58
philpem@5 59 // This function saves the instance image into a ".foo" file.
philpem@5 60 //-----------------------------------------------------------
philpem@5 61 const CImg& save_foo(const char *filename) const {
philpem@5 62 std::fprintf(stderr,"Save '%s' here..\n",filename);
philpem@5 63 return *this;
philpem@5 64 }
philpem@5 65
philpem@5 66 // The code below allows to add the support for the specified extension.
philpem@5 67 //---------------------------------------------------------------------
philpem@5 68 #ifndef cimg_load_plugin
philpem@5 69 #define cimg_load_plugin(filename) \
philpem@5 70 if (!cimg::strncasecmp(cimg::split_filename(filename),"foo",3)) return load_foo(filename);
philpem@5 71 #endif
philpem@5 72 #ifndef cimg_save_plugin
philpem@5 73 #define cimg_save_plugin(filename) \
philpem@5 74 if (!cimg::strncasecmp(cimg::split_filename(filename),"foo",3)) return save_foo(filename);
philpem@5 75 #endif
philpem@5 76
philpem@5 77 // End of the plugin.
philpem@5 78 //-------------------
philpem@5 79 #endif