Search code examples
c++wxwidgetsalphaalphablending

wxWidgets - Alpha blending


Is there a way in wxWidget to do alpha blending operations such as multiplying the alpha of a bitmap versus the RGB of other bitmap to generate new images (such as rendering a photo as an anti-aliased circular shape).


Solution

  • Though I haven't done alpha blending myself, I believe the wxGraphicContext is what you are after.

    http://docs.wxwidgets.org/stable/wx_wxgraphicscontext.html

    I've got flicker free drawing into the graphics context (on Win32) using the following in my paint event handler:

    void OnPaint( wxPaintEvent& e )
    {
        wxBufferedPaintDC dc( this );        
        wxGraphicsContext* gdc = wxGraphicsContext::Create( dc );
        // you drawing code here
    }
    

    EDIT: this email trail might offer some more insight:

    http://www.nabble.com/Is-alpha-blending-implemented-when-using-DC's--td17183159.html