本文整理汇总了C++中Graphics::BeginContainer方法的典型用法代码示例。如果您正苦于以下问题:C++ Graphics::BeginContainer方法的具体用法?C++ Graphics::BeginContainer怎么用?C++ Graphics::BeginContainer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graphics
的用法示例。
在下文中一共展示了Graphics::BeginContainer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GPDrawShadowTextSimple
void GPDrawShadowTextSimple( Graphics&gc, CString& strTxtIn, CRect& rcIn, Gdiplus::Font& fontIn, ARGB BrushClrIn, ARGB shadowBrushClrIn /*= 0xff000000*/, int nOffXIn /*= 2*/, int nOffYIn /*= 2*/, StringFormat* fmtIn /*= NULL*/ )
{
Gdiplus::Font& gcfont = fontIn;
Rect rcText = CRect2Rect(rcIn);
StringFormat fmt;
fmt.SetAlignment(StringAlignmentCenter);
fmt.SetTrimming(StringTrimmingEllipsisWord);
fmt.SetLineAlignment(StringAlignmentCenter);
StringFormat& fmtUse = fmtIn == NULL? fmt:*fmtIn;
GraphicsContainer gcContainer = gc.BeginContainer();
gc.SetSmoothingMode(SmoothingModeAntiAlias);
CComBSTR btrTxtIn(strTxtIn);
SolidBrush textbrush(ARGB2Color(shadowBrushClrIn));
RectF rfText = Rect2RectF(rcText);
if (shadowBrushClrIn != 0)
{
rfText.Offset(1.0, 1.0);
gc.DrawString(btrTxtIn, -1, &gcfont, rfText, &fmtUse, &textbrush);
}
textbrush.SetColor(ARGB2Color(BrushClrIn));
gc.DrawString(btrTxtIn, -1, &gcfont, rfText, &fmtUse, &textbrush);
gc.EndContainer(gcContainer);
}
示例2: GPDrawShadowText
void GPDrawShadowText( Graphics& gc, CString& strTxtIn, CRect& rcIn, Gdiplus::Font& fontIn, ARGB BrushClrIn, ARGB PenClrIn , ARGB shadowPenClrIn /*= 0xff000000*/, ARGB shadowBrushClrIn /*= 0xff000000*/, int nOffXIn /*= 2*/, int nOffYIn /*= 2*/, StringFormat* fmtIn /*= NULL*/ )
{
Gdiplus::Font& gcfont = fontIn;
FontFamily fmy;
gcfont.GetFamily(&fmy);
int nfontStyle = gcfont.GetStyle();
REAL dFontSize = gcfont.GetSize();
Rect rcText = CRect2Rect(rcIn);
StringFormat fmt;
fmt.SetAlignment(StringAlignmentCenter);
fmt.SetTrimming(StringTrimmingEllipsisWord);
fmt.SetLineAlignment(StringAlignmentCenter);
StringFormat& fmtUse = fmtIn == NULL? fmt:*fmtIn;
GraphicsContainer gcContainer = gc.BeginContainer();
gc.SetSmoothingMode(SmoothingModeAntiAlias);
CComBSTR btrTxtIn(strTxtIn);
GraphicsPath textPath;
textPath.AddString(btrTxtIn, -1, &fmy, nfontStyle, dFontSize, rcText, &fmtUse);
Matrix mx;
mx.Translate(nOffXIn, nOffYIn);
textPath.Transform(&mx);
Pen textPen(ARGB2Color(shadowPenClrIn), 1);
SolidBrush textbrush(ARGB2Color(shadowBrushClrIn));
textPen.SetLineJoin(LineJoinRound);
if (shadowBrushClrIn != 0)
{
gc.FillPath(&textbrush, &textPath);
}
if (shadowPenClrIn != 0)
{
gc.DrawPath(&textPen, &textPath);
}
mx.Invert();
textPath.Transform(&mx);
textPen.SetColor(ARGB2Color(PenClrIn));
textbrush.SetColor(ARGB2Color(BrushClrIn));
if (BrushClrIn != 0)
{
gc.FillPath(&textbrush, &textPath);
}
if (PenClrIn != 0)
{
gc.DrawPath(&textPen, &textPath);
}
gc.EndContainer(gcContainer);
}
示例3: GPDrawStretchImage
void GPDrawStretchImage( Graphics& gc, Bitmap* pImage, CRect& rcDes, CRect* prcImgUseIn /*= NULL*/, ENUM_TXBMPSTRETCHTYPE nSTypeIn /*= TXBMP_STRETCH_NONE*/, CRect* prcEdgeIn /*= NULL*/, CRect* prcEdge2In /*= NULL*/ )
{
if (pImage == NULL || rcDes.IsRectEmpty())
{
ASSERT(FALSE);
return;
}
CSize szImage(pImage->GetWidth(), pImage->GetHeight());
CRect rcImgUse;
if (prcImgUseIn == NULL)
{
rcImgUse = CRect(0,0, szImage.cx, szImage.cy);
}
else
{
rcImgUse = *prcImgUseIn;
}
CRect rcEdgeUse = g_globalInfo.txDrawParam.rcStretchEdge;
if (prcEdgeIn != NULL)
{
rcEdgeUse = *prcEdgeIn;
}
GraphicsContainer container = gc.BeginContainer();
Rect rDes = CRect2Rect(rcDes);
gc.SetClip(rDes);
if (rcDes.Size() == rcImgUse.Size())
{
nSTypeIn = TXBMP_STRETCH_NONE;
}
switch(nSTypeIn)
{
case TXBMP_STRETCH_NONE:
{
gc.DrawImage(pImage, rDes, rcImgUse.left, rcImgUse.top, rcImgUse.Width(), rcImgUse.Height(), UnitPixel);
}break;
case TXBMP_STRETCH_LR:
{
}break;
case TXBMP_STRETCH_TB:
{
ASSERT(FALSE);
}break;
case TXBMP_STRETCH_MID_LR:
{
CRect rcMid(rcDes);
rcMid.DeflateRect(rcEdgeUse.left, 0, rcEdgeUse.right, 0);
//draw left edge
Rect rLeft = rDes;
rLeft.Width =rcEdgeUse.left;
gc.DrawImage(pImage, rLeft, rcImgUse.left, rcImgUse.top, rLeft.Width, rLeft.Height, UnitPixel);
//draw right edge
Rect rRight = Rect(rcMid.right, rcDes.top, rcEdgeUse.right, rcDes.bottom);
CPoint ptImgUse(rcImgUse.right - rcEdgeUse.right, rcImgUse.top);
gc.DrawImage(pImage, rRight, ptImgUse.x, ptImgUse.y, rRight.Width, rRight.Height, UnitPixel);
//draw mid
Rect rMid = CRect2Rect(rcMid);
CRect rcImgMidUse(rcImgUse);
rcImgMidUse.DeflateRect(rcEdgeUse.left, 0, rcEdgeUse.right, 0);
gc.DrawImage(pImage, rMid, rcImgMidUse.left, rcImgMidUse.top, rcImgMidUse.Width(), rcImgMidUse.Height(), UnitPixel);
}break;
case TXBMP_STRETCH_MID_TB:
{
CRect rcMid(rcDes);
rcMid.DeflateRect(0, rcEdgeUse.top, 0, rcEdgeUse.bottom);
//draw top
Rect rTop(rcDes.left,rcDes.top, rcDes.Width(), rcEdgeUse.top);
Rect rImgTop(rcImgUse.left, rcImgUse.top, rcImgUse.Width(), rcEdgeUse.top);
gc.DrawImage(pImage, rTop, rImgTop.X, rImgTop.Y, rImgTop.Width, rImgTop.Height, UnitPixel);
//draw bottom
Rect rBottom = Rect(rcDes.left, rcMid.bottom, rcDes.Width(), rcEdgeUse.bottom);
Rect rImgBottom(rcImgUse.left, rcImgUse.bottom - rcEdgeUse.bottom, rcImgUse.Width(), rcEdgeUse.bottom);
gc.DrawImage(pImage, rBottom, rImgBottom.X, rImgBottom.Y, rImgBottom.Width, rImgBottom.Height, UnitPixel);
//draw Mid
Rect rMid = CRect2Rect(rcMid);
Rect rImgMid(rcImgUse.left, rcImgUse.top + rcEdgeUse.top, rcImgUse.Width(), rcImgUse.Height() - rcEdgeUse.top - rcEdgeUse.bottom);
gc.DrawImage(pImage, rMid, rImgMid.X, rImgMid.Y, rImgMid.Width, rImgMid.Height, UnitPixel);
}break;
case TXBMP_STRETCH_MID_LRTB:
{
CRect rcMid(rcDes);
rcMid.DeflateRect(rcEdgeUse);
CRect rcImgMid(rcImgUse);
rcImgMid.DeflateRect(rcEdgeUse);
//.........这里部分代码省略.........
示例4: DrawImage
bool CGdiPlusImage::DrawImage(CDC* pDC)
{
//´´½¨ÆÁÄ»
ASSERT(pDC!=NULL);
if ( !pDC ) return false;
Bitmap bmp(m_rcDest.Width(), m_rcDest.Height());
Graphics* pGraphics = Graphics::FromImage(&bmp);
if ( !pGraphics ) return false;
GraphicsContainer Containter = pGraphics->BeginContainer();
pGraphics->SetSmoothingMode(SmoothingModeHighQuality);
SolidBrush bgbrush(Color(238, 243, 250));
pGraphics->FillRectangle(&bgbrush, 0, 0, m_rcDest.Width(), m_rcDest.Height());
if ( m_pImage )
{
//»ñÈ¡ÊôÐÔ
INT nImageWidth = m_pImage->GetWidth();
INT nImageHeight = m_pImage->GetHeight();
float fMin = 1.0F;
float fZoomRate = 1.0F;
bool bZoomOut = false;
int nXSrc = 0;
int nYSrc = 0;
if ( nImageWidth >= m_rcDest.Width() || nImageHeight >= m_rcDest.Height() )
{
float fXRate = 1.0F * m_rcDest.Width() / nImageWidth;
float fYRate = 1.0F * m_rcDest.Height() / nImageHeight;
fMin = min(fXRate, fYRate);
fZoomRate = max(nImageWidth * 1.0F / m_rcDest.Width(), nImageHeight * 1.0F / m_rcDest.Height());
bZoomOut = true;
}
int nDestWidth = fMin * nImageWidth;
int nDestHeight = fMin * nImageHeight;
//¹¹ÔìλÖÃ
RectF rcDrawRect;
rcDrawRect.X = m_rcDest.left + (m_rcDest.Width() - nDestWidth ) / 2;
rcDrawRect.Y = m_rcDest.top + (m_rcDest.Height() - nDestHeight ) / 2;
rcDrawRect.Width = nDestWidth;
rcDrawRect.Height = nDestHeight;
Matrix matrix;
CPoint pt(m_rcDest.Width() / 2, m_rcDest.Height() / 2);
PointF ptBase((float)pt.x, (float)pt.y);
//¾ØÕó±ä»»Òª×¢Òâ˳Ðò£¬ÏÈƽÒÆÔÚËõ·ÅºóÐýת
matrix.Translate((REAL)m_rcDest.left,(REAL)m_rcDest.top,MatrixOrderAppend);
//Ëõ·Å
if ( m_szZoom.cx != 1.0f || m_szZoom.cy != 1.0f )
{
ptBase.X += m_szZoom.cx;
ptBase.Y += m_szZoom.cy;
matrix.Translate(-ptBase.X,-ptBase.Y,MatrixOrderAppend);
matrix.Scale(m_szZoom.cx,m_szZoom.cy,MatrixOrderAppend);
matrix.Translate(ptBase.X,ptBase.Y,MatrixOrderAppend);
}
//Ðýת
if (m_nRotateAngle)
{
matrix.RotateAt((REAL)m_nRotateAngle,ptBase,MatrixOrderAppend);
}
pGraphics->SetTransform(&matrix);
//͸Ã÷¾ØÕó
ColorMatrix Matrix=
{
1.0f,0.0f,0.0f,0.0f,0.0f,
0.0f,1.0f,0.0f,0.0f,0.0f,
0.0f,0.0f,1.0f,0.0f,0.0f,
0.0f,0.0f,0.0f,m_cbAlphaDepth/255.0f,0.0f,
0.0f,0.0f,0.0f,0.0f,1.0f
};
//ÉèÖÃÊôÐÔ
ImageAttributes Attributes;
Attributes.SetColorMatrix(&Matrix,ColorMatrixFlagsDefault,ColorAdjustTypeBitmap);
//»æ»Í¼Ïñ
pGraphics->DrawImage(m_pImage, rcDrawRect, nXSrc, nYSrc, (REAL)nImageWidth - nXSrc * 2, (REAL)nImageHeight - nYSrc * 2, UnitPixel,&Attributes);
pGraphics->ResetTransform();
pGraphics->EndContainer(Containter);
} // if ( m_pImage )
// ´ÓÄڴ濽±´ÖÁÉ豸
Graphics graphicsreal(pDC->GetSafeHdc());
//.........这里部分代码省略.........