blob: 37b8e3cb41e4f4bf35eb19b0159dc37b6017319f [file] [log] [blame]
Austin Schuh8c794d52019-03-03 21:17:37 -08001/*
2 #
3 # File : use_tiff_stream.cpp
4 # ( C++ source file )
5 #
6 # Description : Example of use for the CImg plugin 'plugins/jpeg_buffer.h'.
7 # This file is a part of the CImg Library project.
8 # ( http://cimg.eu )
9 #
10 # Copyright : Wolf Blecher
11 # ( Wolf.Blecher(at)sirona.com )
12 #
13 # License : CeCILL v2.0
14 # ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
15 #
16 # This software is governed by the CeCILL license under French law and
17 # abiding by the rules of distribution of free software. You can use,
18 # modify and/ or redistribute the software under the terms of the CeCILL
19 # license as circulated by CEA, CNRS and INRIA at the following URL
20 # "http://www.cecill.info".
21 #
22 # As a counterpart to the access to the source code and rights to copy,
23 # modify and redistribute granted by the license, users are provided only
24 # with a limited warranty and the software's author, the holder of the
25 # economic rights, and the successive licensors have only limited
26 # liability.
27 #
28 # In this respect, the user's attention is drawn to the risks associated
29 # with loading, using, modifying and/or developing or reproducing the
30 # software by the user in light of its specific status of free software,
31 # that may mean that it is complicated to manipulate, and that also
32 # therefore means that it is reserved for developers and experienced
33 # professionals having in-depth computer knowledge. Users are therefore
34 # encouraged to load and test the software's suitability as regards their
35 # requirements in conditions enabling the security of their systems and/or
36 # data to be ensured and, more generally, to use and operate it in the
37 # same conditions as regards security.
38 #
39 # The fact that you are presently reading this means that you have had
40 # knowledge of the CeCILL license and that you accept its terms.
41 #
42*/
43
44
45#include <fstream>
46// These includes are necessary to get the plug-in compile ! Don't forget to link with 'libtiff' and 'libtiffxx' !
47#include "tiffio.h"
48#include "tiffio.hxx"
49
50// Define plugin and include the CImg Library.
51#define cimg_plugin "plugins/tiff_stream.h"
52#include "CImg.h"
53using namespace cimg_library;
54
55// Main procedure
56//----------------
57int main() {
58
59 std::ifstream inFile("input.tif", std::ifstream::in | std::ifstream::binary);
60 std::ofstream outFile("outFile.tif", std::ofstream::out | std::ifstream::binary);
61
62 if (!inFile.good())
63 {
64 std::cout << "Error Reading from infile" << std::endl;
65 }
66
67 cimg_library::CImg<unsigned short> imgIn;
68 imgIn.load_tiff(&inFile);
69 imgIn.display();
70 CImg<unsigned short> imgOut = imgIn.save_tiff(&outFile, 2U);
71 imgOut.display();
72
73 inFile.close();
74 outFile.close();
75
76 inFile.open("outFile.tif", std::ifstream::in | std::ifstream::binary);
77 imgIn.load_tiff(&inFile);
78 imgIn.display();
79 inFile.close();
80 return 0;
81}