本文整理汇总了C++中wxMemoryDC::GetSelectedBitmap方法的典型用法代码示例。如果您正苦于以下问题:C++ wxMemoryDC::GetSelectedBitmap方法的具体用法?C++ wxMemoryDC::GetSelectedBitmap怎么用?C++ wxMemoryDC::GetSelectedBitmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxMemoryDC
的用法示例。
在下文中一共展示了wxMemoryDC::GetSelectedBitmap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: data
wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxMemoryDC& dc ) :
wxDCImpl( owner )
{
#if defined(__WXMSW__) && wxUSE_WXDIB
// It seems that GDI+ sets invalid values for alpha channel when used with
// a compatible bitmap (DDB). So we need to convert the currently selected
// bitmap to a DIB before using it with any GDI+ functions to ensure that
// we get the correct alpha channel values in it at the end.
wxBitmap bmp = dc.GetSelectedBitmap();
wxASSERT_MSG( bmp.IsOk(), "Should select a bitmap before creating wxGCDC" );
// We don't need to convert it if it can't have alpha at all (any depth but
// 32) or is already a DIB with alpha.
if ( bmp.GetDepth() == 32 && (!bmp.IsDIB() || !bmp.HasAlpha()) )
{
// We need to temporarily deselect this bitmap from the memory DC
// before modifying it.
const_cast<wxMemoryDC&>(dc).SelectObject(wxNullBitmap);
bmp.ConvertToDIB(); // Does nothing if already a DIB.
if( !bmp.HasAlpha() )
{
// Initialize alpha channel, even if we don't have any alpha yet,
// we should have correct (opaque) alpha values in it for GDI+
// functions to work correctly.
{
wxAlphaPixelData data(bmp);
if ( data )
{
wxAlphaPixelData::Iterator p(data);
for ( int y = 0; y < data.GetHeight(); y++ )
{
wxAlphaPixelData::Iterator rowStart = p;
for ( int x = 0; x < data.GetWidth(); x++ )
{
p.Alpha() = wxALPHA_OPAQUE;
++p;
}
p = rowStart;
p.OffsetY(data, 1);
}
}
} // End of block modifying the bitmap.
// Using wxAlphaPixelData sets the internal "has alpha" flag but we
// don't really have any alpha yet, so reset it back for now.
bmp.ResetAlpha();
}
// Undo SelectObject() at the beginning of this block.
const_cast<wxMemoryDC&>(dc).SelectObjectAsSource(bmp);
}
#endif // wxUSE_WXDIB
Init(wxGraphicsContext::Create(dc));
}