Geogram
Version 1.9.1-rc
A programming library of geometric algorithms
|
Draws triangles in an image. More...
#include <geogram/image/image_rasterizer.h>
Public Member Functions | |
ImageRasterizer (Image *image) | |
ImageRasterizer constructor. More... | |
void | clear () |
Clears the target image. | |
void | triangle (const vec2i &P1, const Color &c1, const vec2i &P2, const Color &c2, const vec2i &P3, const Color &c3) |
Draws a triangle in the target image. More... | |
void | triangle (const vec2 &p1, const Color &c1, const vec2 &p2, const Color &c2, const vec2 &p3, const Color &c3) |
Draws a triangle in the target image. More... | |
void | segment (const vec2i &P1, const vec2i &P2, const Color &c) |
Draws a segment in the target image. More... | |
void | segment (const vec2 &p1, const vec2 &p2, const Color &c) |
Draws a segment in the target image. More... | |
void | fillcircle (const vec2i &C, int radius, const Color &c) |
Fills a circle in the target image. More... | |
void | fillcircle (const vec2 &C, double radius, const Color &c) |
Fills a circle in the target image. More... | |
void | flood_fill (int x, int y, const Color &c) |
Flood-fill from a given pixel. More... | |
void | set_pixel (int x, int y, const Color &c) |
Sets a pixel of the image. More... | |
bool | pixel_is_black (int x, int y) const |
Tests whether a given pixel is black. More... | |
Protected Member Functions | |
vec2i | transform (const vec2 &p) const |
Transforms a 2d point from world space to pixel coordinates. More... | |
void | interpolate_color (const Color &c1, const Color &c2, const Color &c3, double l1, double l2, double l3, Color &c) const |
Computes the linear interpolation between three colors. More... | |
Draws triangles in an image.
Definition at line 56 of file image_rasterizer.h.
GEO::ImageRasterizer::ImageRasterizer | ( | Image * | image | ) |
ImageRasterizer constructor.
[in] | image | a pointer to the target image. |
Fills a circle in the target image.
The circle is clipped to the image
[in] | C | the center of the circle, coordinates are between 0.0 and 1.0. |
[in] | radius | the radius of the circle. A value of 1.0 corresponds to the width of the image. |
[in] | c | the color of the pixels |
Definition at line 151 of file image_rasterizer.h.
Fills a circle in the target image.
The circle is clipped to the image
[in] | C | the center of the circle, integer coordinates are in [0..width-1]x[0..height-1], where width and height are the sizes of the target image. |
[in] | radius | the radius of the circle (in pixels). |
[in] | c | the color of the pixels |
void GEO::ImageRasterizer::flood_fill | ( | int | x, |
int | y, | ||
const Color & | c | ||
) |
Flood-fill from a given pixel.
Fills the connected component of black (zero) pixels incident to x,y
|
inlineprotected |
Computes the linear interpolation between three colors.
[in] | c1,c2,c3 | the three colors to be interpolated. |
[in] | l1,l2,l3 | the coefficients of the interpolation. |
[out] | c | the interpolated color. |
Definition at line 250 of file image_rasterizer.h.
|
inline |
Tests whether a given pixel is black.
Only implemented for BYTE component encoding
[in] | x,y | the integer coordinates of the pixel |
true | if the pixel is black |
false | otherwise |
Definition at line 219 of file image_rasterizer.h.
Draws a segment in the target image.
No clipping is done. It is the responsibility of the caller to give valid coordinates.
[in] | p1,p2 | the two extremities of the segment. coordinates are in the [0,1]x[0,1] square. |
[in] | c | the color |
Definition at line 127 of file image_rasterizer.h.
Draws a segment in the target image.
No clipping is done. It is the responsibility of the caller to give valid coordinates.
[in] | P1,P2 | the two extremities of the segment. integer coordinates are in [0..width-1]x[0..height-1], where width and height are the sizes of the target image. |
[in] | c | the color |
|
inline |
Sets a pixel of the image.
Only BYTE, FLOAT32 and FLOAT64 component encoding are supported. If the image has less than 4 channels, the extra channels in c
are ignored.
[in] | x,y | the integer pixel coordinates |
[in] | c | the color of the pixel |
Definition at line 174 of file image_rasterizer.h.
Transforms a 2d point from world space to pixel coordinates.
[in] | p | coordinates of the points, in [0,1]x[0,1] |
Definition at line 237 of file image_rasterizer.h.
|
inline |
Draws a triangle in the target image.
Colors are linearly interpolated (Gouraud shading). No clipping is done. It is the responsibility of the caller to give coordinates in the viewport.
[in] | p1,p2,p3 | the three vertices of the triangle, coordinates are in the [0,1]x[0,1] square. |
[in] | c1,c2,c3 | the three colors of the vertices. |
Definition at line 96 of file image_rasterizer.h.
void GEO::ImageRasterizer::triangle | ( | const vec2i & | P1, |
const Color & | c1, | ||
const vec2i & | P2, | ||
const Color & | c2, | ||
const vec2i & | P3, | ||
const Color & | c3 | ||
) |
Draws a triangle in the target image.
Colors are linearly interpolated (Gouraud shading). No clipping is done. It is the responsibility of the caller to give coordinates in the viewport.
[in] | P1,P2,P3 | the three vertices of the triangle, integer coordinates are in [0..width-1]x[0..height-1], where width and height are the sizes of the target image. |
[in] | c1,c2,c3 | the three colors of the vertices. |