|
MRPT
1.9.9
|
This virtual class defines the interface of any object accepting drawing primitives on it.
A number of text fonts can be selected with CCanvas::selectTextFont(). These are the implemented font names:
For an example of each font check the corresponding wiki page.
#include <mrpt/img/CCanvas.h>

Public Types | |
| enum | TPenStyle { psSolid = 0, psDash, psDot, psDashDot, psDashDotDot } |
| Definition of pen styles. More... | |
Public Member Functions | |
| CCanvas () | |
| virtual | ~CCanvas () |
| Dummy virtual destructor: More... | |
| virtual void | setPixel (int x, int y, size_t color)=0 |
| Changes the value of the pixel (x,y). More... | |
| virtual size_t | getWidth () const =0 |
| Returns the width of the image in pixels. More... | |
| virtual size_t | getHeight () const =0 |
| Returns the height of the image in pixels. More... | |
| virtual void | line (int x0, int y0, int x1, int y1, const mrpt::img::TColor color, unsigned int width=1, TPenStyle penStyle=psSolid) |
| Draws a line. More... | |
| void | rectangle (int x0, int y0, int x1, int y1, const mrpt::img::TColor color, unsigned int width=1) |
| Draws a rectangle (an empty rectangle, without filling) More... | |
| void | triangle (int x0, int y0, int size, const mrpt::img::TColor color, bool inferior=true, unsigned int width=1) |
| Draws a triangle. More... | |
| virtual void | filledRectangle (int x0, int y0, int x1, int y1, const mrpt::img::TColor color) |
| Draws a filled rectangle. More... | |
| virtual void | textOut (int x0, int y0, const std::string &str, const mrpt::img::TColor color) |
| Renders 2D text using bitmap fonts. More... | |
| virtual void | selectTextFont (const std::string &fontName) |
| Select the current font used when drawing text. More... | |
| virtual void | drawImage (int x, int y, const mrpt::img::CImage &img) |
| Draws an image as a bitmap at a given position. More... | |
| void | cross (int x0, int y0, const mrpt::img::TColor color, char type, unsigned int size=5, unsigned int width=1) |
| Draw a cross. More... | |
| virtual void | drawImage (int x, int y, const mrpt::img::CImage &img, float rotation, float scale) |
| Draws an image as a bitmap at a given position, with some custom scale and rotation changes. More... | |
| virtual void | drawCircle (int x, int y, int radius, const mrpt::img::TColor &color=mrpt::img::TColor(255, 255, 255), unsigned int width=1) |
| Draws a circle of a given radius. More... | |
| template<class MATRIX2X2 > | |
| void | ellipseGaussian (const MATRIX2X2 *cov2D, const double mean_x, const double mean_y, double confIntervalStds=2, const mrpt::img::TColor &color=mrpt::img::TColor(255, 255, 255), unsigned int width=1, int nEllipsePoints=20) |
| Draws an ellipse representing a given confidence interval of a 2D Gaussian distribution. More... | |
| template<class FEATURELIST > | |
| void | drawFeaturesSimple (const FEATURELIST &list, const TColor &color=TColor::red(), const int cross_size=5) |
| Draws a set of marks onto the image, given a generic container of entities having just "x" and "y" fields. More... | |
| template<class FEATURELIST > | |
| void | drawFeatures (const FEATURELIST &list, const TColor &color=TColor::red(), const bool showIDs=false, const bool showResponse=false) |
| Draws a set of marks (or scaled circles for features with scale) onto the image, given a generic container of features. More... | |
Protected Attributes | |
| std::string | m_selectedFont |
| The selected font name. More... | |
| const uint32_t * | m_selectedFontBitmaps |
| Direct access to character bitmaps. More... | |
| enum mrpt::img::CCanvas::TPenStyle |
| CCanvas::CCanvas | ( | ) |
Definition at line 118 of file CCanvas.cpp.
|
inlinevirtual |
| void CCanvas::cross | ( | int | x0, |
| int | y0, | ||
| const mrpt::img::TColor | color, | ||
| char | type, | ||
| unsigned int | size = 5, |
||
| unsigned int | width = 1 |
||
| ) |
Draw a cross.
| x0 | The point x coordinate |
| y0 | The point y coordinate |
| color | The color of the cross |
| size | The size of the cross |
| type | The cross type. It could be: 'x', '+' or ':'(like '+' but clear at the center dot) |
| width | The desired width of the cross (this is IGNORED yet) |
Definition at line 305 of file CCanvas.cpp.
References line(), and THROW_EXCEPTION.
Referenced by drawFeatures(), drawFeaturesSimple(), find_chessboard_corners_multiple(), and mrpt::gui::CDisplayWindow::plot().
|
virtual |
Draws a circle of a given radius.
| x | The center - x coordinate in pixels. |
| y | The center - y coordinate in pixels. |
| radius | The radius - in pixels. |
| color | The color of the circle. |
| width | The desired width of the line (this is IGNORED in this virtual class) |
Reimplemented in mrpt::img::CImage.
Definition at line 333 of file CCanvas.cpp.
References line(), M_2PI, and mrpt::round().
Referenced by drawFeatures().
|
inline |
Draws a set of marks (or scaled circles for features with scale) onto the image, given a generic container of features.
The class of FEATURELIST can be:
Definition at line 321 of file CCanvas.h.
References cross(), drawCircle(), mrpt::format(), mrpt::img::TColor::red(), mrpt::round(), and textOut().
|
inline |
Draws a set of marks onto the image, given a generic container of entities having just "x" and "y" fields.
The class of FEATURELIST can be, for example, std::vector<mrpt::math::TPoint2D>, std::vector<TPixelCoordsf> or mrpt::vision::CFeatureList
Definition at line 300 of file CCanvas.h.
References cross(), and mrpt::round().
|
virtual |
Draws an image as a bitmap at a given position.
| x0 | The top-left corner x coordinates on this canvas where the image is to be drawn |
| y0 | The top-left corner y coordinates on this canvas where the image is to be drawn |
| img | The image to be drawn in this canvas This method may be redefined in some classes implementing this interface in a more appropiate manner. |
Reimplemented in mrpt::img::CEnhancedMetaFile.
Definition at line 254 of file CCanvas.cpp.
References MRPT_END, MRPT_START, and setPixel().
Referenced by mrpt::slam::CGridMapAligner::AlignPDF_robustMatch(), mrpt::slam::CMetricMapBuilderRBPF::drawCurrentEstimationToImage(), and mrpt::img::CEnhancedMetaFile::drawImage().
|
virtual |
Draws an image as a bitmap at a given position, with some custom scale and rotation changes.
| x0 | The top-left corner x coordinates on this canvas where the image is to be drawn |
| y0 | The top-left corner y coordinates on this canvas where the image is to be drawn |
| rotation | The rotation in radians, positive values being anti-clockwise direction, 0 is the normal position. |
| scale | The scale factor, e.g. 2 means twice the original size. |
| img | The image to be drawn in this canvas This method may be redefined in some classes implementing this interface in a more appropiate manner. |
Reimplemented in mrpt::img::CEnhancedMetaFile.
Definition at line 286 of file CCanvas.cpp.
References MRPT_END, MRPT_START, MRPT_UNUSED_PARAM, and THROW_EXCEPTION.
|
inline |
Draws an ellipse representing a given confidence interval of a 2D Gaussian distribution.
| mean_x | The x coordinate of the center point of the ellipse. |
| mean_y | The y coordinate of the center point of the ellipse. |
| cov2D | A 2x2 covariance matrix. |
| confIntervalStds | How many "sigmas" for the confidence level (i.e. 2->95%, 3=99.97%,...) |
| color | The color of the ellipse |
| width | The desired width of the line (this is IGNORED in this virtual class) |
| nEllipsePoints | The number of points to generate to approximate the ellipse shape. |
| std::exception | On an invalid matrix. |
Definition at line 250 of file CCanvas.h.
References line(), M_2PI, MRPT_END_WITH_CLEAN_UP, MRPT_START, and mrpt::round().
|
virtual |
Draws a filled rectangle.
| x0 | The top-left x coordinate |
| y0 | The top-left y coordinate |
| x1 | The right-bottom x coordinate |
| y1 | The right-bottom y coordinate |
| color | The color of the rectangle fill This method may be redefined in some classes implementing this interface in a more appropiate manner. |
Definition at line 214 of file CCanvas.cpp.
References getHeight(), getWidth(), min, and setPixel().
Referenced by mrpt::slam::CGridMapAligner::AlignPDF_robustMatch(), mrpt::img::CEnhancedMetaFile::CEnhancedMetaFile(), and mrpt::gui::CDisplayWindow::plot().
|
pure virtual |
Returns the height of the image in pixels.
Implemented in mrpt::img::CImage, and mrpt::img::CEnhancedMetaFile.
Referenced by filledRectangle(), and line().
|
pure virtual |
Returns the width of the image in pixels.
Implemented in mrpt::img::CImage, and mrpt::img::CEnhancedMetaFile.
Referenced by filledRectangle(), and line().
|
virtual |
Draws a line.
| x0 | The starting point x coordinate |
| y0 | The starting point y coordinate |
| x1 | The end point x coordinate |
| y1 | The end point y coordinate |
| color | The color of the line |
| width | The desired width of the line (this is IGNORED in this virtual class) This method may be redefined in some classes implementing this interface in a more appropiate manner. |
Reimplemented in mrpt::img::CImage, and mrpt::img::CEnhancedMetaFile.
Definition at line 122 of file CCanvas.cpp.
References getHeight(), getWidth(), MRPT_UNUSED_PARAM, setPixel(), and mrpt::square().
Referenced by cross(), drawCircle(), ellipseGaussian(), rectangle(), and triangle().
| void CCanvas::rectangle | ( | int | x0, |
| int | y0, | ||
| int | x1, | ||
| int | y1, | ||
| const mrpt::img::TColor | color, | ||
| unsigned int | width = 1 |
||
| ) |
Draws a rectangle (an empty rectangle, without filling)
| x0 | The top-left x coordinate |
| y0 | The top-left y coordinate |
| x1 | The right-bottom x coordinate |
| y1 | The right-bottom y coordinate |
| color | The color of the line |
| width | The desired width of the line. |
Definition at line 170 of file CCanvas.cpp.
References line().
Referenced by mrpt::vision::addFeaturesToImage().
|
virtual |
Select the current font used when drawing text.
| fontName | The name of the font |
Valid font names:
18x18ja (Asian characters for UTF-8 strings - Only available if MRPT is built with MRPT_HAS_ASIAN_FONTS = true)
Definition at line 229 of file CCanvas.cpp.
References init_fonts_list(), list_registered_fonts, m_selectedFont, and m_selectedFontBitmaps.
Referenced by mrpt::img::CImage::drawChessboardCorners(), mrpt::img::CEnhancedMetaFile::selectVectorTextFont(), and textOut().
|
pure virtual |
Changes the value of the pixel (x,y).
Pixel coordinates starts at the left-top corner of the image, and start in (0,0). The meaning of the parameter "color" depends on the implementation: it will usually be a 24bit RGB value (0x00RRGGBB), but it can also be just a 8bit gray level.
You can also use a TColor() type as input and it will be automatically converted to size_t.
This method must support (x,y) values OUT of the actual image size without neither raising exceptions, nor leading to memory access errors.
Implemented in mrpt::img::CImage, and mrpt::img::CEnhancedMetaFile.
Referenced by drawImage(), filledRectangle(), line(), and textOut().
|
virtual |
Renders 2D text using bitmap fonts.
| x0 | The x coordinates |
| y0 | The y coordinates |
| str | The string to put. If using UNICODE characters, use UTF-8 encoding. |
| color | The text color |
Reimplemented in mrpt::img::CEnhancedMetaFile.
Definition at line 369 of file CCanvas.cpp.
References mrpt::system::decodeUTF8(), mrpt::img::CImage::isOriginTopLeft(), m_selectedFontBitmaps, MRPT_END, MRPT_START, selectTextFont(), and setPixel().
Referenced by mrpt::img::CImage::drawChessboardCorners(), drawFeatures(), and mrpt::gui::CDisplayWindow::plot().
| void CCanvas::triangle | ( | int | x0, |
| int | y0, | ||
| int | size, | ||
| const mrpt::img::TColor | color, | ||
| bool | inferior = true, |
||
| unsigned int | width = 1 |
||
| ) |
Draws a triangle.
| x0 | The triangle center x coordinate |
| y0 | The triangle center y coordinate |
| size | The size of the triangle |
| color | The color of the line |
| inferior | The position of the triangle |
| width | The desired width of the line. |
Definition at line 190 of file CCanvas.cpp.
References line(), and mrpt::round().
|
protected |
|
protected |
Direct access to character bitmaps.
Definition at line 47 of file CCanvas.h.
Referenced by selectTextFont(), and textOut().
| Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020 |