MEPP2 Project
cimg_tests.cpp
Go to the documentation of this file.
1 // Copyright (c) 2012-2019 University of Lyon and CNRS (France).
2 // All rights reserved.
3 //
4 // This file is part of MEPP2; you can redistribute it and/or modify
5 // it under the terms of the GNU Lesser General Public License as
6 // published by the Free Software Foundation; either version 3 of
7 // the License, or (at your option) any later version.
8 //
9 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11 #include <iostream>
12 
13 #ifdef FEVV_USE_JPEG
14 #define cimg_use_jpeg // pb avec vcpkg en Release uniquement, why ?
15 #endif
16 
17 #ifdef FEVV_USE_PNG
18 #define cimg_use_png
19 #endif
20 
21 #ifdef FEVV_USE_TIFF
22 #define cimg_use_tiff
23 #endif
24 
25 #undef _PTHREAD_H // to avoid linking with pthread
26 #define cimg_display 0 // no display
27 #include <CImg.h>
28 
29 int main(int argc, char **argv)
30 {
31  if(argc < 2)
32  {
33  std::cout << "Usage: " << argv[0] << " <path_to_image_file_1> [<path_to_image_file_2>...]\n";
34  return -1; // error
35  }
36 
37  for(int i = 1; i < argc; i++)
38  {
39  std::string filename(argv[i]);
40  if(filename.substr(filename.size() - 4) == ".jpg")
41  {
42  // skip jpeg because of a bug in vcpkg jpeg library.
43  // TODO: restore when vcpkg jpeg library is fixed.
44  continue;
45  }
46 
47  std::cout << "----------------------------\n";
48  std::cout << "loading " << argv[i] << "...\n";
49  cimg_library::CImg<unsigned char> image(argv[i]);
50 
51  //image.display();
52  std::cout << "with " << image.width() << '\n';
53  std::cout << "height " << image.height() << '\n';
54  std::cout << "depth " << image.depth() << '\n';
55  std::cout << "spectrum " << image.spectrum() << '\n';
56  }
57 
58  return 0; // ok
59 }
main
int main(int argc, char **argv)
Definition: cimg_tests.cpp:29