Go to the documentation of this file.
30 #if MRPT_HAS_ASIAN_FONTS
45 map<string, std::vector<uint8_t>>
59 #define SAVE_COMPRESSED(ARR) \
61 list_registered_fonts[#ARR].resize(sizeof(mrpt_font_##ARR)); \
63 &list_registered_fonts[#ARR][0], mrpt_font_##ARR, \
64 sizeof(mrpt_font_##ARR)); \
65 cout << #ARR << " -> " << sizeof(mrpt_font_##ARR) << endl; \
66 CFileGZOutputStream f( \
67 string("mrpt_font_") + string(#ARR) + string(".gz")); \
68 f.WriteBuffer(mrpt_font_##ARR, sizeof(mrpt_font_##ARR)); \
80 #if MRPT_HAS_ASIAN_FONTS
86 #if 1 // Normal operation: Load fonts and uncompress them:
88 #define LOAD_FONT(FONTNAME) \
90 std::vector<uint8_t> tmpBuf(sizeof(mrpt_font_gz_##FONTNAME)); \
92 &tmpBuf[0], mrpt_font_gz_##FONTNAME, \
93 sizeof(mrpt_font_gz_##FONTNAME)); \
94 mrpt::io::zip::decompress_gz_data_block( \
95 tmpBuf, list_registered_fonts[#FONTNAME]); \
105 #if MRPT_HAS_ASIAN_FONTS
140 float Ax = (float)(x1 - x0);
141 float Ay = (float)(y1 - y0);
144 if (Ax == 0 && Ay == 0)
return;
145 if (x0 < 0 && x1 < 0)
return;
146 if (y0 < 0 && y1 < 0)
return;
151 int i, N = (int)ceil(dist);
159 for (i = 0; i < N; i++)
174 int w_min = (int)-ceil(((
float)
width) / 2);
175 int w_max = (int)floor(((
float)
width) / 2);
177 for (
int w = w_min;
w <= w_max;
w++)
217 int x_min = max(x0, 0);
219 int y_min = max(y0, 0);
222 for (
int y = y_min;
y <= y_max;
y++)
239 cerr <<
"[CCanvas::selectTextFont] Warning: Unknown font: " << fontName
246 reinterpret_cast<const uint32_t*
>(&it->second[0]);
258 int img_lx =
img.getWidth();
259 int img_ly =
img.getHeight();
263 for (
int xx = 0; xx < img_lx; xx++)
264 for (
int yy = 0; yy < img_ly; yy++)
271 for (
int xx = 0; xx < img_lx; xx++)
272 for (
int yy = 0; yy < img_ly; yy++)
274 c = *((
unsigned char*)
img(xx, yy));
275 col =
c | (
c << 8) | (
c << 16);
337 if (radius < 0) radius = -radius;
347 nSegments = int(
M_2PI * radius);
350 int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
351 double ang, Aa =
M_2PI / (nSegments - 1);
354 for (i = 0, ang = 0; i < nSegments; i++, ang += Aa)
356 x2 =
round(
x + radius * cos(ang));
357 y2 =
round(
y + radius * sin(ang));
378 bool y_axis_reversed =
false;
383 std::vector<uint16_t> uniStr;
393 for (
size_t i = 0; i < uniStr.size(); i++)
395 const uint16_t& unichar = uniStr[i];
399 uint32_t charset_ini = table_ptr[0];
400 uint32_t charset_end = table_ptr[1];
405 if (unichar <= charset_end && unichar >= charset_ini)
408 unsigned pyy = y_axis_reversed ? (py + char_h - 1) : py;
412 table_ptr + 2 + char_h * (unichar - charset_ini);
414 for (
unsigned y = 0;
y < char_h;
415 y++, pyy += y_axis_reversed ? -1 : 1)
419 for (
unsigned x = 0;
x < char_w;
x++, pxx++)
432 uint32_t n_chars = charset_end - charset_ini + 1;
433 table_ptr += 2 + n_chars * char_h;
436 charset_ini = table_ptr[0];
437 charset_end = table_ptr[1];
void triangle(int x0, int y0, int size, const mrpt::img::TColor color, bool inferior=true, unsigned int width=1)
Draws a triangle.
const Scalar * const_iterator
virtual void setPixel(int x, int y, size_t color)=0
Changes the value of the pixel (x,y).
unsigned __int16 uint16_t
void cross(int x0, int y0, const mrpt::img::TColor color, char type, unsigned int size=5, unsigned int width=1)
Draw a cross.
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.
void decodeUTF8(const std::string &strUTF8, std::vector< uint16_t > &out_uniStr)
Decodes a UTF-8 string into an UNICODE string.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLubyte GLubyte GLubyte GLubyte w
GLuint GLuint GLsizei GLenum type
#define THROW_EXCEPTION(msg)
T square(const T x)
Inline function for the square of a number.
std::string m_selectedFont
The selected font name.
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)
int round(const T value)
Returns the closer integer (int) to x.
bool isOriginTopLeft() const
Returns true if the coordinates origin is top-left, or false if it is bottom-left
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.
virtual size_t getHeight() const =0
Returns the height of the image in pixels.
virtual size_t getWidth() const =0
Returns the width of the image in pixels.
A class for storing images as grayscale or RGB bitmaps.
GLenum GLenum GLenum GLenum GLenum scale
virtual void drawImage(int x, int y, const mrpt::img::CImage &img)
Draws an image as a bitmap at a given position.
GLenum GLenum GLvoid * row
const uint32_t * m_selectedFontBitmaps
Direct access to character bitmaps.
GLsizei const GLchar ** string
virtual void textOut(int x0, int y0, const std::string &str, const mrpt::img::TColor color)
Renders 2D text using bitmap fonts.
#define LOAD_FONT(FONTNAME)
map< string, std::vector< uint8_t > > list_registered_fonts
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.
TPenStyle
Definition of pen styles.
unsigned __int32 uint32_t
virtual void filledRectangle(int x0, int y0, int x1, int y1, const mrpt::img::TColor color)
Draws a filled rectangle.
virtual void selectTextFont(const std::string &fontName)
Select the current font used when drawing text.
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST | |