Resizing wxImage

Hi there,

I am just starting up with Python, and loving it.

This snippet has me consomethingbobulated:
      
..................
  jpgName = "/home/knoppix/Photos/Play/mvc00022.jpg"
        img = wxImage(jpgName, wxBITMAP_TYPE_JPEG).ConvertToBitmap()
        imgSmall = img.scale(100,100)
        wxStaticBitmap(self, -1, imgSmall, pos = (120,
    20),size=(100,100))
...................

I get this error:

Traceback (most recent call last):
  File "GalleryTextProvider.py", line 152, in ?
    app = MyApp(0)
  File "/usr/lib/python2.3/site-packages/wxPython/wx.py", line 1951, in
__init__
    _wxStart(self.OnInit)
  File "GalleryTextProvider.py", line 147, in OnInit
    frame = MyFrame(NULL, -1, "GalleryTextProvider")
  File "GalleryTextProvider.py", line 100, in __init__
    imgSmall = img.scale(100,100)
AttributeError: wxBitmapPtr instance has no attribute 'scale'

If img is of type wxImage, how can it be pointer, and not a bitmap? Or
more to the point, how do I resize img?

Any smacks to the head appreciated ( as long as they point me in the
right direction!

Steve

Steve,

note that you're converting the image to a bitmap (via ConvertToBitmap).
Bitmaps don't have a scale method. wxImage has a scale method, but it
has an uppercase letter at the beginning.

You could use something like this:

img = wxImage(jpgName, wxBITMAP_TYPE_JPEG)
imgSmall = img.Scale(100, 100)
wxStaticBitmap(self, -1, wxBitmapFromImage(imgSmall))

Markus

···

Am Mon, den 29.12.2003 schrieb Steve Cronje um 16:27:

Hi there,

I am just starting up with Python, and loving it.

This snippet has me consomethingbobulated:
      
..................
  jpgName = "/home/knoppix/Photos/Play/mvc00022.jpg"
        img = wxImage(jpgName, wxBITMAP_TYPE_JPEG).ConvertToBitmap()
        imgSmall = img.scale(100,100)
        wxStaticBitmap(self, -1, imgSmall, pos = (120,
    20),size=(100,100))
...................

I get this error:

Traceback (most recent call last):
  File "GalleryTextProvider.py", line 152, in ?
    app = MyApp(0)
  File "/usr/lib/python2.3/site-packages/wxPython/wx.py", line 1951, in
__init__
    _wxStart(self.OnInit)
  File "GalleryTextProvider.py", line 147, in OnInit
    frame = MyFrame(NULL, -1, "GalleryTextProvider")
  File "GalleryTextProvider.py", line 100, in __init__
    imgSmall = img.scale(100,100)
AttributeError: wxBitmapPtr instance has no attribute 'scale'

If img is of type wxImage, how can it be pointer, and not a bitmap? Or
more to the point, how do I resize img?

Any smacks to the head appreciated ( as long as they point me in the
right direction!

Steve

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

That works perfectly! Thanks. I am really enjoying programming again.

Steve

···

On Mon, 2003-12-29 at 09:39, Markus Meyer wrote:

Steve,

note that you're converting the image to a bitmap (via ConvertToBitmap).
Bitmaps don't have a scale method. wxImage has a scale method, but it
has an uppercase letter at the beginning.

You could use something like this:

img = wxImage(jpgName, wxBITMAP_TYPE_JPEG)
imgSmall = img.Scale(100, 100)
wxStaticBitmap(self, -1, wxBitmapFromImage(imgSmall))