本文整理汇总了C++中gdiplus::Graphics::DrawImage方法的典型用法代码示例。如果您正苦于以下问题:C++ Graphics::DrawImage方法的具体用法?C++ Graphics::DrawImage怎么用?C++ Graphics::DrawImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gdiplus::Graphics
的用法示例。
在下文中一共展示了Graphics::DrawImage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawButton
// 绘制按钮
void CDUIButton::DrawButton( Gdiplus::Graphics& graphics)
{
// 获取按钮图片信息
UINT iCount = m_nImageCount;
int iButtonIndex = 0;
if(m_bDisabled && iCount >= 4) iButtonIndex = 3;
else if(m_bPressed && iCount >= 3)iButtonIndex = 2;
else if(m_bHovering && iCount >= 2)iButtonIndex = 1;
else iButtonIndex = 0;
// 在指定位置绘制按钮
int iWidth = m_pImage->GetWidth()/iCount;
int iHeight = m_pImage->GetHeight();
RectF grect;
grect.X=(Gdiplus::REAL)m_rcRect.left;
grect.Y=(Gdiplus::REAL)m_rcRect.top;
grect.Width = (Gdiplus::REAL)m_rcRect.Width();
grect.Height = (Gdiplus::REAL)m_rcRect.Height();
graphics.DrawImage(m_pImage, grect, (Gdiplus::REAL)iWidth*iButtonIndex,0,(Gdiplus::REAL)iWidth,(Gdiplus::REAL)iHeight, UnitPixel);
StringFormat stringFormat;
if (m_pIcon)
{
PointF ptIcon(m_ptIcon.x,m_ptIcon.y);
graphics.DrawImage(m_pIcon,ptIcon);
grect.X=(Gdiplus::REAL)m_ptIcon.x + m_pIcon->GetWidth() + 2;
grect.Width = (Gdiplus::REAL)m_rcRect.Width() - m_pIcon->GetWidth() - 2;
stringFormat.SetFormatFlags( StringFormatFlagsDirectionVertical);
stringFormat.SetAlignment(StringAlignmentCenter);
stringFormat.SetLineAlignment(StringAlignmentNear);
}
else
{
//stringFormat.SetFormatFlags( StringFormatFlagsDirectionVertical);
stringFormat.SetAlignment(StringAlignmentCenter);
stringFormat.SetLineAlignment(StringAlignmentCenter);
}
if (!m_strCaption.IsEmpty())
{
//绘制文字
FontFamily fontFamily(L"宋体");
Gdiplus::Font font(&fontFamily, 10, FontStyleRegular, UnitPoint);
CStringW strTitle(m_strCaption);
SolidBrush brush((ARGB)Color::White);
if (m_bDisabled)
{
brush.SetColor((ARGB)Color::Gray);
}
graphics.DrawString(strTitle, strTitle.GetLength(), &font,grect,&stringFormat, &brush);
}
}
示例2: if
void CSkinButton2::DrawImage(Gdiplus::Graphics& gdi,BTN_DRAW_HUE hue)
{
if(hue == DRAW_NORMAL)
{
if( m_pPngImage && m_pPngImage->m_pBitmap )
{
RectF grect; grect.X=0, grect.Y=0; grect.Width = m_pPngImage->m_pBitmap->GetWidth(); grect.Height = m_pPngImage->m_pBitmap->GetHeight();
gdi.DrawImage(*m_pPngImage,grect );
}
}
else if(hue == DRAW_LIGHT)
{
if( m_pPngImage && m_pPngImage->m_pBitmap )
{
ImageAttributes ia;
ia.SetColorMatrix(&m_LightMat);
RectF grect; grect.X=0, grect.Y=0; grect.Width = m_pPngImage->m_pBitmap->GetWidth(); grect.Height = m_pPngImage->m_pBitmap->GetHeight();
gdi.DrawImage(*m_pPngImage, grect, 0, 0, grect.Width, grect.Height, UnitPixel, &ia);
}
}
else if(hue == DRAW_GRAY )
{
if( m_pPngImage && m_pPngImage->m_pBitmap )
{
ImageAttributes ia;
ia.SetColorMatrix(&m_GrayMat);
RectF grect; grect.X=0, grect.Y=0; grect.Width = m_pPngImage->m_pBitmap->GetWidth(); grect.Height = m_pPngImage->m_pBitmap->GetHeight();
gdi.DrawImage(*m_pPngImage, grect, 0, 0, grect.Width, grect.Height, UnitPixel, &ia);
}
}
}
示例3: onDraw
void ProgressBar::onDraw(Gdiplus::Graphics& g, int x, int y)
{
g.DrawImage(background_, x+x_, y+y_);
int w = int(foreground_.width() * percent_);
int h = foreground_.height();
g.DrawImage(foreground_, x+x_, y+y_, 0, 0, w, h, Gdiplus::UnitPixel);
}
示例4: DrawImage
void Graphics::DrawImage(Image* image, const Rect& rc, const ImageAttributes* attr) {
Gdiplus::Graphics* g = reinterpret_cast<Gdiplus::Graphics*>(_private);
Gdiplus::Image* gdiImage = reinterpret_cast<Gdiplus::Image*>(image->_private);
if(attr!=0) {
Gdiplus::ImageAttributes* ia = reinterpret_cast<Gdiplus::ImageAttributes*>(attr->_private);
g->DrawImage(gdiImage, Gdiplus::Rect(rc.GetLeft(), rc.GetTop(), rc.GetWidth(), rc.GetHeight()), 0, 0, gdiImage->GetWidth(), gdiImage->GetHeight(), Gdiplus::UnitPixel, ia);
}
else {
g->DrawImage(gdiImage, ToGDIRect<Rect, Gdiplus::Rect>(rc));
}
}
示例5: DrawButton
// 绘制按钮
void CXButton::DrawButton( Gdiplus::Graphics& graphics)
{
// 获取按钮图片信息
Image* pImage = CImageInfo::Instance()->ImageFromResource(m_nImageContorl);
UINT iCount = m_nImageCount;
if(m_bCheck && m_nAltImageContorl != 0)
{
pImage = CImageInfo::Instance()->ImageFromResource(m_nAltImageContorl);;
iCount = m_nAltImageCount;
}
// 获取按钮状态信息
int iButtonIndex = 0;
if(m_bDisabled && iCount >= 4) iButtonIndex = 3;
else if(m_bPressed && iCount >= 3)iButtonIndex = 2;
else if(m_bHovering && iCount >= 2)iButtonIndex = 1;
else iButtonIndex = 0;
// 在指定位置绘制按钮
int iWidth = pImage->GetWidth()/iCount;
int iHeight = pImage->GetHeight();
RectF grect;
grect.X=m_rcRect.left, grect.Y=m_rcRect.top; grect.Width = m_rcRect.Width(); grect.Height = m_rcRect.Height();
graphics.DrawImage(pImage, grect, iWidth*iButtonIndex,0,iWidth,iHeight, UnitPixel);
}
示例6: RestoreLayer
void CanvasGdiplus::RestoreLayer()
{
DCHECK(layers_.size());
CanvasLayer* layer = layers_.top();
layers_.pop();
DCHECK(layer);
Gdiplus::Graphics* current = GetCurrentGraphics();
Gdiplus::Bitmap* native_bitmap =
layer->mem_bitmap.GetNativeBitmap();
Gdiplus::ImageAttributes ia;
Gdiplus::ColorMatrix cm =
{
1.0, 0.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 0.0, (static_cast<float>(layer->alpha))/255, 0.0,
0.0, 0.0, 0.0, 0.0, 1.0
};
ia.SetColorMatrix(&cm);
Gdiplus::Rect destRect(layer->bounds.x(), layer->bounds.y(),
layer->bounds.width(), layer->bounds.height());
current->DrawImage(native_bitmap, destRect,
layer->bounds.x(), layer->bounds.y(),
layer->bounds.width(), layer->bounds.height(),
Gdiplus::UnitPixel, &ia);
delete layer;
}
示例7: BuildFontSheetBitmap
void DxFont::BuildFontSheetBitmap(Gdiplus::Font & font, Gdiplus::Graphics & charGraphics, Gdiplus::Bitmap & charBitmap, Gdiplus::Graphics & fontSheetGraphics)
{
WCHAR charString[ 2 ] = { ' ', 0 };
Gdiplus::SolidBrush whiteBrush( Gdiplus::Color( 255, 255, 255, 255 ) );
UINT fontSheetX = 0;
UINT fontSheetY = 0;
for( UINT i = 0; i < NumChars; ++i )
{
charString[ 0 ] = static_cast<WCHAR>(StartChar + i);
charGraphics.Clear(Gdiplus::Color(0, 0, 0, 0));
charGraphics.DrawString(charString, 1, &font, Gdiplus::PointF(0.0f, 0.0f), &whiteBrush);
int minX = GetCharMinX(charBitmap);
int maxX = GetCharMaxX(charBitmap);
int charWidth = maxX - minX + 1;
if(fontSheetX + charWidth >= TexWidth)
{
fontSheetX = 0;
fontSheetY += static_cast<int>(CharHeight) + 1;
}
CharRects[i] = CD3D11_RECT(fontSheetX, fontSheetY, fontSheetX + charWidth, fontSheetY + CharHeight);
fontSheetGraphics.DrawImage(&charBitmap, fontSheetX, fontSheetY, minX, 0, charWidth, CharHeight, Gdiplus::UnitPixel);
fontSheetX += charWidth + 1;
}
}
示例8: DrawBitmapInt
void CanvasGdiplus::DrawBitmapInt(const Bitmap& bitmap, int x, int y)
{
Gdiplus::Graphics* current = GetCurrentGraphics();
if(!bitmap.IsNull())
{
current->DrawImage(bitmap.GetNativeBitmap(), x, y);
}
}
示例9: DrawAudioVideo
void CMonitorWidget::DrawAudioVideo(Gdiplus::Graphics & graphics)
{
CRect rcVideo;
pStaticVideo.GetWindowRect(rcVideo);
ScreenToClient(rcVideo);
if(m_lpBitsInfo && m_lpBits)
{
Gdiplus::Bitmap bitmapVideo(m_lpBitsInfo, m_lpBits);
graphics.DrawImage(&bitmapVideo, rcVideo.left, rcVideo.top, rcVideo.Width(), rcVideo.Height());
}
else
{
Gdiplus::Bitmap bitmap(m_hBitmapVideo, NULL);
graphics.DrawImage(&bitmap, rcVideo.left, rcVideo.top, rcVideo.Width(), rcVideo.Height());
}
CAudioWidget::DrawAudioVideo(graphics);
}
示例10: Render
void CTranslucentProgressBar::Render(Gdiplus::Graphics& g)
{
float ratio = (float)m_nPos / (m_nUpper - m_nLower);
CRect rc;
GetWindowRect(&rc);
GetParent()->ScreenToClient(&rc);
Gdiplus::RectF rect((float)rc.left, (float)rc.top, (float)rc.Width(), (float)rc.Height());
if (m_imageList[0] != NULL)
g.DrawImage(m_imageList[0], rect, static_cast<float>(0), static_cast<float>(0), rect.Width, rect.Height, Gdiplus::UnitPixel);
if (m_imageList[1] != NULL)
{
float nWidth = rc.Width() * ratio;
rect.Width = nWidth;
(void)g.DrawImage(m_imageList[1], rect, static_cast<float>(0), static_cast<float>(0), nWidth, rect.Height, Gdiplus::UnitPixel);
rect.Width = (float)rc.Width();
}
CString szText;
GetWindowText(szText);
if (szText.GetLength() > 0)
{
TCHAR wsFile[MAX_PATH] = {0};
if(!CToolsHelp::Strncpy(wsFile,MAX_PATH,(LPCTSTR)szText,static_cast<IVS_UINT32>(szText.GetLength())))
{
BP_RUN_LOG_ERR(IVS_ALLOC_MEMORY_ERROR,"IVS_OCX::","Failed");
return;
}
WCHAR* wstr = CTranslucentUtility::ttowc(wsFile);
if (NULL != wstr)
{
(void)g.DrawString(wstr, static_cast<int >(wcslen(wstr)), m_pFont, rect, &m_format, &m_brush);
delete []wstr;
wstr = NULL;
}
}
}
示例11: DrawImcLogo
void CStartupView::DrawImcLogo(Gdiplus::Graphics &graphics)
{
if (m_pImcLogo == NULL)
return;
Gdiplus::Rect gdipRcLogoRegion;
Gdiplus::Rect gdipRcButtonRegion;
Gdiplus::Rect gdipRcBottomRegion;
CalculateRegions(gdipRcLogoRegion, gdipRcButtonRegion, gdipRcBottomRegion);
// Calculate correct position
Gdiplus::REAL dLogoX = (gdipRcBottomRegion.X + gdipRcBottomRegion.Width) -
(m_pImcLogo->GetWidth() + LOGO_RIGHT_SPACE);
Gdiplus::REAL dLogoY = gdipRcBottomRegion.Y +
(int)((double)(gdipRcBottomRegion.Height - m_pImcLogo->GetHeight()) / 2.0);
graphics.DrawImage(m_pImcLogo, dLogoX, dLogoY);
}
示例12: Render
void FlexDblBuffer::Render(Gdiplus::Graphics& destination, INT X, INT Y)
{
ASSERT(m_cx > 0 && m_cy > 0);
ASSERT(m_pB != NULL);
if (m_cx > 0 && m_cy > 0 && m_pB != NULL)
{
//=== DEBUG in order to find out why in VMWare it fails to destination.DrawImage
// (without getting an error)
// FillRectangle in contrast always succeeds
//destination.FillRectangle(&Gdiplus::SolidBrush(Gdiplus::Color::Red), X, Y, m_cx,m_cy);
//m_pG->FillRectangle(&Gdiplus::SolidBrush(Gdiplus::Color::Blue), X, Y, m_cx,m_cy / 2);
if (destination.DrawImage(m_pB, X, Y, 0, 0, m_cx, m_cy, Gdiplus::UnitPixel) != Gdiplus::Ok)
{
TRACE(_T("@1 FlexDblBuffer::Render x:%d y:%d (FAILED)\r\n"), X, Y);
TRACE(_T("@1 \tcx:%d cy:%d (FAILED)\r\n"), m_cx, m_cy);
}
}
}
示例13: TileImageInt
void CanvasGdiplus::TileImageInt(const Bitmap& bitmap,
int src_x, int src_y, int dest_x, int dest_y, int w, int h)
{
if(!IntersectsClipRectInt(dest_x, dest_y, w, h))
{
return;
}
Gdiplus::Graphics* current = GetCurrentGraphics();
if(!bitmap.IsNull())
{
Gdiplus::Bitmap* native_bitmap = bitmap.GetNativeBitmap();
Gdiplus::ImageAttributes ia;
ia.SetWrapMode(Gdiplus::WrapModeTile);
Gdiplus::Rect rc_dest(dest_x, dest_y, w, h);
current->DrawImage(native_bitmap,
rc_dest, src_x, src_y,
native_bitmap->GetWidth()-src_x,
native_bitmap->GetHeight()-src_y,
Gdiplus::UnitPixel, &ia);
}
}
示例14: CreateAndIndexAtlasBitmap
//---------------------------------------------------------------------------
void CreateAndIndexAtlasBitmap(Gdiplus::Font& font, Gdiplus::Graphics& charGraphics, Gdiplus::Bitmap& charBitmap,
Gdiplus::Graphics& fontSheetGraphics, FontAtlasSizeInfo* pSizeInfo,
ScreenRect* pCharacterMap )
{
using namespace Gdiplus;
WCHAR charString[2] = {' ', 0};
SolidBrush whiteBrush(Color(255, 255, 255, 255));
UINT fontSheetX = 0;
UINT fontSheetY = 0;
for(UINT i = 0; i < s_NumChars; ++i)
{
charString[0] = static_cast<WCHAR>(s_StartChar + i);
charGraphics.Clear(Color(0, 0, 0, 0));
charGraphics.DrawString(charString, 1, &font, PointF(0.0f, 0.0f), &whiteBrush);
// Compute tight char horizontal bounds (ignoring empty space).
int minX = GetCharMinX(charBitmap);
int maxX = GetCharMaxX(charBitmap);
int charWidth = maxX - minX + 1;
// Move to next row of the font sheet?
if(fontSheetX + charWidth >= pSizeInfo->atlasTextureWidth)
{
fontSheetX = 0;
fontSheetY += static_cast<int>(pSizeInfo->characterRowHeight) + 1;
}
// Save the rectangle of this character on the texture atlas.
pCharacterMap[i] = ScreenRect(fontSheetX, fontSheetY, fontSheetX + charWidth, fontSheetY + pSizeInfo->characterRowHeight);
// The rectangle subset of the source image to copy.
fontSheetGraphics.DrawImage(&charBitmap, fontSheetX, fontSheetY,
minX, 0, charWidth, pSizeInfo->characterRowHeight, UnitPixel);
// next char
fontSheetX += charWidth + 1;
}
}
示例15: onRender
bool UnitVideo::onRender(LPVOID world,FLOAT& x,FLOAT& y,FLOAT& z)
{
if(isRenderFlag() && m_dataPtr && getStat() == MEDIA_PLAY)
{
m_critical.lock();
if(m_initImage)
{
INT width = MediaSampler::getImageWidth();
INT height = MediaSampler::getImageHeight();
setSize(width,height);
m_initImage = false;
}
INT width = MediaSampler::getImageWidth();
INT height = MediaSampler::getImageHeight();
INT pitch = (width * 24/8 + 3)/4*4;
Gdiplus::Bitmap bitmap(width,height,pitch,PixelFormat24bppRGB,(LPBYTE)m_dataPtr);
Gdiplus::Graphics* g = getGraphics();
g->DrawImage(&bitmap,0,height-1,width,-height);
m_critical.unlock();
}
return UnitGdip::onRender(world,x,y,z);
}