示例#1
0
wxBitmapRefData::wxBitmapRefData(const wxBitmapRefData& data)
{
    Create(data.m_width, data.m_height, data.m_bpp);

    m_mask = data.m_mask ? new wxMask(*data.m_mask) : NULL;

#if wxUSE_PALETTE
    wxASSERT_MSG( !data.m_palette,
                  wxT("copying bitmaps palette not implemented") );
#endif // wxUSE_PALETTE


    // copy the bitmap data by simply drawing the source bitmap on this one
    GdkPixmap **dst;
    if ( data.m_pixmap )
    {
        dst = &m_pixmap;
    }
    else if ( data.m_bitmap )
    {
        dst = &m_bitmap;
    }
    else // invalid bitmap?
    {
        return;
    }

    GdkGC *gc = gdk_gc_new(*dst);
    if ( m_bpp == 1 )
    {
        gdk_wx_draw_bitmap(m_bitmap, gc, data.m_bitmap, 0, 0, 0, 0, -1, -1);
    }
    else // colour pixmap
    {
        gdk_draw_pixmap(m_pixmap, gc, data.m_pixmap, 0, 0, 0, 0, -1, -1);
    }

    gdk_gc_unref(gc);
}
示例#2
0
文件: bitmap.cpp 项目: gitrider/wxsj2
bool wxMask::Create( const wxBitmap& bitmap )
{
    if (m_bitmap)
    {
        gdk_bitmap_unref( m_bitmap );
        m_bitmap = (GdkBitmap*) NULL;
    }

    if (!bitmap.Ok()) return FALSE;

    wxCHECK_MSG( bitmap.GetBitmap(), FALSE, wxT("Cannot create mask from colour bitmap") );

    m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, bitmap.GetWidth(), bitmap.GetHeight(), 1 );

    if (!m_bitmap) return FALSE;

    GdkGC *gc = gdk_gc_new( m_bitmap );

    gdk_wx_draw_bitmap( m_bitmap, gc, bitmap.GetBitmap(), 0, 0, 0, 0, bitmap.GetWidth(), bitmap.GetHeight() );

    gdk_gc_unref( gc );

    return TRUE;
}