14 #include <MRPT/config.h> 16 #ifdef MRPT_OS_WINDOWS 42 m_hdc = CreateEnhMetaFileA( NULL, targetFileName.c_str(), NULL, NULL );
60 DeleteEnhMetaFile( CloseEnhMetaFile( (HDC)
m_hdc.
get() ) );
74 LPBITMAPINFO pBmpInfo = (LPBITMAPINFO)
new unsigned char[
sizeof(BITMAPINFOHEADER) + (256 *
sizeof(RGBQUAD))];
77 unsigned int imgWidth = (
unsigned int)
img.getWidth();
78 unsigned int imgHeight = (
unsigned int)
img.getHeight();
80 pBmpInfo->bmiHeader.biSize =
sizeof( BITMAPINFOHEADER );
81 pBmpInfo->bmiHeader.biWidth = imgWidth;
82 pBmpInfo->bmiHeader.biHeight = imgHeight;
83 pBmpInfo->bmiHeader.biPlanes = 1;
85 pBmpInfo->bmiHeader.biBitCount = 8;
86 pBmpInfo->bmiHeader.biCompression = BI_RGB;
87 pBmpInfo->bmiHeader.biSizeImage = 0;
88 pBmpInfo->bmiHeader.biXPelsPerMeter =
89 pBmpInfo->bmiHeader.biYPelsPerMeter = 0;
90 pBmpInfo->bmiHeader.biClrUsed = 0;
91 pBmpInfo->bmiHeader.biClrImportant = 0;
94 for (
unsigned char i=0; i<255; i++)
96 pBmpInfo->bmiColors[i].rgbRed = i;
97 pBmpInfo->bmiColors[i].rgbGreen = i;
98 pBmpInfo->bmiColors[i].rgbBlue = i;
99 pBmpInfo->bmiColors[i].rgbReserved = 0;
104 unsigned int lineBytes = imgWidth;
105 if (lineBytes % 2) lineBytes++;
106 if (lineBytes % 4) lineBytes+=2;
108 BYTE *ptrBits =
new BYTE[lineBytes * imgHeight];
110 for (
unsigned int py=0;py<imgHeight;py++)
111 for (
unsigned int px=0;px<imgWidth;px++)
112 ptrBits[(py*lineBytes+px)+0] = *
img(px,py);
114 HBITMAP hBitmap = CreateDIBitmap(
116 &pBmpInfo->bmiHeader,
125 GetObject(hBitmap,
sizeof(bm),&bm);
127 HDC hdcMem = CreateCompatibleDC( (HDC)
m_hdc.
get() );
128 HBITMAP hbmT = (HBITMAP)SelectObject(hdcMem,hBitmap);
141 SelectObject(hdcMem,hbmT);
146 DeleteObject( hBitmap );
172 HPEN hPen = CreatePen(
175 (
unsigned int)
color );
177 HPEN hOldPen = (HPEN) SelectObject( (HDC)
m_hdc.
get(), hPen );
179 MoveToEx( (HDC)
m_hdc.
get(), x0,y0, NULL );
182 SelectObject( (HDC)
m_hdc.
get(), hOldPen );
183 DeleteObject( hPen );
198 ::SetBkMode((HDC)
m_hdc.
get(), TRANSPARENT);
201 ::TextOutA( (HDC)
m_hdc.
get(), x0,y0, str.c_str(), (int)str.size());
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 );
236 ::DeleteObject(oldFont);
265 #endif // 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)
char BASE_IMPEXP * strcpy(char *dest, size_t destSize, const char *source) MRPT_NO_THROWS
An OS-independent version of strcpy.
GLsizei const GLchar ** string
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.