Drawing On Empty Bitmap...

Hello NG,

I must be doing something really stupid, but every modification I do to this small piece of code results in a completely black bitmap. Does anyone have some suggestion?

Thank you.

def CreateBitmap(self):

memory = wx.MemoryDC()

bitmap = wx.EmptyBitmap(self._total_w, self._total_h)
memory.SelectObject(bitmap)
    
memory.SetFont(self._font)
memory.SetTextForeground(self._colour

# This is just to hide the unwanted pixels after with the mask
memory.SetBrush(wx.Brush(wx.Colour(1, 2, 3)))


# itemimage and itemcheck are 2 small bitmaps from an imagelist    
if self._itemimage:
    memory.DrawBitmap(self._itemimage, self._ximagepos, self._yimagepos, True)

if self._itemcheck:
    memory.DrawBitmap(self._itemcheck, self._xcheckpos, self._ycheckpos, True)
        
memory.DrawText(self._text, self._xtextpos, self._ytextpos)

memory.SelectObject(wx.NullBitmap)
mask = wx.Mask(bitmap, wx.Colour(1, 2, 3))
bitmap.SetMask(mask)

return bitmap

···

Andrea Gavana
(gavana@kpo.kz)

Reservoir Engineer

KPDL

4, Millbank

SW1P 3JA London

Direct Tel: +44 (0) 20 717 08936

Mobile Tel: +44 (0) 77 487 70534

Fax: +44 (0) 20 717 08900

Web:
http://xoomer.virgilio.it/infinity77

¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

Gavana, Andrea wrote:

    # This is just to hide the unwanted pixels after with the mask
    memory.SetBrush(wx.Brush(wx.Colour(1, 2, 3)))

You probably want to change this to SetBackground(wx.Brush(wx.Colour(1, 2, 3))), and add a call to memory.Clear().

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!