texture_from_png.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2014 Alec Jacobson <alecjacobson@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_TEXTURE_FROM_PNG_H
  9. #define IGL_TEXTURE_FROM_PNG_H
  10. #include "../igl_inline.h"
  11. #include <string>
  12. #include <Eigen/Core>
  13. #ifndef IGL_NO_OPENGL
  14. #include "../OpenGL_convenience.h"
  15. namespace igl
  16. {
  17. // Read an image from a .png file and use it as a texture
  18. //
  19. // Input:
  20. // png_file path to .png file
  21. // Output:
  22. // id of generated openGL texture
  23. // Returns true on success, false on failure
  24. IGL_INLINE bool texture_from_png(const std::string png_file, GLuint & id);
  25. }
  26. #endif
  27. namespace igl
  28. {
  29. // Read an image from a .png file and use it as a texture
  30. //
  31. // Input:
  32. // png_file path to .png file
  33. // Output:
  34. // R,G,B,A texture channels
  35. // Returns true on success, false on failure
  36. IGL_INLINE bool texture_from_png(const std::string png_file,
  37. Eigen::Matrix<char,Eigen::Dynamic,Eigen::Dynamic>& R,
  38. Eigen::Matrix<char,Eigen::Dynamic,Eigen::Dynamic>& G,
  39. Eigen::Matrix<char,Eigen::Dynamic,Eigen::Dynamic>& B,
  40. Eigen::Matrix<char,Eigen::Dynamic,Eigen::Dynamic>& A
  41. );
  42. }
  43. #ifndef IGL_STATIC_LIBRARY
  44. # include "texture_from_png.cpp"
  45. #endif
  46. #endif