About the ancient problem of Colors and Alpha Values in wx.MemoryDC

There are already a dozen alpha channel related open bugs in the database:

http://tinyurl.com/yuspj9

But I see that there are no new topics in about 2 years, and wxpython 3.0.0 was shipped half year ago.

My case is When in a wx.MemoryDC() painted of some color, I draw an alpha-bitmap over:the DrawBitmap action makes disappear the previous color, no matter the size of the bitmap drawed upon.

In my case, It Fails/Works:

DOES WORK with : WXMAC (3, 0, 0, 0, ‘’) wx.VERSION
: WXMSW (2, 8, 12, 1, ‘’)
: WXGTK (2, 8, 12, 1, ‘’)

DOESNT’ WORK with : WXMSW (3, 0, 0, 0, ‘’)

I’ve tried to import the image from PIL to try preserving the alpha using the ImageConversions methods. But same result.

So my question is…

  • Cannot we trust using Alpha in a wx.MemoryDC ?
  • Am I doing something from Tutankhamon era and should steadly change my habits into new ones?

P.D. Working example attached.

locked_12x12.png

test_DrawBitmap.py (2.8 KB)

ImageConversions.py (5.45 KB)

I found the answers to my own questions in a previous post although I did a lot of research before asking: https://groups.google.com/d/msg/wxpython-users/oCoMbebHzpE/gMtT7Ea6iX8J:

As said by Robin Dunn:

In an nutshell, wx.DC is designed for old-style
24-bit raster based

drawing with no alpha nor anti-aliasing other than
drawing bitmaps that

have alpha and drawing text, but only if the
platform automatically

anti-aliases text.
wx.GraphicsContext on the other hand is
designed to

be implemented using the new-style drawing APIs
available on each

platform (GDI+, CoreGraphics, or Cairo) and is meant
to be more vector

based and to fully support alpha and anti-aliasing.
wx.GCDC is a hybrid

of the two where the DC API is reimplemented using
wx.GraphicsContext.

So if you want to draw with alpha then you need to
switch to using

wx.GraphicsContext or use wx.GCDC.

···

On Monday, May 12, 2014 1:21:04 PM UTC+2, sesenmaister wrote:

There are already a dozen alpha channel related open bugs in the database:

http://tinyurl.com/yuspj9

But I see that there are no new topics in about 2 years, and wxpython 3.0.0 was shipped half year ago.

My case is When in a wx.MemoryDC() painted of some color, I draw an alpha-bitmap over:the DrawBitmap action makes disappear the previous color, no matter the size of the bitmap drawed upon.

In my case, It Fails/Works:

DOES WORK with : WXMAC (3, 0, 0, 0, ‘’) wx.VERSION
: WXMSW (2, 8, 12, 1, ‘’)
: WXGTK (2, 8, 12, 1, ‘’)

DOESNT’ WORK with : WXMSW (3, 0, 0, 0, ‘’)

I’ve tried to import the image from PIL to try preserving the alpha using the ImageConversions methods. But same result.

So my question is…

  • Cannot we trust using Alpha in a wx.MemoryDC ?
  • Am I doing something from Tutankhamon era and should steadly change my habits into new ones?

P.D. Working example attached.