texture_from_png.h 1.8 KB

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