28 #include <mrpt/config.h> 29 #ifdef MRPT_OS_WINDOWS 39 : m_scale(scaleFactor), m_targetFile(targetFileName)
41 #ifdef MRPT_OS_WINDOWS 43 CreateEnhMetaFileA(
nullptr, targetFileName.c_str(),
nullptr,
nullptr);
58 #ifdef MRPT_OS_WINDOWS 67 DeleteEnhMetaFile(CloseEnhMetaFile((HDC)
m_hdc.
get()));
81 #ifdef MRPT_OS_WINDOWS 84 LPBITMAPINFO pBmpInfo =
85 (LPBITMAPINFO)
new unsigned char[
sizeof(BITMAPINFOHEADER) +
86 (256 *
sizeof(RGBQUAD))];
90 unsigned int imgWidth = (
unsigned int)
img.getWidth();
91 unsigned int imgHeight = (
unsigned int)
img.getHeight();
93 pBmpInfo->bmiHeader.biSize =
sizeof(BITMAPINFOHEADER);
94 pBmpInfo->bmiHeader.biWidth = imgWidth;
95 pBmpInfo->bmiHeader.biHeight = imgHeight;
96 pBmpInfo->bmiHeader.biPlanes = 1;
98 pBmpInfo->bmiHeader.biBitCount = 8;
99 pBmpInfo->bmiHeader.biCompression = BI_RGB;
100 pBmpInfo->bmiHeader.biSizeImage = 0;
101 pBmpInfo->bmiHeader.biXPelsPerMeter =
102 pBmpInfo->bmiHeader.biYPelsPerMeter = 0;
103 pBmpInfo->bmiHeader.biClrUsed = 0;
104 pBmpInfo->bmiHeader.biClrImportant = 0;
107 for (
unsigned char i = 0; i < 255; i++)
109 pBmpInfo->bmiColors[i].rgbRed = i;
110 pBmpInfo->bmiColors[i].rgbGreen = i;
111 pBmpInfo->bmiColors[i].rgbBlue = i;
112 pBmpInfo->bmiColors[i].rgbReserved = 0;
116 unsigned int lineBytes = imgWidth;
117 if (lineBytes % 2) lineBytes++;
118 if (lineBytes % 4) lineBytes += 2;
120 BYTE* ptrBits =
new BYTE[lineBytes * imgHeight];
122 for (
unsigned int py = 0; py < imgHeight; py++)
123 for (
unsigned int px = 0; px < imgWidth; px++)
124 ptrBits[(py * lineBytes + px) + 0] = *
img(px, py);
126 HBITMAP hBitmap = CreateDIBitmap(
127 (HDC)
m_hdc.
get(), &pBmpInfo->bmiHeader, CBM_INIT, ptrBits, pBmpInfo,
133 GetObject(hBitmap,
sizeof(bm), &bm);
135 HDC hdcMem = CreateCompatibleDC((HDC)
m_hdc.
get());
136 HBITMAP hbmT = (HBITMAP)SelectObject(hdcMem, hBitmap);
140 (int)(
m_scale * imgHeight), hdcMem, 0, 0, SRCCOPY);
142 SelectObject(hdcMem, hbmT);
147 DeleteObject(hBitmap);
167 #ifdef MRPT_OS_WINDOWS 173 HPEN hPen = CreatePen(penStyle,
width, (
unsigned int)
color);
175 HPEN hOldPen = (HPEN)SelectObject((HDC)
m_hdc.
get(), hPen);
177 MoveToEx((HDC)
m_hdc.
get(), x0, y0,
nullptr);
180 SelectObject((HDC)
m_hdc.
get(), hOldPen);
193 #ifdef MRPT_OS_WINDOWS 197 ::SetBkMode((HDC)
m_hdc.
get(), TRANSPARENT);
200 ::TextOutA((HDC)
m_hdc.
get(), x0, y0, str.c_str(), (int)str.size());
210 const std::string& fontName,
int fontSize,
bool bold,
bool italic)
212 #ifdef MRPT_OS_WINDOWS 213 HFONT hFont, oldFont;
216 lpf.lfHeight = fontSize;
218 lpf.lfEscapement = 0;
219 lpf.lfOrientation = 0;
220 lpf.lfWeight = bold ? 700 : 400;
221 lpf.lfItalic = italic ? 1 : 0;
224 lpf.lfCharSet = DEFAULT_CHARSET;
225 lpf.lfOutPrecision = OUT_DEFAULT_PRECIS;
226 lpf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
227 lpf.lfQuality = DEFAULT_QUALITY;
228 lpf.lfPitchAndFamily = DEFAULT_PITCH;
229 os::strcpy(lpf.lfFaceName, LF_FACESIZE, fontName.c_str());
231 hFont = ::CreateFontIndirectA(&lpf);
233 oldFont = (HFONT)::SelectObject((HDC)
m_hdc.
get(), hFont);
235 if (oldFont) ::DeleteObject(oldFont);
253 #ifdef MRPT_OS_WINDOWS
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
A class for storing images as grayscale or RGB bitmaps.
#define THROW_EXCEPTION(msg)
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
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.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLsizei const GLfloat * value
char * strcpy(char *dest, size_t destSize, const char *source) noexcept
An OS-independent version of strcpy.
TPenStyle
Definition of pen styles.