I've browsed through the (behemoth!) wxWindows reference manual, I'm a bit
overwhelmed with the huge number of classes, and thus don't know how best to do
what I want. And that is, to have some simple bitmap/canvas item on which I
can plot points pixel by pixel... (just pretend I want to implement a fractal
viewer with wxPython) What is the most sensible way of doing this? So far I've
tried with a wxBitmap+wxMemoryDC, but, oh my, wxMemoryDC::DrawPoint() is
excruciatingly slow... surely something better exists?
···
--
"The higher we soar, the smaller we appear to those who cannot fly."
-- Friedrich Wilhelm Nietsche
Standard approach is to simply update a bitmap (possibly stored as a Numeric Python array) and then blit the whole thing (or a sub-set) to the wxPaintDC. You can keep a mask in the bitmap (4-bytes/pixel) to allow for not over-drawing particular pixels. You will probably also want to use one of the "buffered" wxDC sub-classes to eliminate flicker.
BTW, when people actually wrote a fractal viewer way back when, here's what it looked like :
We should really update that code one of these days, the wx code is written in a fairly primitive style .
Enjoy,
Mike
Maciej Kalisiak wrote:
···
Hello all,
I've browsed through the (behemoth!) wxWindows reference manual, I'm a bit
overwhelmed with the huge number of classes, and thus don't know how best to do
what I want. And that is, to have some simple bitmap/canvas item on which I
can plot points pixel by pixel... (just pretend I want to implement a fractal
viewer with wxPython) What is the most sensible way of doing this? So far I've
tried with a wxBitmap+wxMemoryDC, but, oh my, wxMemoryDC::DrawPoint() is
excruciatingly slow... surely something better exists?
I've browsed through the (behemoth!) wxWindows reference manual, I'm a bit
overwhelmed with the huge number of classes, and thus don't know how best to do
what I want. And that is, to have some simple bitmap/canvas item on which I
can plot points pixel by pixel... (just pretend I want to implement a fractal
viewer with wxPython) What is the most sensible way of doing this? So far I've
tried with a wxBitmap+wxMemoryDC, but, oh my, wxMemoryDC::DrawPoint() is
excruciatingly slow... surely something better exists?
There are some things in the pipe for 2.5 that should make raw bitmap access much faster... In the meantime I'd suggest using a wxImage with the SetRGB(x, y, r, g, b) method. It doesn't have to do any API calls to set the pixel and it can then be converted to a wxBitmap for drawing when you are ready.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
> So far I've
> tried with a wxBitmap+wxMemoryDC, but, oh my, wxMemoryDC::DrawPoint() is
> excruciatingly slow... surely something better exists?
>
access much faster... In the meantime I'd suggest using a wxImage with
the SetRGB(x, y, r, g, b) method. It doesn't have to do any API calls
to set the pixel and it can then be converted to a wxBitmap for drawing
when you are ready.
If you still want to use a DC, try using the DC.DrawPointList() method.
It can draw a whole list (or any python sequence) a whole lot faster
than looping through your points one by one. It's demoed in the demo
under DrawXXXList.
-Chris
···
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception