Main MRPT website > C++ reference for MRPT 1.5.9
CEnhancedMetaFile_LIN.cpp
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #include "base-precomp.h" // Precompiled headers
11 
12 #include <mrpt/config.h>
13 
14 #if defined(MRPT_OS_LINUX) || defined(MRPT_OS_APPLE)
15 
17 #include <mrpt/utils/CImage.h>
18 
19 using namespace mrpt;
20 using namespace mrpt::utils;
21 
22 
25 
26 
27 /*---------------------------------------------------------------
28  Constructor
29 ---------------------------------------------------------------*/
31  const std::string &targetFileName,
32  int scaleFactor ) :
33  m_scale(scaleFactor),
34  m_hFont(NULL),
35  m_targetFile(targetFileName)
36 {
39 }
40 
41 /*---------------------------------------------------------------
42  Destructor
43 ---------------------------------------------------------------*/
45 {
46  ((CImage*)m_hdc.get())->saveToFile(m_targetFile+".png");
47 
48  // Free objects:
49  delete ((CImage*)m_hdc.get());
50 }
51 
52 /*---------------------------------------------------------------
53  drawImage
54 ---------------------------------------------------------------*/
56  int x,
57  int y,
58  const CImage &img
59  )
60 {
62 
63  ((CImage*)m_hdc.get())->drawImage(x,y,img);
64 
66 }
67 
68 /*---------------------------------------------------------------
69  line
70 ---------------------------------------------------------------*/
72  int x0,
73  int y0,
74  int x1,
75  int y1,
77  unsigned int width,
78  TPenStyle penStyle
79  )
80 {
82 
83  ((CImage*)m_hdc.get())->line(x0,y0,x1,y1,color,width,penStyle);
84 
86 }
87 
88 /*---------------------------------------------------------------
89  textOut
90 ---------------------------------------------------------------*/
92  int x0,
93  int y0,
94  const std::string &str,
96  )
97 {
99 
100  ((CImage*)m_hdc.get())->textOut(x0,y0,str,color);
101 
102  MRPT_TRY_END;
103 }
104 
105 /*---------------------------------------------------------------
106  selectVectorTextFont
107 ---------------------------------------------------------------*/
109  const std::string &fontName,
110  int fontSize,
111  bool bold,
112  bool italic )
113 {
114  MRPT_UNUSED_PARAM(fontSize); MRPT_UNUSED_PARAM(bold); MRPT_UNUSED_PARAM(italic);
116 
117  ((CImage*)m_hdc.get())->selectTextFont(fontName);
118 
119  MRPT_TRY_END;
120 }
121 
122 
123 /*---------------------------------------------------------------
124  setPixel
125 ---------------------------------------------------------------*/
126 void CEnhancedMetaFile::setPixel( int x, int y, size_t color)
127 {
129 
130  ((CImage*)m_hdc.get())->setPixel(x,y, color);
131 
132  MRPT_TRY_END;
133 }
134 
135 /*---------------------------------------------------------------
136  rectangle
137 ---------------------------------------------------------------*/
139  int x0,
140  int y0,
141  int x1,
142  int y1,
144  unsigned int width)
145 {
146  line(x0,y0,x1,y0,color,width);
147  line(x1,y0,x1,y1,color,width);
148  line(x1,y1,x0,y1,color,width);
149  line(x0,y1,x0,y0,color,width);
150 }
151 
152 #endif
153 
CEnhancedMetaFile(const std::string &targetFileName, int scaleFactor=1)
Constructor.
void setPixel(int x, int y, size_t color) MRPT_OVERRIDE
Changes the value of the pixel (x,y).
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
virtual ~CEnhancedMetaFile()
Destructor.
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:101
virtual void selectVectorTextFont(const std::string &fontName, int fontSize, bool bold=false, bool italic=false)
Select the current font used when drawing text.
GLenum GLsizei width
Definition: glext.h:3513
GLuint color
Definition: glext.h:7093
#define MRPT_TRY_END
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
GLint GLvoid * img
Definition: glext.h:3645
void line(int x0, int y0, int x1, int y1, const mrpt::utils::TColor color, unsigned int width=1, TPenStyle penStyle=psSolid) MRPT_OVERRIDE
Draws a line.
virtual void selectTextFont(const std::string &fontName)
Select the current font used when drawing text.
Definition: CCanvas.cpp:249
A RGB color - 8bit.
Definition: TColor.h:26
void textOut(int x0, int y0, const std::string &str, const mrpt::utils::TColor color) MRPT_OVERRIDE
Places a text label.
GLsizei const GLchar ** string
Definition: glext.h:3919
virtual void filledRectangle(int x0, int y0, int x1, int y1, const mrpt::utils::TColor color)
Draws a filled rectangle.
Definition: CCanvas.cpp:229
virtual void rectangle(int x0, int y0, int x1, int y1, const mrpt::utils::TColor color, unsigned int width=1)
Draws a rectangle (an empty rectangle, without filling)
static int LINUX_IMG_HEIGHT
In Linux, the size of the bitmap image that emulates the EMF (Default:600)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define MRPT_TRY_START
GLenum GLint GLint y
Definition: glext.h:3516
GLenum GLint x
Definition: glext.h:3516
static int LINUX_IMG_WIDTH
In Linux, the size of the bitmap image that emulates the EMF (Default:800)
void drawImage(int x, int y, const utils::CImage &img) MRPT_OVERRIDE
Draws an image as a bitmap at a given position.



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020