36 #if MRPT_HAS_ASIAN_FONTS 62 #define SAVE_COMPRESSED( ARR ) \ 64 list_registered_fonts[#ARR].resize(sizeof(mrpt_font_##ARR)); \ 65 memcpy(&list_registered_fonts[#ARR][0], mrpt_font_##ARR, sizeof(mrpt_font_##ARR)); \ 66 cout << #ARR << " -> " << sizeof(mrpt_font_##ARR) << endl; \ 67 CFileGZOutputStream f(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 vector_byte tmpBuf(sizeof(mrpt_font_gz_##FONTNAME)); \ 91 memcpy(&tmpBuf[0], mrpt_font_gz_##FONTNAME, sizeof(mrpt_font_gz_##FONTNAME)); \ 92 mrpt::compress::zip::decompress_gz_data_block(tmpBuf,list_registered_fonts[#FONTNAME]); \ 102 #if MRPT_HAS_ASIAN_FONTS 117 m_selectedFont(
"9x15"),
118 m_selectedFontBitmaps(NULL)
148 float Ax = (float)( x1-x0 );
149 float Ay = (float)( y1-y0 );
152 if (Ax==0 && Ay==0)
return;
153 if (x0<0 && x1<0)
return;
154 if (y0<0 && y1<0)
return;
159 int i,N = (int)ceil(dist);
163 x = (float)x0;
y = (float)y0;
184 int w_min = (int) -ceil(((
float)
width)/2);
185 int w_max = (int) floor(((
float)
width)/2);
187 for (
int w=w_min;
w<=w_max;
w++)
236 int x_min = max(x0,0);
238 int y_min = max(y0,0);
241 for (
int y=y_min;
y<=y_max;
y++)
242 for (
int x=x_min;
x<=x_max;
x++)
258 cerr <<
"[CCanvas::selectTextFont] Warning: Unknown font: " << fontName << endl;
278 int img_lx =
img.getWidth();
279 int img_ly =
img.getHeight();
283 for (
int xx=0;xx<img_lx;xx++)
284 for (
int yy=0;yy<img_ly;yy++)
291 for (
int xx=0;xx<img_lx;xx++)
292 for (
int yy=0;yy<img_ly;yy++)
294 c = *((
unsigned char *)
img(xx,yy));
295 col =
c | (
c<<8) | (
c<<16);
363 if (radius<0) radius=-radius;
373 nSegments = int(
M_2PI * radius);
376 int x1=0,y1=0,x2=0,y2=0;
377 double ang, Aa =
M_2PI/(nSegments-1);
380 for (i=0,ang=0;i<nSegments;i++,ang+=Aa)
382 x2 =
round(
x + radius * cos(ang) );
383 y2 =
round(
y + radius * sin(ang) );
410 bool y_axis_reversed =
false;
428 for (
size_t i=0; i<uniStr.size() ; i++)
430 const uint16_t &unichar = uniStr[i];
434 uint32_t charset_ini = table_ptr[0];
435 uint32_t charset_end = table_ptr[1];
440 if ( unichar<=charset_end && unichar>=charset_ini )
443 unsigned pyy = y_axis_reversed ? (py+char_h-1) : py;
446 const uint32_t *char_bitmap = table_ptr+ 2 + char_h*(unichar-charset_ini);
448 for (
unsigned y=0;
y<char_h;
y++,pyy+= y_axis_reversed ? -1:1 )
452 for (
unsigned x=0;
x<char_w;
x++,pxx++)
466 uint32_t n_chars = charset_end-charset_ini+1;
467 table_ptr+= 2 + n_chars * char_h;
470 charset_ini = table_ptr[0];
471 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)
map< string, vector_byte > list_registered_fonts
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 BASE_IMPEXP 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.
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.