GLIP-Lib
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ImageBuffer.hpp
Go to the documentation of this file.
1 /* ************************************************************************************************************* */
2 /* */
3 /* GLIP-LIB */
4 /* OpenGL Image Processing LIBrary */
5 /* */
6 /* Author : R. Kerviche */
7 /* LICENSE : MIT License */
8 /* Website : glip-lib.net */
9 /* */
10 /* File : TextureReader.hpp */
11 /* Original Date : October 17th 2010 */
12 /* */
13 /* Description : Module : Image Buffer */
14 /* */
15 /* ************************************************************************************************************* */
16 
24 #ifndef __IMAGE_BUFFER_INCLUDE__
25 #define __IMAGE_BUFFER_INCLUDE__
26 
27  // Includes
28  #include <limits>
29  #include "Core/LibTools.hpp"
30  #include "Core/OglInclude.hpp"
31  #include "Core/HdlDynamicData.hpp"
32  #include "Core/HdlTexture.hpp"
33 
34 namespace Glip
35 {
36  // Prototypes
37  using namespace Glip::CoreGL;
38 
39  namespace Modules
40  {
41  // Structures :
47  class GLIP_API ImageBuffer : public HdlAbstractTextureFormat
48  {
49  private :
50  static const unsigned int headerNumBytes;
51  static const unsigned int maxCommentLength;
52  static const std::string headerSignature;
53 
54  const HdlTextureFormatDescriptor& descriptor;
55  HdlDynamicTable* table;
56 
57  public :
58  ImageBuffer(const HdlAbstractTextureFormat& format, int _alignment=1);
59  ImageBuffer(void* buffer, const HdlAbstractTextureFormat& format, int _alignment=1);
60  ImageBuffer(HdlTexture& texture, int _alignment=1);
61  ImageBuffer(const ImageBuffer& image);
62  ~ImageBuffer(void);
63 
64  const HdlTextureFormatDescriptor& getDescriptor(void) const;
65  void* getPtr(void);
66  const void* getPtr(void) const;
67  void* getRowPtr(int i);
68  const void* getRowPtr(int i) const;
69  HdlDynamicTable& getTable(void);
70  const HdlDynamicTable& getTable(void) const;
71 
72  void setMinFilter(GLenum mf);
73  void setMagFilter(GLenum mf);
74  void setSWrapping(GLenum m);
75  void setTWrapping(GLenum m);
76 
77  const ImageBuffer& operator<<(HdlTexture& texture);
78  const ImageBuffer& operator<<(const ImageBuffer& image);
79  const ImageBuffer& operator<<(const void* bytes);
80  const ImageBuffer& operator>>(HdlTexture& texture) const;
81  const ImageBuffer& operator>>(ImageBuffer& image) const;
82  const ImageBuffer& operator>>(void* bytes) const;
83 
84  bool isInside(const int& x, const int& y) const;
85  bool isInside(const int& x, const int& y, const GLenum& channel) const;
86  int getIndex(const int& x, const int& y, const GLenum& channel) const;
87  long long get(const int& x, const int& y, const GLenum& channel) const;
88  void set(const long long& value, const int& x, const int& y, const GLenum& channel);
89  float getNormalized(const int& x, const int& y, const GLenum& channel) const;
90  void setNormalized(const float& value, const int& x, const int& y, const GLenum& channel);
91 
92  void blit(const ImageBuffer& src, const int& xSrc=0, const int& ySrc=0, const int& xDst=0, const int& yDst=0, int _width=0, int _height=0, const bool xFlip=false, const bool yFlip=false);
93 
94  static ImageBuffer* load(const std::string& filename, std::string* comment=NULL);
95  void write(const std::string& filename, const std::string& comment="") const;
96  };
97  }
98 }
99 
100 #endif
101 
Specific defines for the API structure.
OpenGL Dynamic Memory Allocator.
Object handle describing an OpenGL Texture mode.
Definition: HdlTextureTools.hpp:39
OpenGL Texture Handle.
Object handle for OpenGL textures.
Definition: HdlTexture.hpp:138
Definition: Component.hpp:32
Dynamic table allocator for GL types (run-time resolution of type).
Definition: HdlDynamicData.hpp:299
Host-side image buffer.
Definition: ImageBuffer.hpp:47
OpenGL includes and tools.
Definition: Component.hpp:34
Object handle for OpenGL texture formats (Read Only).
Definition: HdlTexture.hpp:42