texture_from_png.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 <Eigen/Core>
  12. #include <string>
  13. #include <Eigen/Core>
  14. #ifndef IGL_NO_OPENGL
  15. #include "../OpenGL_convenience.h"
  16. namespace igl
  17. {
  18. // Read an image from a .png file and use it as a texture
  19. //
  20. // Input:
  21. // png_file path to .png file
  22. // Output:
  23. // id of generated openGL texture
  24. // Returns true on success, false on failure
  25. IGL_INLINE bool texture_from_png(const std::string png_file, GLuint & id);
  26. }
  27. #endif
  28. namespace igl
  29. {
  30. // Read an image from a .png file and use it as a texture
  31. //
  32. // Input:
  33. // png_file path to .png file
  34. // Output:
  35. // R,G,B,A texture channels
  36. // Returns true on success, false on failure
  37. IGL_INLINE bool texture_from_png(const std::string png_file,
  38. Eigen::Matrix<char,Eigen::Dynamic,Eigen::Dynamic>& R,
  39. Eigen::Matrix<char,Eigen::Dynamic,Eigen::Dynamic>& G,
  40. Eigen::Matrix<char,Eigen::Dynamic,Eigen::Dynamic>& B,
  41. Eigen::Matrix<char,Eigen::Dynamic,Eigen::Dynamic>& A
  42. );
  43. }
  44. #ifndef IGL_STATIC_LIBRARY
  45. # include "texture_from_png.cpp"
  46. #endif
  47. #endif