test_precomp.hpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // This file is part of OpenCV project.
  2. // It is subject to the license terms in the LICENSE file found in the top-level directory
  3. // of this distribution and at http://opencv.org/license.html
  4. #ifndef __OPENCV_TEST_PRECOMP_HPP__
  5. #define __OPENCV_TEST_PRECOMP_HPP__
  6. #include "opencv2/ts.hpp"
  7. #include "opencv2/imgcodecs.hpp"
  8. #include "opencv2/imgproc/imgproc_c.h"
  9. namespace cv {
  10. static inline
  11. void PrintTo(const ImreadModes& val, std::ostream* os)
  12. {
  13. int v = val;
  14. if (v == IMREAD_UNCHANGED && (v & IMREAD_IGNORE_ORIENTATION) != 0)
  15. {
  16. CV_Assert(IMREAD_UNCHANGED == -1);
  17. *os << "IMREAD_UNCHANGED";
  18. return;
  19. }
  20. if ((v & IMREAD_COLOR) != 0)
  21. {
  22. CV_Assert(IMREAD_COLOR == 1);
  23. v &= ~IMREAD_COLOR;
  24. *os << "IMREAD_COLOR" << (v == 0 ? "" : " | ");
  25. }
  26. else
  27. {
  28. CV_Assert(IMREAD_GRAYSCALE == 0);
  29. *os << "IMREAD_GRAYSCALE" << (v == 0 ? "" : " | ");
  30. }
  31. if ((v & IMREAD_ANYDEPTH) != 0)
  32. {
  33. v &= ~IMREAD_ANYDEPTH;
  34. *os << "IMREAD_ANYDEPTH" << (v == 0 ? "" : " | ");
  35. }
  36. if ((v & IMREAD_ANYCOLOR) != 0)
  37. {
  38. v &= ~IMREAD_ANYCOLOR;
  39. *os << "IMREAD_ANYCOLOR" << (v == 0 ? "" : " | ");
  40. }
  41. if ((v & IMREAD_LOAD_GDAL) != 0)
  42. {
  43. v &= ~IMREAD_LOAD_GDAL;
  44. *os << "IMREAD_LOAD_GDAL" << (v == 0 ? "" : " | ");
  45. }
  46. if ((v & IMREAD_IGNORE_ORIENTATION) != 0)
  47. {
  48. v &= ~IMREAD_IGNORE_ORIENTATION;
  49. *os << "IMREAD_IGNORE_ORIENTATION" << (v == 0 ? "" : " | ");
  50. }
  51. switch (v)
  52. {
  53. case IMREAD_UNCHANGED: return;
  54. case IMREAD_GRAYSCALE: return;
  55. case IMREAD_COLOR: return;
  56. case IMREAD_ANYDEPTH: return;
  57. case IMREAD_ANYCOLOR: return;
  58. case IMREAD_LOAD_GDAL: return;
  59. case IMREAD_REDUCED_GRAYSCALE_2: // fallthru
  60. case IMREAD_REDUCED_COLOR_2: *os << "REDUCED_2"; return;
  61. case IMREAD_REDUCED_GRAYSCALE_4: // fallthru
  62. case IMREAD_REDUCED_COLOR_4: *os << "REDUCED_4"; return;
  63. case IMREAD_REDUCED_GRAYSCALE_8: // fallthru
  64. case IMREAD_REDUCED_COLOR_8: *os << "REDUCED_8"; return;
  65. case IMREAD_IGNORE_ORIENTATION: return;
  66. } // don't use "default:" to emit compiler warnings
  67. *os << "IMREAD_UNKNOWN(" << (int)v << ")";
  68. }
  69. } // namespace
  70. #endif