23 std::vector<Color> m_pixels;
28 Image( ) : m_pixels(), m_width(0), m_height(0) {}
29 Image(
const int w,
const int h,
const Color& color=
Black() ) : m_pixels(w*h, color), m_width(w), m_height(h) {}
42 return m_pixels[
offset(x, y)];
48 return m_pixels[
offset(x, y)];
54 assert(
offset < m_pixels.size());
61 assert(
offset < m_pixels.size());
69 float u= x - std::floor(x);
70 float v= y - std::floor(y);
73 return (*
this)(ix, iy) * ((1 - u) * (1 - v))
74 + (*this)(ix+1, iy) * (u * (1 - v))
75 + (*
this)(ix, iy+1) * ((1 - u) * v)
76 + (*
this)(ix+1, iy+1) * (u * v);
82 return sample(x * m_width, y * m_height);
88 assert(!m_pixels.empty());
89 return (
const float *) m_pixels.data();
95 assert(!m_pixels.empty());
96 return (
float *) m_pixels.data();
100 int width( )
const {
return m_width; }
104 unsigned size( )
const {
return m_width * m_height; }
108 unsigned offset(
const int x,
const int y )
const
112 if(px > m_width-1) px= m_width-1;
115 if(py > m_height-1) py= m_height-1;
117 unsigned p= py * m_width + px;
118 assert(p < m_pixels.size());
representation d'une image.
int height() const
renvoie la hauteur de l'image.
unsigned size() const
renvoie le nombre de pixels de l'image.
const float * data() const
renvoie un const pointeur sur le stockage des couleurs des pixels.
float * data()
renvoie un pointeur sur le stockage des couleurs des pixels.
Color texture(const float x, const float y) const
renvoie la couleur interpolee aux coordonnees normalisees (x, y) [0 .. 1]x[0 .. 1].
Color & operator()(const int x, const int y)
unsigned offset(const int x, const int y) const
Color sample(const float x, const float y) const
renvoie la couleur interpolee a la position (x, y) [0 .. width]x[0 .. height].
int width() const
renvoie la largeur de l'image.
Color Black()
utilitaire. renvoie une couleur noire.
representation d'une couleur (rgba) transparente ou opaque.