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];
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.
void cross(int x0, int y0, const mrpt::img::TColor color, char type, unsigned int size=5, unsigned int width=1)
Draw a cross.
unsigned __int16 uint16_t
TPenStyle
Definition of pen styles.
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.
#define THROW_EXCEPTION(msg)
GLenum GLenum GLenum GLenum GLenum scale
void decodeUTF8(const std::string &strUTF8, std::vector< uint16_t > &out_uniStr)
Decodes a UTF-8 string into an UNICODE string.
virtual void setPixel(int x, int y, size_t color)=0
Changes the value of the pixel (x,y).
void triangle(int x0, int y0, int size, const mrpt::img::TColor color, bool inferior=true, unsigned int width=1)
Draws a triangle.
GLubyte GLubyte GLubyte GLubyte w
T square(const T x)
Inline function for the square of a number.
#define LOAD_FONT(FONTNAME)
std::string m_selectedFont
The selected font name.
virtual void selectTextFont(const std::string &fontName)
Select the current font used when drawing text.
virtual void filledRectangle(int x0, int y0, int x1, int y1, const mrpt::img::TColor color)
Draws a filled rectangle.
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)
GLsizei const GLchar ** string
map< string, std::vector< uint8_t > > list_registered_fonts
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.
bool isOriginTopLeft() const
Returns true if the coordinates origin is top-left, or false if it is bottom-left.
GLenum GLenum GLvoid * row
virtual void textOut(int x0, int y0, const std::string &str, const mrpt::img::TColor color)
Renders 2D text using bitmap fonts.
virtual size_t getHeight() const =0
Returns the height of the image in pixels.
virtual void drawImage(int x, int y, const mrpt::img::CImage &img)
Draws an image as a bitmap at a given position.
unsigned __int32 uint32_t
const Scalar * const_iterator
GLuint GLuint GLsizei GLenum type
const uint32_t * m_selectedFontBitmaps
Direct access to character bitmaps.
A class for storing images as grayscale or RGB bitmaps.
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.
int round(const T value)
Returns the closer integer (int) to x.