示例#1
0
BOOL GdiplusUtilities::DrawTextOutline(Gdiplus::Graphics& graphics, 
									   LPCTSTR lpchText, int cchText, const RECT* lprc, UINT format, 
									   const LOGFONT& lf, COLORREF fill, COLORREF outline, INT outlineWidth,
									   BOOL bCalcOnly /*= FALSE*/, RECT* rcCalc/* = NULL*/)
{
	HDC hdc = graphics.GetHDC();
	Gdiplus::Font font(hdc, &lf);
	graphics.ReleaseHDC(hdc);
	Gdiplus::StringFormat sFormat;
	if (format & DT_VCENTER)
		sFormat.SetLineAlignment(Gdiplus::StringAlignmentCenter);
	else if (format & DT_BOTTOM)
		sFormat.SetLineAlignment(Gdiplus::StringAlignmentFar);
	else
		sFormat.SetLineAlignment(Gdiplus::StringAlignmentNear);

	if (format & DT_CENTER)
		sFormat.SetAlignment(Gdiplus::StringAlignmentCenter);
	else if (format & DT_RIGHT)
		sFormat.SetAlignment(Gdiplus::StringAlignmentFar);
	else
		sFormat.SetAlignment(Gdiplus::StringAlignmentNear);

	Gdiplus::Rect rcForCalc;
	Gdiplus::Rect* pRCForCalc = &rcForCalc;
	if (rcCalc == NULL)
		pRCForCalc = NULL;
	if (DrawTextOutline(graphics, lpchText, cchText, RECT2GdiplusRect(*lprc), sFormat, font, 
		COLORREF2Color(fill), COLORREF2Color(outline), outlineWidth, bCalcOnly, pRCForCalc))
	{
		if (pRCForCalc != NULL)
			*rcCalc = GdiplusRect2RECT(*pRCForCalc);
		return TRUE;
	}
	return FALSE;

}
示例#2
0
void obj_Help_Text::Draw()
{
	DrawTextOutline(FontManager::GetInstance().GetFont(0), al_map_rgb(255,255,255), al_map_rgb(0,0,0),
		x, y, ALLEGRO_ALIGN_CENTRE, 2, "No help will be given MUHAHAHAHAHAHA!");
}