texture_from_png.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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_PNG_TEXTURE_FROM_PNG_H
  9. #define IGL_PNG_TEXTURE_FROM_PNG_H
  10. #include "../igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <string>
  13. #include "../opengl/OpenGL_convenience.h"
  14. namespace igl
  15. {
  16. namespace png
  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. }
  28. namespace igl
  29. {
  30. namespace png
  31. {
  32. // Read an image from a .png file and use it as a texture
  33. //
  34. // Input:
  35. // png_file path to .png file
  36. // Output:
  37. // R,G,B,A texture channels
  38. // Returns true on success, false on failure
  39. IGL_INLINE bool texture_from_png(const std::string png_file,
  40. Eigen::Matrix<char,Eigen::Dynamic,Eigen::Dynamic>& R,
  41. Eigen::Matrix<char,Eigen::Dynamic,Eigen::Dynamic>& G,
  42. Eigen::Matrix<char,Eigen::Dynamic,Eigen::Dynamic>& B,
  43. Eigen::Matrix<char,Eigen::Dynamic,Eigen::Dynamic>& A
  44. );
  45. }
  46. }
  47. #ifndef IGL_STATIC_LIBRARY
  48. # include "texture_from_png.cpp"
  49. #endif
  50. #endif