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


C++ wxPaintDC::DrawBitmap方法代码示例

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


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

示例1: RenderPreview

void ImageResource::RenderPreview(wxPaintDC & dc, wxPanel & previewPanel, gd::Project & project)
{
    wxLogNull noLog; //We take care of errors.

    wxSize size = previewPanel.GetSize();

    //Checkerboard background
    dc.SetBrush(gd::CommonBitmapProvider::Get()->transparentBg);
    dc.DrawRectangle(0,0, size.GetWidth(), size.GetHeight());

    wxString fullFilename = GetAbsoluteFile(project);

    if ( !wxFile::Exists(fullFilename) )
        return;

    wxBitmap bmp( fullFilename, wxBITMAP_TYPE_ANY);
    if ( bmp.GetWidth() != 0 && bmp.GetHeight() != 0 && (bmp.GetWidth() > previewPanel.GetSize().x || bmp.GetHeight() > previewPanel.GetSize().y) )
    {
        //Rescale to fit in previewPanel
        float xFactor = static_cast<float>(previewPanel.GetSize().x)/static_cast<float>(bmp.GetWidth());
        float yFactor = static_cast<float>(previewPanel.GetSize().y)/static_cast<float>(bmp.GetHeight());
        float factor = std::min(xFactor, yFactor);

        wxImage image = bmp.ConvertToImage();
        if ( bmp.GetWidth()*factor >= 5 && bmp.GetHeight()*factor >= 5)
            bmp = wxBitmap(image.Scale(bmp.GetWidth()*factor, bmp.GetHeight()*factor));
    }

    //Display image in the center
    if ( bmp.IsOk() )
        dc.DrawBitmap(bmp,
                      (size.GetWidth() - bmp.GetWidth()) / 2,
                      (size.GetHeight() - bmp.GetHeight()) / 2,
                      true /* use mask */);
}
开发者ID:alcemirfernandes,项目名称:GD,代码行数:35,代码来源:ResourcesManager.cpp

示例2: DrawButton

void ButtonPanel::DrawButton(wxPaintDC &dc)
{
	int totalWidth=0;
	int maxHeight = m_playButton->GetSize().GetHeight();
	totalWidth+=m_playButton->GetSize().GetWidth();
	totalWidth+=m_previousButton->GetSize().GetWidth();
	totalWidth+=m_stopButton->GetSize().GetWidth();
	totalWidth+=m_nextButton->GetSize().GetWidth();
	totalWidth+=m_browseButton->GetSize().GetWidth();
	totalWidth+=m_slider->GetSize().GetWidth();
	totalWidth+=25;
	
	wxSize size = GetSize();

	// draw background
	wxBitmap bg = wxGetBitmapFromMemory(panel_background_bmp, 
			sizeof(panel_background_bmp));
	for(int x=0; x<size.GetWidth(); x+=bg.GetWidth())
		dc.DrawBitmap(bg, x, 0, true);
	
	// previous
	int x = (size.GetWidth()-totalWidth)/2;
	wxSize buttonSize = m_previousButton->GetSize();
	int y = (maxHeight-buttonSize.GetHeight())/2;
	m_previousButton->Move(wxPoint(x,y));

	// stop
	x = x + buttonSize.GetWidth()+5;
	buttonSize = m_stopButton->GetSize();
	y = (maxHeight-buttonSize.GetHeight())/2;
	m_stopButton->Move(wxPoint(x,y));
	
	// play
	x = x + buttonSize.GetWidth()+5;
	buttonSize = m_playButton->GetSize();
	y = (maxHeight-buttonSize.GetHeight())/2;
	m_playButton->Move(wxPoint(x,y));
	
	// next
	x = x + buttonSize.GetWidth()+5;
	buttonSize = m_nextButton->GetSize();
	y = (maxHeight-buttonSize.GetHeight())/2;
	m_nextButton->Move(wxPoint(x,y));
	
	// browse
	x = x + buttonSize.GetWidth()+10;
	buttonSize = m_browseButton->GetSize();
	y = (maxHeight-buttonSize.GetHeight())/2;
	m_browseButton->Move(wxPoint(x,y));
	
	// volume slider
	x = x + buttonSize.GetWidth()+20;
	buttonSize = m_slider->GetSize();
	y = (maxHeight-buttonSize.GetHeight())/2;
	m_slider->Move(wxPoint(x,y));
}
开发者ID:sopepos,项目名称:imsplayer_osx,代码行数:56,代码来源:ActionPanel.cpp

示例3: doImgPaint

void gcProgressBar::doImgPaint(wxPaintDC& dc)
{
	int h = GetSize().GetHeight();
	int w = GetSize().GetWidth();
#ifdef WIN32 // unused AFAIK
	int ih = m_imgProg->GetSize().GetHeight();
#endif
	int iw = m_imgProg->GetSize().GetWidth();

	uint32 wp = w*m_uiProg/100;

	wxImage scaled = m_imgProg->Scale(iw, h);
	wxBitmap norm = GetGCThemeManager()->getSprite(scaled, "progressbar", "Norm");
	wxBitmap nedge = GetGCThemeManager()->getSprite(scaled, "progressbar", "NormEdge");
	wxBitmap empty = GetGCThemeManager()->getSprite(scaled, "progressbar", "Empty");

	wxBitmap   tmpBmp(w, h);
	wxMemoryDC tmpDC(tmpBmp);

	tmpDC.SetBrush(wxBrush(wxColor(255,0,255)));
	tmpDC.SetPen( wxPen(wxColor(255,0,255),1) );
	tmpDC.DrawRectangle(0,0,w,h);


	uint32 neWidth = nedge.GetWidth();
	wxColor c(255,0,255);

	if (wp == 0)
	{
		//dont do any thing
	}
	else if (wp <= neWidth)
	{
		wxBitmap left = nedge.ConvertToImage().GetSubImage(wxRect(neWidth-wp,0,neWidth,h));
		tmpDC.DrawBitmap(left, 0, 0, true);
	}
	else
	{
		wxBitmap left(wp-neWidth, h);
		
		gcImage::tileImg(left, norm, &c);

		tmpDC.DrawBitmap(left, 0, 0, true);
		tmpDC.DrawBitmap(nedge, wp-neWidth, 0, true);
	}

	wxBitmap right(w-wp, h);
	gcImage::tileImg(right, empty, &c);
	tmpDC.DrawBitmap(right, wp,0,true);

	tmpDC.SelectObject(wxNullBitmap);

	doExtraImgPaint(tmpBmp, w, h);

	dc.DrawBitmap(tmpBmp, 0,0, true);
}
开发者ID:CSRedRat,项目名称:desura-app,代码行数:56,代码来源:gcProgressBar.cpp

示例4: DoPaint

void MyVideoCaptureWindow::DoPaint( wxPaintDC& dc )
{
    wxVideoCaptureWindowBase::DoPaint(dc);

    if (!IsDeviceConnected())
    {
        // The window is blank when disconnected so we might as well
        // give a hint to people that they need to connect first.
        wxBitmap bmp = wxArtProvider::GetBitmap(wxART_MISSING_IMAGE, wxART_OTHER, wxSize(32, 32));
        wxSize clientSize(GetClientSize());

        wxString txt(wxT("Please select a capture device"));
        wxSize txtSize = dc.GetTextExtent(txt);

        dc.DrawText(txt,   clientSize.GetWidth()/2  - txtSize.GetWidth()/2,
                           clientSize.GetHeight()/2 - txtSize.GetHeight());
        dc.DrawBitmap(bmp, clientSize.GetWidth()/2  - bmp.GetWidth()/2,
                           clientSize.GetHeight()/2 + 4);
    }
}
开发者ID:stahta01,项目名称:wxCode_components,代码行数:20,代码来源:wxvidcap.cpp

示例5: OnSized

void PeakMeter::OnSized( wxPaintDC& dc )
{
	m_colorBack.Set(wxT("#DDE1E6"));
	dc.SetBackground(wxBrush(m_colorBack));
	dc.Clear();

	wxRect rc = GetClientRect();

	int rw = rc.GetWidth();
	int rh = rc.GetHeight();

	// draw meter
	wxBitmap bmp = wxGetBitmapFromMemory(meter_bmp, sizeof(meter_bmp));
	int bw = bmp.GetWidth();
	int bh = bmp.GetHeight();

	m_meterBitmapX = (rw-bw)/2;
	m_meterBitmapY = (rh-bh)/2;
	dc.DrawBitmap(bmp, m_meterBitmapX, m_meterBitmapY, true);

	// draw repeat button
	int x = m_meterBitmapX+20;

	if ( m_repeatButton == NULL )
	{
		wxBitmap bmp1 = wxGetBitmapFromMemory(repeat_all_bmp,
											  sizeof(repeat_all_bmp));
		wxBitmap bmp2 = wxGetBitmapFromMemory(repeat_all_hover_bmp,
											  sizeof(repeat_all_hover_bmp));
		m_repeatButton= new GButton(this, wxID_ANY,
									wxDefaultPosition, bmp1, bmp2);
		m_repeatButton->SetToolTip(wxT("Choose Repeat mode (Repeat All)"));
		Connect(m_repeatButton->GetId(), wxEVT_COMMAND_GBUTTON,
				(wxObjectEventFunction) (wxEventFunction) &PeakMeter::OnRepeat);
	}
	m_repeatButton->Move(x, m_meterBitmapY+25);

	if ( m_playModeButton == NULL )
	{
		wxBitmap bmp1 = wxGetBitmapFromMemory(play_mode_normal_bmp,
											  sizeof(play_mode_normal_bmp));
		wxBitmap bmp2 = wxGetBitmapFromMemory(play_mode_normal_hover_bmp,
											  sizeof(play_mode_normal_hover_bmp));
		m_playModeButton= new GButton(this, wxID_ANY,
									  wxDefaultPosition, bmp1, bmp2);
		m_playModeButton->SetToolTip(wxT("Choose Play mode"));
	}
	m_playModeButton->Move(x, m_meterBitmapY+45);

	// draw convert button
	bmp = wxGetBitmapFromMemory(button_bmp, sizeof(button_bmp));
	int bw2 = bmp.GetWidth();
	bh = bmp.GetHeight();

	x = m_meterBitmapX-bw2-10;
	if ( m_convertButton == NULL )
	{
		wxBitmap bmp1 = wxGetBitmapFromMemory(convert_bmp,
											  sizeof(convert_bmp));
		wxBitmap bmp2 = wxGetBitmapFromMemory(convert_hover_bmp,
											  sizeof(convert_hover_bmp));
		wxBitmap bmp3 = wxGetBitmapFromMemory(convert_clicked_bmp,
											  sizeof(convert_clicked_bmp));
		m_convertButton= new GButton(this, wxID_ANY,
									 wxDefaultPosition, bmp1, bmp2, bmp3);
	}
	m_convertButton->Move(x, m_meterBitmapY+5);

	dc.DrawBitmap(bmp, x, m_meterBitmapY+40, true);

	x = m_meterBitmapX+bw+10;
	dc.DrawBitmap(bmp, x, m_meterBitmapY+5, true);
	dc.DrawBitmap(bmp, x, m_meterBitmapY+40, true);
}
开发者ID:sopepos,项目名称:imsplayer_osx,代码行数:74,代码来源:PeakMeter.cpp


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