Changeset 26
- Timestamp:
- 05/20/13 21:29:15 (12 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/gl/image.hh
r21 r26 13 13 namespace nv 14 14 { 15 /** 16 * Defines the starting position of some region and its size. 17 */ 15 18 struct region 16 19 { … … 22 25 }; 23 26 27 /** 28 * Holder for images. 29 * 30 * By an image we understand a group of pixels, limited to X and Y 31 * dimensions, of a certain depth (by depth we mean how rich 32 * the colours are. 33 */ 24 34 class image 25 35 { 26 36 public: 37 /** 38 * Constructor 39 * 40 * @arg[in] size : Dimensions of the image as a vector. 41 * @arg[in] depth : Depth of the image. 42 */ 27 43 image( glm::ivec2 size, size_t depth ); 44 /** 45 * Full constructor. 46 * 47 * Allows creation of an image with specified data. It is 48 * to reverse the image (from left to right). 49 * 50 * @arg[in] size : Dimensions of the image as a vector. 51 * @arg[in] depth : Depth of the image. 52 * @arg[in] data : Data of the image. 53 * @arg[in] reversed : Determines if the image should be 54 * reversed or not. 55 */ 28 56 image( glm::ivec2 size, size_t depth, const uint8 * data, bool reversed = false ); 29 void clear(); 57 /** 58 * Fills the image with a given value. 59 * 60 * @arg[in] value : Value to fill. 61 */ 30 62 void fill( uint8 value ); 63 /** 64 * Just like fill, but a region can be specified. 65 * 66 * @arg[in] r : Region to be filled. 67 * @arg[in] data : Data to fill the region 68 * @arg[in] stride : 69 */ 31 70 void set_region( region r, const uint8 * data, size_t stride = 0 ); 32 ~image(); 71 /** 72 * Default destructor. Deallocates data. 73 */ 74 virtual ~image(); 75 /** 76 * Getter for data. 77 * 78 * @return The data. 79 */ 33 80 const uint8 * get_data() const { return m_data; } 81 /** 82 * Getter for size. 83 * 84 * @return Returns the size of the image as a vector. 85 */ 34 86 const glm::ivec2 get_size() const { return m_size; } 87 /** 88 * Getter for depth. 89 * 90 * @return Returns depth of the image. 91 */ 35 92 const size_t get_depth() const { return m_depth; } 36 93 protected: 94 /** Defines the size of the image as a vector. */ 37 95 glm::ivec2 m_size; 96 /** Deefines the depth of the image. */ 38 97 size_t m_depth; 98 /** Holder for data. */ 39 99 uint8* m_data; 40 100 }; … … 43 103 44 104 #endif // NV_IMAGE_HH 105 -
trunk/src/gl/image.cc
r21 r26 22 22 if ( reversed ) 23 23 { 24 for( size_t i = 0; i < size.y; ++i )24 for( int i = 0; i < size.y; ++i ) 25 25 { 26 26 memcpy( m_data + size.x * ( size.y - i - 1) * m_depth, data + i * size.x * m_depth, m_size.x * m_depth ); … … 43 43 if ( stride == 0 ) stride = r.size.x; 44 44 45 for( size_t i = 0; i < r.size.y; ++i )46 47 48 49 45 for( int i = 0; i < r.size.y; ++i ) 46 { 47 memcpy( m_data+((r.pos.y+i)*m_size.x + r.pos.x ) * m_depth, 48 data + (i*stride), r.size.x * m_depth ); 49 } 50 50 } 51 51
Note: See TracChangeset
for help on using the changeset viewer.