bug in convert wxImage to wxBitmap?

if it is a bug, is there other non-deprecated method to do so with
pure wx(i.e. no PIL)
thanx

I want to load a picture, scale it, then put it on a staticBitmap
[code]
import wx

myimg = wx.Image("a.jpg", wx.BITMAP_TYPE_ANY).Scale(300,200)
mybmp=wx.Bitmap(myimg)
......

Traceback (most recent call last):
  File "a.py", line 5, in ?
    mybmp=wx.Bitmap(myimg)
  File "e:\prg\py\sap-24\bin\lib\site-packages\wx-2.8-msw-unicode\wx\_gdi.py",
line 542, in __init__
TypeError: String or Unicode type required
[/code]

I am using wxpython 2.8.9.2, and the doc says
[quote]
wxBitmap(const wxImage& img, int depth = -1)
Creates bitmap object from the image.
[/quote]

I have to use
[code]
mybmp=myimg.ConvertToBitmap()
[/code]
but the doc says
[quote]
wxImage::ConvertToBitmap
wxBitmap ConvertToBitmap() const

Deprecated, use equivalent wxBitmap constructor (which takes wxImage
and depth as its arguments) instead.
[/quote]

Hi,

if it is a bug, is there other non-deprecated method to do so with
pure wx(i.e. no PIL)
thanx

I want to load a picture, scale it, then put it on a staticBitmap
[code]
import wx

myimg = wx.Image("a.jpg", wx.BITMAP_TYPE_ANY).Scale(300,200)
mybmp=wx.Bitmap(myimg)
......

Traceback (most recent call last):
File "a.py", line 5, in ?
mybmp=wx.Bitmap(myimg)
File "e:\prg\py\sap-24\bin\lib\site-packages\wx-2.8-msw-unicode\wx\_gdi.py",
line 542, in __init__
TypeError: String or Unicode type required
[/code]

I am using wxpython 2.8.9.2, and the doc says
[quote]
wxBitmap(const wxImage& img, int depth = -1)
Creates bitmap object from the image.
[/quote]

I have to use
[code]
mybmp=myimg.ConvertToBitmap()
[/code]
but the doc says
[quote]
wxImage::ConvertToBitmap
wxBitmap ConvertToBitmap() const

Deprecated, use equivalent wxBitmap constructor (which takes wxImage
and depth as its arguments) instead.
[/quote]

This is not a bug, I believe you need to read the docs more carefully:

"""
wxBitmap::wxBitmap
wxBitmap()

Default constructor.

... blah blah blah ...

**wxPython note**: Constructors supported by wxPython are:

wxBitmap(name, flag) Loads a bitmap from a file
wxEmptyBitmap(width, height, depth = -1) Creates an empty bitmap with
the given specifications
wxBitmapFromXPMData(listOfStrings) Create a bitmap from a Python list
of strings whose contents are XPM data.
wxBitmapFromBits(bits, width, height, depth=-1) Create a bitmap from
an array of bits contained in a string.
wxBitmapFromImage(image, depth=-1) Convert a wxImage to a wxBitmap.

"""

And ConvertToBitmap() is not deprecated, at least on wxPython 2.8.9.2.
You shoul use wx.BitmapFromImage(yourImage) to solve your issue.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On Fri, Apr 17, 2009 at 1:38 PM, oyster wrote: