Added getColor method to allow easy reading of individual pixels.

This commit is contained in:
Robert Osfield
2007-10-31 12:55:15 +00:00
parent c761efb371
commit 316b36fab7
2 changed files with 54 additions and 0 deletions

View File

@@ -15,6 +15,9 @@
#define OSG_IMAGE 1
#include <osg/BufferObject>
#include <osg/Vec2>
#include <osg/Vec3>
#include <osg/Vec4>
#include <string>
#include <vector>
@@ -203,6 +206,15 @@ class OSG_EXPORT Image : public Object
return _data+(column*getPixelSizeInBits())/8+row*getRowSizeInBytes()+image*getImageSizeInBytes();
}
/** Get the color value for specified texcoord.*/
Vec4 getColor(unsigned int s,unsigned t=0,unsigned r=0) const;
/** Get the color value for specified texcoord.*/
Vec4 getColor(const Vec2& texcoord) const { return getColor(Vec3(texcoord.x(),texcoord.y(),0.0f)); }
/** Get the color value for specified texcoord.*/
Vec4 getColor(const Vec3& texcoord) const;
/** Flip the image horizontally. */
void flipHorizontal();