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


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

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


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

示例1: Redraw

void FormEditorWin::Redraw(SynthWidget *wdg)
{
	if (wdg)
	{
		Graphics *gr = new Graphics(m_hWnd);
		Graphics *gr2 = 0;
		if (offscrn)
			gr2 = Graphics::FromImage(offscrn);
		else
			gr2 = gr;
		wdg->Paint((DrawContext)gr2);
		SynthWidget *bud = wdg->GetBuddy2();
		if (bud)
			bud->Paint((DrawContext)gr2);
		if (offscrn)
		{
			delete gr2;
			wdgRect a = wdg->GetArea();
			gr->DrawImage(offscrn, a.x, a.y, a.x, a.y, a.w, a.h, UnitPixel);
			if (bud)
			{
				a = bud->GetArea();
				gr->DrawImage(offscrn, a.x, a.y, a.x, a.y, a.w, a.h, UnitPixel);
			}
		}
		delete gr;
	}
	else
		InvalidateRect(NULL, 0);
}
开发者ID:travisgoodspeed,项目名称:basicsynth,代码行数:30,代码来源:FormEditor.cpp

示例2: OnPaint

void CHeightMapPanel::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	Graphics *graph = Graphics::FromHDC(dc.GetSafeHdc());

	if (m_heightMap)
	{
		// 텍스쳐 출력.
		if (CWnd *pictureCtlr = GetDlgItem(IDC_STATIC_TEXTURE))
		{
			CRect cr;
			pictureCtlr->GetWindowRect(cr);
			ScreenToClient(cr);

			const Rect dest(cr.left, cr.top, cr.Width(), cr.Height());
			graph->DrawImage(m_heightMap, dest );
		}
	}

	if (m_texture)
	{
		// 텍스쳐 출력.
		if (CWnd *pictureCtlr = GetDlgItem(IDC_STATIC_TEXTURE2))
		{
			CRect cr;
			pictureCtlr->GetWindowRect(cr);
			ScreenToClient(cr);

			const Rect dest(cr.left, cr.top, cr.Width(), cr.Height());
			graph->DrawImage(m_texture, dest );
		}
	}
}
开发者ID:lthnim371,项目名称:DirectX3D,代码行数:33,代码来源:HeightMapPanel.cpp

示例3: gdiplusResize

wxBitmap* gdiplusResize(wxBitmap* bitmap, const FloatSize& size)
{
    IntSize intSize = IntSize(ceilf(size.width()), ceilf(size.height()));
    if (intSize.width() == bitmap->GetWidth() && intSize.height() == bitmap->GetHeight())
        return new wxBitmap(*bitmap); // just return a copy if the asked for the same size

    wxBitmap* newBitmap = new wxBitmap(intSize.width(), intSize.height(), 32);
    newBitmap->UseAlpha();

    wxMemoryDC memdc(*newBitmap);
    wxGraphicsContext* gc = wxGraphicsContext::Create(memdc);
    wxGraphicsBitmap gcbitmap(gc->CreateBitmap(*bitmap));

    Graphics* graphics = (Graphics*)gc->GetNativeContext();
    graphics->Clear(Gdiplus::Color(0, 0, 0, 0));

    // Only use HighQualityBicubic when downsampling.
    InterpolationMode mode;
    if (size.width() < (int)bitmap->GetWidth() && size.height() < (int)bitmap->GetHeight())
        mode = InterpolationModeHighQualityBicubic;
    else
        mode = InterpolationModeBicubic;

    graphics->SetInterpolationMode(mode);
    graphics->DrawImage((Bitmap*)gcbitmap.GetNativeBitmap(), 0.0, 0.0, size.width(), size.height());
    
    premultiplyAlpha(*newBitmap);

    delete gc;

    return newBitmap;
}
开发者ID:mikedougherty,项目名称:webkit,代码行数:32,代码来源:ImageWx.cpp

示例4: OnPaint

void CSplashWnd::OnPaint()
{
	CPaintDC dc (this);

	Graphics g (dc.GetSafeHdc ());
	g.DrawImage ((Bitmap*) *m_pBitmap, 0, 0, m_nWidth, m_nHeight);
}
开发者ID:matthias-christen,项目名称:CdCoverCreator,代码行数:7,代码来源:Splasher.cpp

示例5: WriteNumberFromStrip

void Widget::WriteNumberFromStrip(Graphics* g, int theNumber, int theX, int theY, Image* theNumberStrip, int aSpacing)
{
	int aDivisor = 10;
	int aNumDigits = 1;
	while (theNumber >= aDivisor)
	{
		aNumDigits++;
		aDivisor *= 10;
	}
	if (theNumber == 0)
		aDivisor = 10;

	int aDigitLen = theNumberStrip->GetWidth() / 10;
	
	for (int aDigitIdx = 0; aDigitIdx < aNumDigits; aDigitIdx++)
	{				
		aDivisor /= 10;
		int aDigit = (theNumber / aDivisor) % 10;				
			
		Graphics* aClipG = g->Create();
		aClipG->ClipRect(theX + aDigitIdx*(aDigitLen + aSpacing), theY, aDigitLen, theNumberStrip->GetHeight());
		aClipG->DrawImage(theNumberStrip, theX + aDigitIdx*(aDigitLen + aSpacing) - aDigit*aDigitLen, theY);		
		delete aClipG;
	}
}										 
开发者ID:Ferddi,项目名称:psf-monkey,代码行数:25,代码来源:Widget.cpp

示例6: Draw

/*
** Draws the meter on the double buffer
**
*/
bool CMeterRotator::Draw(Graphics& graphics)
{
	if (!CMeter::Draw(graphics)) return false;

	if (m_Image.IsLoaded())
	{
		// Calculate the center for rotation
		int x = GetX();
		int y = GetY();

		REAL cx = (REAL)(x + m_W / 2.0);
		REAL cy = (REAL)(y + m_H / 2.0);

		// Calculate the rotation
		REAL angle = (REAL)(CONVERT_TO_DEGREES(m_RotationAngle * m_Value + m_StartAngle));

		graphics.TranslateTransform(cx, cy);
		graphics.RotateTransform(angle);
		graphics.TranslateTransform((REAL)-m_OffsetX, (REAL)-m_OffsetY);

		Bitmap* drawBitmap = m_Image.GetImage();

		UINT width = drawBitmap->GetWidth();
		UINT height = drawBitmap->GetHeight();

		// Blit the image
		graphics.DrawImage(drawBitmap, 0, 0, width, height);

		graphics.ResetTransform();
	}

	return true;
}
开发者ID:RichVRed,项目名称:rainmeter,代码行数:37,代码来源:MeterRotator.cpp

示例7: Paint

void ImageButton::Paint(Graphics &g)
{
	Component::Paint(g);

	Image *anImage = NULL;
	if(Disabled())
		anImage = mImages[ImageButtonType_Disabled];
	else if(IsChecked() && mImages[ImageButtonType_Checked].get()!=NULL)
		anImage = mImages[4];
	else if(IsButtonDown())
		anImage = mImages[ImageButtonType_Down];
	else if(IsMouseOver())// || HasFocus())
		anImage = mImages[ImageButtonType_Over];

	if(anImage==NULL)
		anImage = mImages[ImageButtonType_Normal];

	if(anImage!=NULL)
	{
		if(mStretch && (anImage->GetWidth()!=Width() || anImage->GetHeight()!=Height()))
			anImage->SetSize(Width(),Height());

		g.DrawImage(anImage,0,0);
	}
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:25,代码来源:ImageButton.cpp

示例8: ResizeBitmap

Bitmap* ResizeBitmap(Bitmap* source, int percentage)
{
	int w = source->GetWidth()*percentage/100;
	if(w < 1)
		w = 1;

	int h = source->GetHeight()*percentage/100;
	if(h < 1)
		h = 1;

	Bitmap* b = new Bitmap(w, h, source->GetPixelFormat());
	if(b)
	{
		Graphics* g = Graphics::FromImage(b);
		if(g)
		{
			g->DrawImage(source, 0, 0, w, h);
			delete g;
		}
		else
		{
			delete b;
			b = NULL;
		}
	}

	return b;
}
开发者ID:RaMMicHaeL,项目名称:cmdline-screenshot-maker,代码行数:28,代码来源:Screenshot+Maker.cpp

示例9: Bitmap

Bitmap *Cell::getImageThumb()
{
    if( this->thumb == NULL ) {
        Image *img = this->getImage();

        if( img != NULL ) {
            this->thumb = new Bitmap(THB_SIZE,THB_SIZE,Core::getPixelFormat());

            int frame = 1;
            Graphics *gfx = Graphics::FromImage(this->thumb);

            int iwidth = img->GetWidth();
            int iheight = img->GetHeight();
            int thbSize = THB_SIZE - 4*frame;

            if( iwidth > thbSize || iheight > thbSize ) {
                double dx = (double)thbSize / (double)iwidth;
                double dy = (double)thbSize / (double)iheight;

                iwidth = (int)(min(dx,dy) * iwidth);
                iheight = (int)(min(dx,dy) * iheight);
            }
            int x = max( (int)((thbSize - iwidth) / 2), 2*frame );
            int y = max( (int)((thbSize - iheight) / 2), 2*frame );

            gfx->DrawImage(img,x,y,iwidth,iheight);

            delete gfx;
            delete img;
        }
    }
    return this->thumb;
}
开发者ID:f055,项目名称:fedit-image-editor,代码行数:33,代码来源:Cacher.cpp

示例10: OnDraw

//[-------------------------------------------------------]
//[ Protected virtual PLGui::Widget functions             ]
//[-------------------------------------------------------]
void GuiButton::OnDraw(Graphics &cGraphics)
{
	// Call base implementation
	Widget::OnDraw(cGraphics);

	// Draw background
	if (m_cBackground.GetPointer())
		cGraphics.DrawImage(*m_cBackground.GetPointer(), Vector2i::Zero, GetSize());

	// Is the font valid?
	if (m_pFont) {
		// Get the text color to use
		const Color4 &cColor = m_bMouseOver ? m_cMouseOverColor : m_cColor;

		// Get text alignment
		if (m_nAlign == AlignLeft) {
			// Left aligned
			uint32 nHeight = cGraphics.GetTextHeight(*m_pFont, m_sText);
			cGraphics.DrawText(*m_pFont, cColor, Color4::Transparent, Vector2i(0, GetSize().y/2 - nHeight/2), m_sText);
		} else if (m_nAlign == AlignRight) {
			// Right aligned
			uint32 nWidth = cGraphics.GetTextWidth(*m_pFont, m_sText);
			uint32 nHeight = cGraphics.GetTextHeight(*m_pFont, m_sText);
			cGraphics.DrawText(*m_pFont, cColor, Color4::Transparent, Vector2i(GetSize().x - nWidth, GetSize().y/2 - nHeight/2), m_sText);
		} else if (m_nAlign == AlignCenter) {
			// Centered
			uint32 nWidth = cGraphics.GetTextWidth(*m_pFont, m_sText);
			uint32 nHeight = cGraphics.GetTextHeight(*m_pFont, m_sText);
			cGraphics.DrawText(*m_pFont, cColor, Color4::Transparent, Vector2i((GetSize().x - nWidth)/2, GetSize().y/2 - nHeight/2), m_sText);
		} else if (m_nAlign == AlignBlock) {
			// Draw block text
			Vector2i vPos (0, 0);
			Vector2i vSize(GetSize());

			// Draw text word for word
			RegEx cRegEx("\\s*([^\\s]+)");
			uint32 nParsePos = 0;
			while (cRegEx.Match(m_sText, nParsePos)) {
				// Get word
				nParsePos = cRegEx.GetPosition();
				String sWord = cRegEx.GetResult(0);

				// Get text width
				int nWidth = cGraphics.GetTextWidth(*m_pFont, sWord);
				if (vPos.x + nWidth >= vSize.x) {
					// Line break
					vPos.x = 0;
					vPos.y = vPos.y + cGraphics.GetTextHeight(*m_pFont, sWord);
				}

				// Draw word
				cGraphics.DrawText(*m_pFont, cColor, Color4::Transparent, vPos, sWord);

				// Next word
				vPos.x += nWidth + 8;
			}
		}
	}
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:62,代码来源:GuiButton.cpp

示例11: anim

DWORD WINAPI Layer::anim(LPVOID param)
{
	Layer *that = (Layer *)param;

	WaitForSingleObject(that->mut_animloop,INFINITE);

	WaitForSingleObject(that->mut_image,INFINITE);
	if( that->image == NULL ){
		ReleaseMutex(that->mut_image);
		return 0;
	}
	int propertySize = that->image->GetPropertyItemSize(PropertyTagFrameDelay);
	PropertyItem *frameDelay = (PropertyItem*) malloc(propertySize);
	that->image->GetPropertyItem(PropertyTagFrameDelay,propertySize,frameDelay);

	ReleaseMutex(that->mut_image);

	long *delays = (long *)frameDelay->value;
	bool mode = false;

	while( true ){
		if( that->isTopmost() == false )
			break;
		if( WaitForSingleObject(that->mut_terminator,0) != WAIT_TIMEOUT ){
			ReleaseMutex(that->mut_terminator);
			ReleaseMutex(that->mut_animloop);
			return 0;
		}
		Sleep( max((delays[that->frameThat] * 100),MINDELAY) );

		WaitForSingleObject(that->mut_image,INFINITE);

		if( that->gifdir == RIGHT )
			mode = that->nextFrame();
		else if( that->gifdir == LEFT )
			mode = that->prevFrame();

		if( that->scali != NULL )
			delete that->scali;
		that->scali = NULL;

		if( that->rot != ROT_0 ){
			that->scali = new Bitmap(that->image->GetWidth(),that->image->GetHeight());
			Graphics *gfx = Graphics::FromImage(that->scali);
			gfx->DrawImage(that->image,0,0,that->scali->GetWidth(),that->scali->GetHeight());
			delete gfx;
		}
		ReleaseMutex(that->mut_image);

		if( that->rot != ROT_0 )
			that->rotate(that->scali);
		that->invalidate(mode);
	}
	if( frameDelay != NULL )
		delete frameDelay;	

	ReleaseMutex(that->mut_animloop);
	return 0;
}
开发者ID:f055,项目名称:fiew-image-viewer,代码行数:59,代码来源:Layer.cpp

示例12: OnDraw

void Bitmap::OnDraw(Graphics &cGraphics)
{
	// Call base implementation
	Widget::OnDraw(cGraphics);

	// Draw image
	// [TODO] PLGui: Was m_cImage.GetSize() ?!
	cGraphics.DrawImage(m_cImage, Vector2i::Zero, GetSize());
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:9,代码来源:Bitmap.cpp

示例13: OnPaint

void CBacnetAlarmWindow::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	
	// Do not call CDialogEx::OnPaint() for painting messages

	CMemDC memDC(dc,this);
	CRect rcClient;
	GetClientRect(&rcClient);
	memDC.GetDC().FillSolidRect(&rcClient,RGB(230,230,230));
	Graphics *mygraphics;
	mygraphics = new Graphics(memDC.GetDC());
	mygraphics->SetSmoothingMode(SmoothingModeAntiAlias);


	CRect test_rect;
	HWND temp_hwnd = this->m_hWnd;
	::GetWindowRect(temp_hwnd,&test_rect);	//获取 view的窗体大小;
	Bitmap bitmap(show_bitmap,NULL);
	mygraphics->DrawImage(&bitmap,0 ,0,test_rect.Width(),test_rect.Height());


	delete mygraphics;

	//Graphics graphics(memDC.GetDC());
	//SolidBrush *BlackBrush;
	//SolidBrush *CharacterBlackBrush;

	//Graphics *mygraphics;
	//mygraphics = new Graphics(memDC.GetDC());
	//mygraphics->SetSmoothingMode(SmoothingModeAntiAlias);
	//BlackBrush =new  SolidBrush(MY_COLOR_RED) ;
	//CharacterBlackBrush = new SolidBrush(MY_COLOR_BLACK_CHARACTER);


	//mygraphics->FillRectangle(BlackBrush,0,0,rcClient.Width(),40);

	//FontFamily  CharacterfontFamily(_T("Arial"));
	//PointF     TitlepointF(0, 0);
	//SolidBrush  TitleCharacterColor(Color(255,255,255,255));
	//Gdiplus::Font  Scroll_font(&CharacterfontFamily, 28, FontStyleBold, UnitPixel);
	//TitlepointF.X = 250;
	//TitlepointF.Y = 5;
	//mygraphics->DrawString(_T("Remote Connect procedure"), -1, &Scroll_font, TitlepointF,&TitleCharacterColor);

	//PointF      WarningMessagePoint(0, 0);
	//SolidBrush  WarningMessageColor(Color(255,0,0,0));
	//Gdiplus::Font  WarningMessageFont(&CharacterfontFamily, 21, FontStyleRegular, UnitPixel);
	//SolidBrush  MessageRetColor(Color(255,0,255,255));

	//CString step1_message;

end_connect_paint:

	return;

}
开发者ID:Fance,项目名称:T3000_Building_Automation_System,代码行数:57,代码来源:BacnetAlarmWindow.cpp

示例14: Paint

void TextImage::Paint(Graphics &g, TextArea *theTextArea)
{
	if(theTextArea->mSelStartChar<=mAbsStartChar && theTextArea->mSelEndChar>=mAbsEndChar)
	{
		g.SetColor(theTextArea->mSelColor.GetBackgroundColor(g));
		g.FillRect(mx,0,mWidth,mLine->mHeight);
	}

	g.DrawImage(mImage,mx,my);
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:10,代码来源:TextBox.cpp

示例15: PreDrawImage

/******************************************************************************
*	作用:		在内存中预先绘制图像
******************************************************************************/
void CGraphShowerView::PreDrawImage(void)
{
	Image image(GetFilePath(m_nPos));

	::delete m_pBitmap;

	m_pBitmap = ::new Bitmap(image.GetWidth(), image.GetHeight(), PixelFormat32bppARGB);
	Graphics* graph = Graphics::FromImage(m_pBitmap);

	graph->DrawImage(&image, 0, 0, image.GetWidth(), image.GetHeight());
	SAFE_DELETE (graph);
}
开发者ID:ptthisdan,项目名称:DIPVC,代码行数:15,代码来源:GraphShowerView.cpp


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