representation d'une image.
More...
#include <image.h>
|
| | Image (const int w, const int h, const Color &color=Black()) |
| |
| Color & | operator() (const int x, const int y) |
| |
| Color | operator() (const int x, const int y) const |
| | renvoie la couleur d'un pixel de l'image (image non modifiable).
|
| |
| Color & | operator() (const size_t offset) |
| | renvoie une reference sur le ieme pixel de l'image.
|
| |
| Color | operator() (const size_t offset) const |
| | renvoie lacouleur du ieme pixel de l'image.
|
| |
| Color | sample (const float x, const float y) const |
| | renvoie la couleur interpolee a la position (x, y) [0 .. width]x[0 .. height].
|
| |
| Color | texture (const float x, const float y) const |
| | renvoie la couleur interpolee aux coordonnees normalisees (x, y) [0 .. 1]x[0 .. 1].
|
| |
| 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.
|
| |
| int | width () const |
| | renvoie la largeur de l'image.
|
| |
| int | height () const |
| | renvoie la hauteur de l'image.
|
| |
| unsigned | size () const |
| | renvoie le nombre de pixels de l'image.
|
| |
| unsigned | offset (const int x, const int y) const |
| |
representation d'une image.
Definition at line 20 of file image.h.
◆ Image() [1/2]
Definition at line 28 of file image.h.
28: m_pixels(), m_width(0), m_height(0) {}
◆ Image() [2/2]
| Image::Image |
( |
const int |
w, |
|
|
const int |
h, |
|
|
const Color & |
color = Black() |
|
) |
| |
|
inline |
Definition at line 29 of file image.h.
29: m_pixels(w*h, color), m_width(w), m_height(h) {}
◆ operator()() [1/4]
| Color & Image::operator() |
( |
const int |
x, |
|
|
const int |
y |
|
) |
| |
|
inline |
renvoie une reference sur la couleur d'un pixel de l'image. permet de modifier et/ou de connaitre la couleur d'un pixel :
image(0, 0)= image(10, 10);
representation d'une image.
Color Red()
utilitaire. renvoie une couleur rouge.
Definition at line 40 of file image.h.
41 {
42 return m_pixels[
offset(x, y)];
43 }
unsigned offset(const int x, const int y) const
◆ operator()() [2/4]
| Color Image::operator() |
( |
const int |
x, |
|
|
const int |
y |
|
) |
| const |
|
inline |
renvoie la couleur d'un pixel de l'image (image non modifiable).
Definition at line 46 of file image.h.
47 {
48 return m_pixels[
offset(x, y)];
49 }
◆ operator()() [3/4]
| Color & Image::operator() |
( |
const size_t |
offset | ) |
|
|
inline |
renvoie une reference sur le ieme pixel de l'image.
Definition at line 52 of file image.h.
53 {
54 assert(
offset < m_pixels.size());
56 }
◆ operator()() [4/4]
| Color Image::operator() |
( |
const size_t |
offset | ) |
const |
|
inline |
renvoie lacouleur du ieme pixel de l'image.
Definition at line 59 of file image.h.
60 {
61 assert(
offset < m_pixels.size());
63 }
◆ sample()
| Color Image::sample |
( |
const float |
x, |
|
|
const float |
y |
|
) |
| const |
|
inline |
renvoie la couleur interpolee a la position (x, y) [0 .. width]x[0 .. height].
Definition at line 66 of file image.h.
67 {
68
69 float u= x - std::floor(x);
70 float v= y - std::floor(y);
71 int ix= x;
72 int iy= 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);
77 }
◆ texture()
| Color Image::texture |
( |
const float |
x, |
|
|
const float |
y |
|
) |
| const |
|
inline |
renvoie la couleur interpolee aux coordonnees normalisees (x, y) [0 .. 1]x[0 .. 1].
Definition at line 80 of file image.h.
81 {
82 return sample(x * m_width, y * m_height);
83 }
Color sample(const float x, const float y) const
renvoie la couleur interpolee a la position (x, y) [0 .. width]x[0 .. height].
◆ data() [1/2]
| const float * Image::data |
( |
| ) |
const |
|
inline |
renvoie un const pointeur sur le stockage des couleurs des pixels.
Definition at line 86 of file image.h.
87 {
88 assert(!m_pixels.empty());
89 return (const float *) m_pixels.data();
90 }
◆ data() [2/2]
renvoie un pointeur sur le stockage des couleurs des pixels.
Definition at line 93 of file image.h.
94 {
95 assert(!m_pixels.empty());
96 return (float *) m_pixels.data();
97 }
◆ width()
| int Image::width |
( |
| ) |
const |
|
inline |
renvoie la largeur de l'image.
Definition at line 100 of file image.h.
◆ height()
| int Image::height |
( |
| ) |
const |
|
inline |
renvoie la hauteur de l'image.
Definition at line 102 of file image.h.
◆ size()
| unsigned Image::size |
( |
| ) |
const |
|
inline |
renvoie le nombre de pixels de l'image.
Definition at line 104 of file image.h.
104{ return m_width * m_height; }
◆ offset()
| unsigned Image::offset |
( |
const int |
x, |
|
|
const int |
y |
|
) |
| const |
|
inline |
renvoie l'indice du pixel (x, y) [0 .. width]x[0 .. height]. renvoie le pixel le plus proche si (x, y) est en dehors de l'image...
Definition at line 108 of file image.h.
109 {
110 int px= x;
111 if(px < 0) px= 0;
112 if(px > m_width-1) px= m_width-1;
113 int py= y;
114 if(py < 0) py= 0;
115 if(py > m_height-1) py= m_height-1;
116
117 unsigned p= py * m_width + px;
118 assert(p < m_pixels.size());
119 return p;
120 }
◆ m_pixels
| std::vector<Color> Image::m_pixels |
|
protected |
◆ m_width
◆ m_height
The documentation for this class was generated from the following file: