texture_from_png.h 1.6 KB

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