17 #ifndef AGXIO_IMAGEVALUEINTERPRETER_H
18 #define AGXIO_IMAGEVALUEINTERPRETER_H
45 size_t pos = (size_t)image->
getWidth() * y + x;
47 return 0.00392156863f * image->
getData()[ pos ];
52 const unsigned char* data = image->
getData();
53 size_t pos = (size_t)image->
getWidth() * y + x;
55 return 0.00392156863f * float(( 77 * data[ pos ] + 150 * data[ pos + 1 ] + 29 * data[ pos + 2 ] ) >> 8);
60 const unsigned char* data = image->
getData();
61 size_t pos = (size_t)image->
getWidth() * y + x;
63 return 0.00392156863f * float(( 77 * data[ pos ] + 150 * data[ pos + 1 ] + 29 * data[ pos + 2 ] ) >> 8);
68 const unsigned char* data = image->
getData();
69 size_t pos = (size_t)image->
getWidth() * y + x;
71 return 0.00392156863f * data[ pos + channel ];
76 unsigned char* data = image->
getData();
77 size_t pos = (size_t)image->
getWidth() * y + x;
79 data[ pos + channel ] = val;
101 bool read(
const std::string& filename );
219 void setValueR(
unsigned char val,
size_t x,
size_t y );
225 void setValueG(
unsigned char val,
size_t x,
size_t y );
231 void setValueB(
unsigned char val,
size_t x,
size_t y );
237 void setValueA(
unsigned char val,
size_t x,
size_t y );
#define AGXPHYSICS_EXPORT
Class to represent Images.
unsigned int getChannels() const
unsigned int getWidth() const
unsigned char * getData()
float getMinValue() const
float getValueA(size_t x, size_t y, GetValueFunction func=linearValueFunction) const
Reads single "Alpha" channel at pixel (x,y) and returns value between given minimum and maximum.
agx::Vec3f getValueRGB(size_t x, size_t y, GetValueFunction func=linearValueFunction) const
Reads R, G, and B channels and returns Vec3f with result at pixel (x,y).
PNGImageValueInterpreter()
Default constructor.
float getValueG(size_t x, size_t y, GetValueFunction func=linearValueFunction) const
Reads single "Green" channel at pixel (x,y) and returns value between given minimum and maximum.
virtual ~PNGImageValueInterpreter()
Reference counted object.
ReadValue01Function m_readFunction
void setMaxValue(float maxValue)
Set new maximum value for the accessors methods (i.e., channel value = 255 => maximum value).
size_t getImageHeight() const
agx::Vec4f getValueRGBA(size_t x, size_t y, GetValueFunction func=linearValueFunction) const
Reads R, G, B and A channels and returns Vec4f with result at pixel (x,y).
void setValueG(unsigned char val, size_t x, size_t y)
Set current value to the "Green" channel.
void setValueA(unsigned char val, size_t x, size_t y)
Set current value to the "Alpha" channel.
bool read(const std::string &filename)
Read PNG image.
float getMaxValue() const
float getValueR(size_t x, size_t y, GetValueFunction func=linearValueFunction) const
Reads single "Red" channel at pixel (x,y) and returns value between given minimum and maximum.
void setMinValue(float minValue)
Set new minimum value for the accessors methods (i.e., channel value = 0 => minimum value).
void setValueR(unsigned char val, size_t x, size_t y)
Set current value to the "Red" channel.
PNGImageValueInterpreter(float minValue, float maxValue)
Construct given minimum- and maximum value.
float getValue(size_t x, size_t y, GetValueFunction func=linearValueFunction) const
Reads image at pixel (x,y) and returns value between given minimum and maximum.
agxIO::Image * getImage() const
size_t getImageWidth() const
void setValueB(unsigned char val, size_t x, size_t y)
Set current value to the "Blue" channel.
float getValueB(size_t x, size_t y, GetValueFunction func=linearValueFunction) const
Reads single "Blue" channel at pixel (x,y) and returns value between given minimum and maximum.
Base class providing referencing counted objects.
A class holding 4 dimensional vectors and providing basic arithmetic.
The agxIO namespace contains classes for reading, writing and finding files.
float linearValueFunction(float val)
float readThreeChannelMergedValue01(agxIO::Image *image, size_t x, size_t y)
float cubicValueFunction(float val)
float quadraticValueFunction(float val)
float readSingleChannelValue01(agxIO::Image *image, size_t x, size_t y, size_t channel)
float readOneOrTwoChannelValue01(agxIO::Image *image, size_t x, size_t y)
float(* GetValueFunction)(float val)
float readFourChannelMergedValue01(agxIO::Image *image, size_t x, size_t y)
agx::ref_ptr< PNGImageValueInterpreter > PNGImageValueInterpreterRef
void writeSingleChannelValue01(unsigned char val, agxIO::Image *image, size_t x, size_t y, size_t channel)
float(* ReadValue01Function)(agxIO::Image *image, size_t x, size_t y)