Ticket #10066 (new defect)

Opened 6 weeks ago

wxMemoryDC with alpha bitmap makes garbage

Reported by: robind Owned by:
Priority: normal Milestone:
Component: wxGTK Version: 2.8.9
Keywords: wxGraphicsContext wxMemoryDC Cc:
Blocked By: Patch: no
Blocking:

Description

In wxGTK there is a problem with using a wxMemoryDC on a bitmap that has alpha. For example in this sample we have this bit of code:

            bmp = wx.EmptyBitmapRGBA(DIM, DIM, red, green, blue, alpha)
            dc = wx.MemoryDC(bmp)
            gc = wx.GraphicsContext.Create(dc)            
            path = gc.CreatePath()
            path.MoveToPoint(POS,POS)
            path.AddLineToPoint(DIM-POS, DIM-POS)
            gc.SetPen(wx.Pen("red", 8))
            gc.StrokePath(path)

In wxPython the EmptyBitmapRGBA function makes a new bitmap that is prefilled with the given color/alpha components using raw bitmap access. On wxGTK the bitmap can end up looking like Snap001 instead of as it should look like Snap002. (The diagonal blue lines are already present on the window when the bitmaps are drawn.)

In fact, all that needs to be done to create the garbage is to create the wx.MemoryDC and not draw on it at all. IOW, using just the first two lines above will also result in garbage in the bitmap.

This happens in the 2.8 branch and also on the trunk.

Another, probably related problem that the sample program shows is that if the bitmap's alpha is set to zero then nothing drawn on the bitmap will ever change the alpha values and so the whole bitmap remains fully transparent.

Attachments

Snap001.png (5.3 kB) - added by robind 6 weeks ago.
Snap002.png (1.4 kB) - added by robind 6 weeks ago.

Change History

Changed 6 weeks ago by robind

Changed 6 weeks ago by robind

Note: See TracTickets for help on using tickets.