[wxPython-users] Adding zoom to bmp image
Peter Decker
pydecker at gmail.com
Mon Nov 26 17:46:56 PST 2007
On Nov 26, 2007 5:13 PM, Karl Kobata <karl.kobata at syncira.com> wrote:
> I currently create a bmp image then use DrawBitmap to render the data to the
> screen. I also do a lot of coordinate conversion since I am plotting an
> image that uses the lower left corner as the origin.
>
> I would like to enable a zoom capability by giving a scale factor, then
> rendering the image to the screen. I will also need to somehow compensate
> the coordinates to keep the enlarged/reduced image using the lower left
> corner as the origin. What is the best way to do this?
Instead of re-inventing the wheel, you could just look at how it was
done in Dabo. Their dImage class has all of this done for you. If you
don't want to switch to Dabo, you could just take their code and use
it in your projects.
The source for dImage.py is available online at:
http://trac.dabodev.com/browser/trunk/dabo/ui/uiwx/dImage.py
It's funny - this is the third question in the last week or so dealing
with image manipulation being difficult to do in wxPython. The guys
behind Dabo already figured this stuff out, coded and tested it, and
now those of us using their framework can take for granted how utterly
simple it is to size and scale images. We can ignore drawing on DCs
entirely, and simply create and manipulate draw objects like any other
GUI object. We can ignore all the complexities of creating and
populating a grid, and simply set a few simple properties to get what
we want.
I understand why someone with zillions of lines of wxPython code
wouldn't want to switch to Dabo, but it just floors me that so many
people resist making their lives easier.
--
# p.d.
More information about the wxpython-users
mailing list