wx.Region as an array

Albi K. wrote:

Hello,

I'm wondering if I can get an array that has the same shape as the bounding box of a wx.Region object, where each element that corresponds to a point that is contained within the region is 1, and 0 otherwise. The wx.Region.Contains method seems to be slow for large regions. So, how can I get around this? Any idea?

Put the region in a wx.RegionIterator, and then loop though all the
rectangles that the iterator will give you. Something like this:

  ri = wx.RegionIterator(region)
  while ri:
    rect = ri.GetRect()
    # do something with rect
    ri.Next()

···

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