Tucano  0.1
A library for rapid prototyping with modern OpenGL and GLSL
imageIO.hpp
Go to the documentation of this file.
1 
23 #ifndef __IMAGEIO__
24 #define __IMAGEIO__
25 
26 #include <tucano/utils/pamIO.hpp>
27 #include <tucano/utils/ppmIO.hpp>
28 
29 namespace Tucano
30 {
31 
32 namespace ImageImporter
33 {
34 
35 static bool loadImage (string filename, Tucano::Texture* tex) __attribute__ ((unused));
36 static bool writeImage (string filename, Tucano::Framebuffer* tex, int attach = 0) __attribute__ ((unused));
37 
38 /* @brief Loads a texture from a supported file format.
39  * Checks file extension, if format is supported reads file and loads texture
40  *
41  * @param filename Given filename.
42  * @param tex Pointer to the texture
43  * @return True if loaded successfully, false otherwise
44  */
45 static bool loadImage (string filename, Tucano::Texture *tex)
46 {
47  string ext = filename.substr(filename.find_last_of(".") + 1);
48  if( ext.compare("pam") == 0)
49  {
50  return loadPAMImage (filename, tex);
51  }
52  else if (ext.compare("ppm") == 0)
53  {
54  return loadPPMImage (filename, tex);
55  }
56  std::cerr << "format not supported : " << ext.c_str() << std::endl;
57  return false;
58 
59 }
60 
68 static bool writeImage (string filename, Tucano::Framebuffer* fbo, int attach)
69 {
70  string ext = filename.substr(filename.find_last_of(".") + 1);
71  if( ext.compare("pam") == 0)
72  {
73  return writePAMImage (filename, fbo, attach);
74  }
75  else if (ext.compare("ppm") == 0)
76  {
77  return false;//writePPMImage (filename, fbo, attach);
78  }
79  std::cerr << "format not supported : " << ext.c_str() << std::endl;
80  return false;
81 }
82 
83 
84 }
85 }
86 #endif
static bool writeImage(string filename, Tucano::Framebuffer *tex, int attach=0) __attribute__((unused))
Saves a framebuffer attachment to an image file.
Definition: imageIO.hpp:68
Definition: bufferobject.hpp:34
static bool loadImage(string filename, Tucano::Texture *tex) __attribute__((unused))
Definition: imageIO.hpp:45
static bool loadPPMImage(string filename, Tucano::Texture *tex) __attribute__((unused))
Loads a texture from a PPM file. The texture receives data in the range [0,1] to create a FLOAT textu...
Definition: ppmIO.hpp:46
A wrapper class for creating and using FBOs.
Definition: framebuffer.hpp:44
static bool loadPAMImage(string filename, Tucano::Texture *tex) __attribute__((unused))
Definition: pamIO.hpp:47
static bool writePAMImage(string filename, Tucano::Framebuffer *fbo, int attach=0) __attribute__((unused))
Saves a framebuffer attachment to an image file Note that since the input is a float image...
Definition: pamIO.hpp:157
An OpenGL texture. It can be a simple texture or an FBO texture.
Definition: texture.hpp:41