texture_from_png.h 1.4 KB

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