当前位置: 首页>>代码示例>>C++>>正文


C++ Graphics::SetPageUnit方法代码示例

本文整理汇总了C++中gdiplus::Graphics::SetPageUnit方法的典型用法代码示例。如果您正苦于以下问题:C++ Graphics::SetPageUnit方法的具体用法?C++ Graphics::SetPageUnit怎么用?C++ Graphics::SetPageUnit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gdiplus::Graphics的用法示例。


在下文中一共展示了Graphics::SetPageUnit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DrawString

bool PngOutlineText::DrawString(
	Gdiplus::Graphics* pGraphics, 
	Gdiplus::FontFamily* pFontFamily,
	Gdiplus::FontStyle fontStyle,
	int nfontSize,
	const wchar_t*pszText, 
	Gdiplus::Rect rtDraw, 
	Gdiplus::StringFormat* pStrFormat)
{
	if(!pGraphics) return false;

	if(m_bEnableShadow&&m_pBkgdBitmap&&m_pFontBodyShadow&&m_pShadowStrategy&&m_pShadowStrategyMask)
	{
		Gdiplus::Graphics* pGraphicsMask=NULL;
		Gdiplus::Bitmap* pBmpMask=NULL;
		Gdiplus::Graphics* pGraphicsDrawn=NULL;
		Gdiplus::Bitmap* pBmpDrawn=NULL;

		bool b = RenderTransShadowA( pGraphics, &pGraphicsMask, &pBmpMask, &pGraphicsDrawn, &pBmpDrawn);

		if(!b) return false;

		b = RenderFontShadow(
			pGraphicsDrawn,
			pGraphicsMask,
			pBmpDrawn,
			pBmpMask,
			pFontFamily,
			fontStyle,
			nfontSize,
			pszText, 
			Gdiplus::Rect(rtDraw.X+m_ptShadowOffset.X, rtDraw.Y+m_ptShadowOffset.Y,rtDraw.Width,rtDraw.Height),
			pStrFormat);

		if(!b) 
		{
			delete pGraphicsMask;
			delete pGraphicsDrawn;
			delete pBmpDrawn;
			return false;
		}

		b = RenderTransShadowB( pGraphics, pGraphicsMask, pBmpMask, pGraphicsDrawn, pBmpDrawn);

		delete pGraphicsMask;
		delete pGraphicsDrawn;
		delete pBmpDrawn;

		if(!b) return false;
	}

	if(m_pTextStrategy&&m_pTextStrategyMask)
	{
		Gdiplus::Graphics* pGraphicsPng = new Gdiplus::Graphics((Gdiplus::Image*)(m_pPngBitmap));

		pGraphicsPng->SetCompositingMode(pGraphics->GetCompositingMode());
		pGraphicsPng->SetCompositingQuality(pGraphics->GetCompositingQuality());
		pGraphicsPng->SetInterpolationMode(pGraphics->GetInterpolationMode());
		pGraphicsPng->SetSmoothingMode(pGraphics->GetSmoothingMode());
		pGraphicsPng->SetTextRenderingHint(pGraphics->GetTextRenderingHint());
		pGraphicsPng->SetPageUnit(pGraphics->GetPageUnit());
		pGraphicsPng->SetPageScale(pGraphics->GetPageScale());

		bool b = m_pTextStrategy->DrawString(
			pGraphicsPng, 
			pFontFamily,
			fontStyle,
			nfontSize,
			pszText, 
			rtDraw, 
			pStrFormat);

		delete pGraphicsPng;

		if(!b)
			return false;
	}

	//pGraphics->DrawImage(m_pPngBitmap,0,0,m_pPngBitmap->GetWidth(),m_pPngBitmap->GetHeight());

	return true;
}
开发者ID:Olivki,项目名称:foo-wsh-panel-mod,代码行数:82,代码来源:PngOutlineText.cpp

示例2: RenderFontShadow

bool PngOutlineText::RenderFontShadow(	
	Gdiplus::Graphics* pGraphicsDrawn, 
	Gdiplus::Graphics* pGraphicsMask,
	Gdiplus::Bitmap* pBitmapDrawn,
	Gdiplus::Bitmap* pBitmapMask,
	Gdiplus::FontFamily* pFontFamily,
	Gdiplus::FontStyle fontStyle,
	int nfontSize,
	const wchar_t*pszText, 
	Gdiplus::Rect rtDraw, 
	Gdiplus::StringFormat* pStrFormat)
{
	if(!pGraphicsDrawn||!pGraphicsMask||!pBitmapDrawn||!pBitmapMask) return false;

	Gdiplus::Bitmap* pBitmapShadowMask = 
		m_pPngBitmap->Clone(0, 0, m_pPngBitmap->GetWidth(), m_pPngBitmap->GetHeight(), PixelFormat32bppARGB);

	Gdiplus::Graphics* pGraphicsShadowMask = new Gdiplus::Graphics((Gdiplus::Image*)(pBitmapShadowMask));
	Gdiplus::SolidBrush brushBlack(Gdiplus::Color(0,0,0));
	pGraphicsShadowMask->FillRectangle(&brushBlack, 0, 0, m_pPngBitmap->GetWidth(), m_pPngBitmap->GetHeight() );

	pGraphicsShadowMask->SetCompositingMode(pGraphicsDrawn->GetCompositingMode());
	pGraphicsShadowMask->SetCompositingQuality(pGraphicsDrawn->GetCompositingQuality());
	pGraphicsShadowMask->SetInterpolationMode(pGraphicsDrawn->GetInterpolationMode());
	pGraphicsShadowMask->SetSmoothingMode(pGraphicsDrawn->GetSmoothingMode());
	pGraphicsShadowMask->SetTextRenderingHint(pGraphicsDrawn->GetTextRenderingHint());
	pGraphicsShadowMask->SetPageUnit(pGraphicsDrawn->GetPageUnit());
	pGraphicsShadowMask->SetPageScale(pGraphicsDrawn->GetPageScale());

	bool b = false;

	b = m_pFontBodyShadowMask->DrawString(
		pGraphicsMask, 
		pFontFamily,
		fontStyle,
		nfontSize,
		pszText, 
		rtDraw, 
		pStrFormat);

	if(!b) return false;

	b = m_pShadowStrategyMask->DrawString(		
		pGraphicsShadowMask, 
		pFontFamily,
		fontStyle,
		nfontSize,
		pszText, 
		rtDraw, 
		pStrFormat);

	if(!b) return false;

	b = m_pFontBodyShadow->DrawString(
		pGraphicsDrawn, 
		pFontFamily,
		fontStyle,
		nfontSize,
		pszText, 
		rtDraw, 
		pStrFormat);

	if(!b) return false;

	b = m_pShadowStrategy->DrawString(		
		pGraphicsDrawn, 
		pFontFamily,
		fontStyle,
		nfontSize,
		pszText, 
		rtDraw, 
		pStrFormat);

	if(!b) return false;

	UINT* pixelsDest = NULL;
	UINT* pixelsMask = NULL;
	UINT* pixelsShadowMask = NULL;

	using namespace Gdiplus;

	BitmapData bitmapDataDest;
	BitmapData bitmapDataMask;
	BitmapData bitmapDataShadowMask;
	Rect rect(0, 0, m_pBkgdBitmap->GetWidth(), m_pBkgdBitmap->GetHeight() );

	pBitmapDrawn->LockBits(
		&rect,
		ImageLockModeWrite,
		PixelFormat32bppARGB,
		&bitmapDataDest );

	pBitmapMask->LockBits(
		&rect,
		ImageLockModeWrite,
		PixelFormat32bppARGB,
		&bitmapDataMask );

	pBitmapShadowMask->LockBits(
		&rect,
//.........这里部分代码省略.........
开发者ID:Olivki,项目名称:foo-wsh-panel-mod,代码行数:101,代码来源:PngOutlineText.cpp


注:本文中的gdiplus::Graphics::SetPageUnit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。