33 #if MRPT_HAS_ASIAN_FONTS 61 #define SAVE_COMPRESSED(ARR) \ 63 list_registered_fonts[#ARR].resize(sizeof(mrpt_font_##ARR)); \ 65 &list_registered_fonts[#ARR][0], mrpt_font_##ARR, \ 66 sizeof(mrpt_font_##ARR)); \ 67 cout << #ARR << " -> " << sizeof(mrpt_font_##ARR) << endl; \ 68 CFileGZOutputStream f( \ 69 string("mrpt_font_") + string(#ARR) + string(".gz")); \ 70 f.WriteBuffer(mrpt_font_##ARR, sizeof(mrpt_font_##ARR)); \ 82 #if MRPT_HAS_ASIAN_FONTS 88 #if 1 // Normal operation: Load fonts and uncompress them: 90 #define LOAD_FONT(FONTNAME) \ 92 vector_byte tmpBuf(sizeof(mrpt_font_gz_##FONTNAME)); \ 94 &tmpBuf[0], mrpt_font_gz_##FONTNAME, \ 95 sizeof(mrpt_font_gz_##FONTNAME)); \ 96 mrpt::compress::zip::decompress_gz_data_block( \ 97 tmpBuf, list_registered_fonts[#FONTNAME]); \ 107 #if MRPT_HAS_ASIAN_FONTS 142 float Ax = (float)(x1 - x0);
143 float Ay = (float)(y1 - y0);
146 if (Ax == 0 && Ay == 0)
return;
147 if (x0 < 0 && x1 < 0)
return;
148 if (y0 < 0 && y1 < 0)
return;
153 int i, N = (int)ceil(dist);
161 for (i = 0; i < N; i++)
176 int w_min = (int)-ceil(((
float)
width) / 2);
177 int w_max = (int)floor(((
float)
width) / 2);
179 for (
int w = w_min;
w <= w_max;
w++)
219 int x_min = max(x0, 0);
221 int y_min = max(y0, 0);
224 for (
int y = y_min;
y <= y_max;
y++)
241 cerr <<
"[CCanvas::selectTextFont] Warning: Unknown font: " << fontName
248 reinterpret_cast<const uint32_t*
>(&it->second[0]);
260 int img_lx =
img.getWidth();
261 int img_ly =
img.getHeight();
265 for (
int xx = 0; xx < img_lx; xx++)
266 for (
int yy = 0; yy < img_ly; yy++)
273 for (
int xx = 0; xx < img_lx; xx++)
274 for (
int yy = 0; yy < img_ly; yy++)
276 c = *((
unsigned char*)
img(xx, yy));
277 col =
c | (
c << 8) | (
c << 16);
339 if (radius < 0) radius = -radius;
349 nSegments = int(
M_2PI * radius);
352 int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
353 double ang, Aa =
M_2PI / (nSegments - 1);
356 for (i = 0, ang = 0; i < nSegments; i++, ang += Aa)
358 x2 =
round(
x + radius * cos(ang));
359 y2 =
round(
y + radius * sin(ang));
380 bool y_axis_reversed =
false;
395 for (
size_t i = 0; i < uniStr.size(); i++)
397 const uint16_t& unichar = uniStr[i];
401 uint32_t charset_ini = table_ptr[0];
402 uint32_t charset_end = table_ptr[1];
407 if (unichar <= charset_end && unichar >= charset_ini)
410 unsigned pyy = y_axis_reversed ? (py + char_h - 1) : py;
414 table_ptr + 2 + char_h * (unichar - charset_ini);
416 for (
unsigned y = 0;
y < char_h;
417 y++, pyy += y_axis_reversed ? -1 : 1)
421 for (
unsigned x = 0;
x < char_w;
x++, pxx++)
434 uint32_t n_chars = charset_end - charset_ini + 1;
435 table_ptr += 2 + n_chars * char_h;
438 charset_ini = table_ptr[0];
439 charset_end = table_ptr[1];
virtual void textOut(int x0, int y0, const std::string &str, const mrpt::utils::TColor color)
Renders 2D text using bitmap fonts.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
unsigned __int16 uint16_t
std::string m_selectedFont
The selected font name.
A class for storing images as grayscale or RGB bitmaps.
virtual void line(int x0, int y0, int x1, int y1, const mrpt::utils::TColor color, unsigned int width=1, TPenStyle penStyle=psSolid)
Draws a line.
GLenum GLenum GLenum GLenum GLenum scale
#define THROW_EXCEPTION(msg)
virtual size_t getHeight() const =0
Returns the height of the image in pixels.
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)
void triangle(int x0, int y0, int size, const mrpt::utils::TColor color, bool inferior=true, unsigned int width=1)
Draws a triangle.
const Scalar * const_iterator
GLubyte GLubyte GLubyte GLubyte w
T square(const T x)
Inline function for the square of a number.
virtual void setPixel(int x, int y, size_t color)=0
Changes the value of the pixel (x,y).
#define LOAD_FONT(FONTNAME)
const uint32_t * m_selectedFontBitmaps
Direct access to character bitmaps.
void decodeUTF8(const std::string &strUTF8, vector_word &out_uniStr)
Decodes a UTF-8 string into an UNICODE string.
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
map< string, vector_byte > list_registered_fonts
void cross(int x0, int y0, const mrpt::utils::TColor color, char type, unsigned int size=5, unsigned int width=1)
Draw a cross.
virtual void selectTextFont(const std::string &fontName)
Select the current font used when drawing text.
GLsizei const GLchar ** string
virtual void filledRectangle(int x0, int y0, int x1, int y1, const mrpt::utils::TColor color)
Draws a filled rectangle.
virtual size_t getWidth() const =0
Returns the width of the image in pixels.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
virtual void drawCircle(int x, int y, int radius, const mrpt::utils::TColor &color=mrpt::utils::TColor(255, 255, 255), unsigned int width=1)
Draws a circle of a given radius.
std::vector< uint16_t > vector_word
GLenum GLenum GLvoid * row
bool isOriginTopLeft() const
Returns true if the coordinates origin is top-left, or false if it is bottom-left.
int round(const T value)
Returns the closer integer (int) to x.
TPenStyle
Definition of pen styles.
unsigned __int32 uint32_t
GLuint GLuint GLsizei GLenum type
virtual void drawImage(int x, int y, const utils::CImage &img)
Draws an image as a bitmap at a given position.