本文整理汇总了C++中wxBitmap类的典型用法代码示例。如果您正苦于以下问题:C++ wxBitmap类的具体用法?C++ wxBitmap怎么用?C++ wxBitmap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了wxBitmap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoDrawBitmap
void wxGTKCairoDCImpl::DoDrawBitmap(const wxBitmap& bitmap, int x, int y, bool useMask)
{
wxCHECK_RET(IsOk(), "invalid DC");
cairo_t* cr = NULL;
if (m_graphicContext)
cr = static_cast<cairo_t*>(m_graphicContext->GetNativeContext());
if (cr)
{
cairo_save(cr);
bitmap.Draw(cr, x, y, useMask, &m_textForegroundColour, &m_textBackgroundColour);
cairo_restore(cr);
}
}
示例2: DoDrawBitmap
void wxDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask )
{
wxCHECK_RET( bitmap.Ok(), "invalid bitmap" );
wxMemoryDC memDC;
memDC.SelectObjectAsSource(bitmap);
#if 0
// Not sure if we need this. The mask should leave the masked areas as per
// the original background of this DC.
if (useMask)
{
// There might be transparent areas, so make these the same colour as this
// DC
memDC.SetBackground(* GetBackground());
memDC.Clear();
}
#endif // 0
Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), &memDC, 0, 0, wxCOPY, useMask);
memDC.SelectObject(wxNullBitmap);
}
示例3: wxFAIL_MSG
bool wxBitmapButton::Create( wxWindow *parent,
wxWindowID id,
const wxBitmap& bitmap,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& validator,
const wxString &name )
{
m_needParent = true;
m_acceptsFocus = true;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, validator, name ))
{
wxFAIL_MSG( wxT("wxBitmapButton creation failed") );
return false;
}
m_bitmaps[State_Normal] = bitmap;
m_widget = gtk_button_new();
if (style & wxNO_BORDER)
gtk_button_set_relief( GTK_BUTTON(m_widget), GTK_RELIEF_NONE );
if (bitmap.IsOk())
{
OnSetBitmap();
}
gtk_signal_connect_after( GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_bmpbutton_clicked_callback), (gpointer*)this );
gtk_signal_connect( GTK_OBJECT(m_widget), "enter",
GTK_SIGNAL_FUNC(gtk_bmpbutton_enter_callback), (gpointer*)this );
gtk_signal_connect( GTK_OBJECT(m_widget), "leave",
GTK_SIGNAL_FUNC(gtk_bmpbutton_leave_callback), (gpointer*)this );
gtk_signal_connect( GTK_OBJECT(m_widget), "pressed",
GTK_SIGNAL_FUNC(gtk_bmpbutton_press_callback), (gpointer*)this );
gtk_signal_connect( GTK_OBJECT(m_widget), "released",
GTK_SIGNAL_FUNC(gtk_bmpbutton_release_callback), (gpointer*)this );
m_parent->DoAddChild( this );
PostCreation(size);
return true;
}
示例4: Union
bool wxRegion::Union(const wxBitmap& bmp,
const wxColour& transColour,
int tolerance)
{
#if (!defined(__WXMSW__) || wxUSE_WXDIB)
wxImage image = bmp.ConvertToImage();
return DoRegionUnion(*this, image,
transColour.Red(),
transColour.Green(),
transColour.Blue(),
tolerance);
#else
return false;
#endif
}
示例5: WXUNUSED
wxSize clAuiSimpleTabArt::GetTabSize(wxDC& dc,
wxWindow* WXUNUSED(wnd),
const wxString& caption,
const wxBitmap& bitmap,
bool WXUNUSED(active),
int close_button_state,
int* x_extent)
{
wxCoord measured_textx, measured_texty;
dc.SetFont(m_measuring_font);
dc.GetTextExtent(caption, &measured_textx, &measured_texty);
wxCoord base_height = measured_texty;
wxCoord base_width = measured_textx;
if(bitmap.IsOk()) {
if(bitmap.GetHeight() > base_height)
base_height = bitmap.GetHeight();
base_width += bitmap.GetWidth() + 2;
}
wxCoord tab_height = base_height + 6;
wxCoord tab_width = base_width + tab_height + 5;
if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
tab_width += m_active_close_bmp.GetWidth();
if (m_flags & wxAUI_NB_TAB_FIXED_WIDTH) {
tab_width = m_fixed_tab_width;
}
*x_extent = tab_width - (tab_height/2) - 1;
return wxSize(tab_width, tab_height);
}
示例6: wxASSERT_MSG
int wxGenericImageList::Add( const wxBitmap &bitmap )
{
wxASSERT_MSG( (bitmap.GetWidth() >= m_width && bitmap.GetHeight() == m_height)
|| (m_width == 0 && m_height == 0),
wxT("invalid bitmap size in wxImageList: this might work ")
wxT("on this platform but definitely won't under Windows.") );
const int index = int(m_images.GetCount());
if (bitmap.IsKindOf(wxCLASSINFO(wxIcon)))
{
m_images.Append( new wxIcon( (const wxIcon&) bitmap ) );
}
else
{
// Mimic behaviour of Windows ImageList_Add that automatically breaks up the added
// bitmap into sub-images of the correct size
if (m_width > 0 && bitmap.GetWidth() > m_width && bitmap.GetHeight() >= m_height)
{
int numImages = bitmap.GetWidth() / m_width;
for (int subIndex = 0; subIndex < numImages; subIndex++)
{
wxRect rect(m_width * subIndex, 0, m_width, m_height);
wxBitmap tmpBmp = bitmap.GetSubBitmap(rect);
m_images.Append( new wxBitmap(tmpBmp) );
}
}
else
{
m_images.Append( new wxBitmap(bitmap) );
}
}
if (m_width == 0 && m_height == 0)
{
m_width = bitmap.GetWidth();
m_height = bitmap.GetHeight();
}
return index;
}
示例7: wxDrawSplashBitmap
static void wxDrawSplashBitmap(wxDC& dc, const wxBitmap& bitmap, int WXUNUSED(x), int WXUNUSED(y))
{
wxMemoryDC dcMem;
#ifdef USE_PALETTE_IN_SPLASH
bool hiColour = (wxDisplayDepth() >= 16) ;
if (bitmap.GetPalette() && !hiColour)
{
dcMem.SetPalette(* bitmap.GetPalette());
}
#endif // USE_PALETTE_IN_SPLASH
dcMem.SelectObjectAsSource(bitmap);
dc.Blit(0, 0, bitmap.GetWidth(), bitmap.GetHeight(), & dcMem, 0, 0);
dcMem.SelectObject(wxNullBitmap);
#ifdef USE_PALETTE_IN_SPLASH
if (bitmap.GetPalette() && !hiColour)
{
dcMem.SetPalette(wxNullPalette);
}
#endif // USE_PALETTE_IN_SPLASH
}
示例8: while
bool
wxSVGBitmapFileHandler::ProcessBitmap(const wxBitmap& bmp,
wxCoord x, wxCoord y,
wxOutputStream& stream) const
{
static int sub_images = 0;
if ( wxImage::FindHandler(wxBITMAP_TYPE_PNG) == NULL )
wxImage::AddHandler(new wxPNGHandler);
// find a suitable file name
wxString sPNG;
do
{
sPNG = wxString::Format("image%d.png", sub_images++);
}
while (wxFile::Exists(sPNG));
if ( !bmp.SaveFile(sPNG, wxBITMAP_TYPE_PNG) )
return false;
// reference the bitmap from the SVG doc using only filename & ext
sPNG = sPNG.AfterLast(wxFileName::GetPathSeparator());
// reference the bitmap from the SVG doc
wxString s;
s += wxString::Format(" <image x=\"%d\" y=\"%d\" width=\"%dpx\" height=\"%dpx\"",
x, y, bmp.GetWidth(), bmp.GetHeight());
s += wxString::Format(" xlink:href=\"%s\"/>\n", sPNG);
// write to the SVG file
const wxCharBuffer buf = s.utf8_str();
stream.Write(buf, strlen((const char *)buf));
return stream.IsOk();
}
示例9: DoDrawBitmap
void wxPrinterDC::DoDrawBitmap(
const wxBitmap& rBmp
, wxCoord vX
, wxCoord vY
, bool bUseMask
)
{
wxCHECK_RET( rBmp.Ok(), _T("invalid bitmap in wxPrinterDC::DrawBitmap") );
// int nWidth = rBmp.GetWidth();
// int nHeight = rBmp.GetHeight();
// TODO:
} // end of wxPrinterDC::DoDrawBitmap
示例10: LoadImage
void Image::LoadImage(const wxBitmap &bitmap)
{
// Convert the bitmap to a png image we can use as m_compressedImage
wxImage image = bitmap.ConvertToImage();
wxMemoryOutputStream stream;
image.SaveFile(stream,wxBITMAP_TYPE_PNG);
m_compressedImage.AppendData(stream.GetOutputStreamBuffer()->GetBufferStart(),
stream.GetOutputStreamBuffer()->GetBufferSize());
// Set the info about the image.
m_extension = wxT("png");
m_originalWidth = image.GetWidth();
m_originalHeight = image.GetHeight();
m_scaledBitmap.Create (1,1);
}
示例11: GetPageSize
bool wxWizard::ResizeBitmap(wxBitmap& bmp)
{
if (!GetBitmapPlacement())
return false;
if (bmp.Ok())
{
wxSize pageSize = m_sizerPage->GetSize();
if (pageSize == wxSize(0,0))
pageSize = GetPageSize();
int bitmapWidth = wxMax(bmp.GetWidth(), GetMinimumBitmapWidth());
int bitmapHeight = pageSize.y;
if (!m_statbmp->GetBitmap().Ok() || m_statbmp->GetBitmap().GetHeight() != bitmapHeight)
{
wxBitmap bitmap(bitmapWidth, bitmapHeight);
{
wxMemoryDC dc;
dc.SelectObject(bitmap);
dc.SetBackground(wxBrush(m_bitmapBackgroundColour));
dc.Clear();
if (GetBitmapPlacement() & wxWIZARD_TILE)
{
TileBitmap(wxRect(0, 0, bitmapWidth, bitmapHeight), dc, bmp);
}
else
{
int x, y;
if (GetBitmapPlacement() & wxWIZARD_HALIGN_LEFT)
x = 0;
else if (GetBitmapPlacement() & wxWIZARD_HALIGN_RIGHT)
x = bitmapWidth - bmp.GetWidth();
else
x = (bitmapWidth - bmp.GetWidth())/2;
if (GetBitmapPlacement() & wxWIZARD_VALIGN_TOP)
y = 0;
else if (GetBitmapPlacement() & wxWIZARD_VALIGN_BOTTOM)
y = bitmapHeight - bmp.GetHeight();
else
y = (bitmapHeight - bmp.GetHeight())/2;
dc.DrawBitmap(bmp, x, y, true);
dc.SelectObject(wxNullBitmap);
}
}
bmp = bitmap;
}
}
return true;
}
示例12: wxPanel
OutputViewControlBarButton::OutputViewControlBarButton(wxWindow* win, const wxString& title, const wxBitmap& bmp, long style)
: wxPanel(win)
, m_state(Button_Normal)
, m_text (title)
, m_bmp (bmp)
, m_style (style)
{
if ( title.IsEmpty() && bmp.IsOk() == false ) return;
SetSizeHints(DoCalcButtonWidth( this,
m_style & Button_UseText ? m_text : wxT(""),
m_bmp,
m_style & Button_UseXSpacer ? BUTTON_SPACER_X : 1),
DoCalcButtonHeight(this, wxEmptyString, m_bmp, BUTTON_SPACER_Y));
}
示例13: WXUNUSED
void wxGCDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool WXUNUSED(useMask) )
{
wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid DC") );
wxCHECK_RET( bmp.Ok(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid bitmap") );
if ( bmp.GetDepth() == 1 )
{
m_graphicContext->SetPen(*wxTRANSPARENT_PEN);
m_graphicContext->SetBrush( wxBrush( m_textBackgroundColour , wxSOLID ) );
m_graphicContext->DrawRectangle( x , y , bmp.GetWidth() , bmp.GetHeight() );
m_graphicContext->SetBrush( wxBrush( m_textForegroundColour , wxSOLID ) );
m_graphicContext->DrawBitmap( bmp, x , y , bmp.GetWidth() , bmp.GetHeight() );
m_graphicContext->SetBrush( m_graphicContext->CreateBrush(m_brush));
m_graphicContext->SetPen( m_graphicContext->CreatePen(m_pen));
}
else
m_graphicContext->DrawBitmap( bmp, x , y , bmp.GetWidth() , bmp.GetHeight() );
}
示例14: KiScaledBitmap
wxBitmap KiScaledBitmap( const wxBitmap& aBitmap, EDA_BASE_FRAME* aWindow )
{
const int scale = get_scale_factor( aWindow );
if( scale == 4)
{
return wxBitmap( aBitmap );
}
else
{
wxImage image = aBitmap.ConvertToImage();
image.Rescale( scale * image.GetWidth() / 4, scale * image.GetHeight() / 4,
wxIMAGE_QUALITY_BILINEAR );
return wxBitmap( image );
}
}
示例15: BitmapFromWindow
bool BitmapFromWindow(wxWindow *window, wxBitmap& bitmap)
{
bool ret;
wxMemoryDC mdc;
wxClientDC cdc(window);
const wxSize& size=window->GetClientSize();
window->Raise();
wxTheApp->Yield();
bitmap.Create(size.x, size.y);
mdc.SelectObject(bitmap);
ret=mdc.Blit(0, 0, size.x, size.y, &cdc, 0, 0);
mdc.SelectObject(wxNullBitmap);
return ret;
}