Resize Static Bitmap

I want to create zoom in / zoom out feature when a static bitmap is displayed. How do you resize an image and the wx.StaticBitmap itself so that it appears n% larger (or smaller)?

Thanks.
Brian

Brian Wolf wrote:

I want to create zoom in / zoom out feature when a static bitmap is displayed. How do you resize an image and the wx.StaticBitmap itself so that it appears n% larger (or smaller)?

You'll be better off not using a wx.StaticBitmap for this. (After all static means unchanging.) Instead catch the EVT_PAINT event and draw the bitmap yourself. Then you can do things like stretching it to fit the window, or whatever you want. Just convert it to a wx.Image, manipulate it, convert to a wx.Bitmap and draw it.

···

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

Thanks, Robin.
Sorry, but I don't know how to draw it on the screen. Do you mean with a wx.ScreenDC?

Brian

Robin Dunn wrote:

···

Brian Wolf wrote:

I want to create zoom in / zoom out feature when a static bitmap is displayed. How do you resize an image and the wx.StaticBitmap itself so that it appears n% larger (or smaller)?

You'll be better off not using a wx.StaticBitmap for this. (After all static means unchanging.) Instead catch the EVT_PAINT event and draw the bitmap yourself. Then you can do things like stretching it to fit the window, or whatever you want. Just convert it to a wx.Image, manipulate it, convert to a wx.Bitmap and draw it.

wx.PaintDC

Gre7g

···

--- Brian Wolf <brian.wolf@activustech.com> wrote:

Thanks, Robin.
Sorry, but I don't know how to draw it on the
screen. Do you mean with a
wx.ScreenDC?

____________________________________________________________________________________
We won't tell. Get more on shows you hate to love
(and love to hate): Yahoo! TV's Guilty Pleasures list.
http://tv.yahoo.com/collections/265

Sorry, I'm still not getting it. Can you be a little more specific?
Below are code snippets (unfortunately not working) inside a frame:

self.filename = 'images/sailboat.jpg'
self.bmp = wx.Bitmap(self.filename, wx.BITMAP_TYPE_JPEG)

..........

self.Bind(wx.EVT_PAINT, self.OnPaint)

..........

def OnPaint(self, event):
  paintdc = wx.PaintDC(self)
  x,y = self.GetPosition()
  paintdc.DrawBitmap(self.bmp, x, y)
  self.Refresh()

···

------------------------------------------------------

Brian Wolf |
Activus Technologies Corporation |
brian@activustech.com | 410.367.2958 |

------------------------------------------------------

Helping organizations gain a competitive advantage |
through intelligent application of technology. |

------------------------------------------------------

Gre7g Luterman wrote:

--- Brian Wolf <brian.wolf@activustech.com> wrote:

Thanks, Robin.
Sorry, but I don't know how to draw it on the
screen. Do you mean with a wx.ScreenDC?

wx.PaintDC

Gre7g

____________________________________________________________________________________
We won't tell. Get more on shows you hate to love (and love to hate): Yahoo! TV's Guilty Pleasures list.
Yahooist Teil der Yahoo Markenfamilie

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Sorry, I'm still not getting it. Can you be a
little more specific?
Below are code snippets (unfortunately not working)
inside a frame:

self.filename = 'images/sailboat.jpg'
self.bmp = wx.Bitmap(self.filename,
wx.BITMAP_TYPE_JPEG)

..........

self.Bind(wx.EVT_PAINT, self.OnPaint)

..........

def OnPaint(self, event):
  paintdc = wx.PaintDC(self)
  x,y = self.GetPosition()

You're grabbing the window's coordinates and then
drawing the bitmap at them. Don't do that. Drawing
within the window will have coordinates normalized, so
0,0 will be the origin, regardless of the window's
position.

  paintdc.DrawBitmap(self.bmp, x, y)
  self.Refresh()

Don't Refresh(). You're telling the window it needs
to be redrawn once you've redrawn it.

Here's a snippet that does work:
http://pastie.textmate.org/74794

Gre7g

···

--- Brian Wolf <brian.wolf@activustech.com> wrote:

____________________________________________________________________________________
Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.
http://autos.yahoo.com/new_cars.html