parameters: (bmp)
return_statement: return shadow
docstring: Converts a bitmap to monochrome colour.
  
      :param `bmp`: a valid :class:`Bitmap` object.
docstring_summary: Converts a bitmap to monochrome colour.
docstring_tokens: Converts a bitmap to monochrome colour .
function: def ConvertToMonochrome(bmp):
      """
      Converts a bitmap to monochrome colour.
  
      :param `bmp`: a valid :class:`Bitmap` object.
      """
  
      mem_dc = wx.MemoryDC()
      shadow = wx.EmptyBitmap(bmp.GetWidth(), bmp.GetHeight())
      mem_dc.SelectObject(shadow)
      mem_dc.DrawBitmap(bmp, 0, 0, True)
      mem_dc.SelectObject(wx.NullBitmap)
      img = shadow.ConvertToImage()
      img = img.ConvertToMono(0, 0, 0)
      
      # we now have black where the original bmp was drawn,
      # white elsewhere
      shadow = wx.BitmapFromImage(img)
      shadow.SetMask(wx.Mask(shadow, wx.BLACK))
  
      # Convert the black to grey
      tmp = wx.EmptyBitmap(bmp.GetWidth(), bmp.GetHeight())
      col = wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW)
      mem_dc.SelectObject(tmp)
      mem_dc.SetPen(wx.Pen(col))
      mem_dc.SetBrush(wx.Brush(col))
      mem_dc.DrawRectangle(0, 0, bmp.GetWidth(), bmp.GetHeight())
      mem_dc.DrawBitmap(shadow, 0, 0, True)   # now contains a bitmap with grey where the image was, white elsewhere
      mem_dc.SelectObject(wx.NullBitmap)
      shadow = tmp
      shadow.SetMask(wx.Mask(shadow, wx.WHITE)) 
  
      return shadow
function_tokens: def ConvertToMonochrome ( bmp ) : mem_dc = wx . MemoryDC ( ) shadow = wx . EmptyBitmap ( bmp . GetWidth ( ) , bmp . GetHeight ( ) ) mem_dc . SelectObject ( shadow ) mem_dc . DrawBitmap ( bmp , 0 , 0 , True ) mem_dc . SelectObject ( wx . NullBitmap ) img = shadow . ConvertToImage ( ) img = img . ConvertToMono ( 0 , 0 , 0 ) # we now have black where the original bmp was drawn, # white elsewhere shadow = wx . BitmapFromImage ( img ) shadow . SetMask ( wx . Mask ( shadow , wx . BLACK ) ) # Convert the black to grey tmp = wx . EmptyBitmap ( bmp . GetWidth ( ) , bmp . GetHeight ( ) ) col = wx . SystemSettings_GetColour ( wx . SYS_COLOUR_BTNSHADOW ) mem_dc . SelectObject ( tmp ) mem_dc . SetPen ( wx . Pen ( col ) ) mem_dc . SetBrush ( wx . Brush ( col ) ) mem_dc . DrawRectangle ( 0 , 0 , bmp . GetWidth ( ) , bmp . GetHeight ( ) ) mem_dc . DrawBitmap ( shadow , 0 , 0 , True ) # now contains a bitmap with grey where the image was, white elsewhere mem_dc . SelectObject ( wx . NullBitmap ) shadow = tmp shadow . SetMask ( wx . Mask ( shadow , wx . WHITE ) ) return shadow