AW: Re: AW: Re: Resize Bitmap?

Sorry Alex,
Certainly i meant you!
Sometimes in the wxPython docs you need to have a look for the wxPython
notes at the end of a special function documentation. What you read where
the C++ constructors, and, especially for the constructor section of a
class, you often have different constructors for Python while in C++ they
can (and have to!) be overwritten and all be called with the same name. So
for a wxBitmap, in the docs we have:

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.

As wx.Image.ConvertToBitmap() is signed as deprecated you are warmly invited
to use wx.BitmapFromImage(wx.Image, depth=-1) instead.

But you're right: sometimes it is not well shown in the docs how to do
things in wxPython. Then go to the demo and look into the sources or have a
look at the module sources under Lib\site-packages\wx where you will
certainly find the function you're looking for.

Best regards
Oliver

···

-----Ursprüngliche Nachricht-----
Von: news [mailto:news@sea.gmane.org] Im Auftrag von Alex Zeiger
Gesendet: Dienstag, 8. Juni 2004 09:51
An: wxpython-users@lists.wxwindows.org
Betreff: [wxPython-users] Re: AW: Re: Resize Bitmap?

Oliver Walczak wrote:

Dear Slawomir,
In line 38 use

bmp = wx.BitmapFromImage(img)

In Python functions cannot be owerwritten, and you used the constructor
which accepts only the filename to create the bitmap. Please refer to the
docs again.
Regards
Oliver

Thanks (I'm assuming you meant to reply to me instead of Slawomir). That
solved my problem. However, straight from the 2.5.1 docs under wxBitmap:

"wxBitmap(const wxString& name, long type)

Loads a bitmap from a file or resource.

wxBitmap(const wxImage& img, int depth = -1)

Creates bitmap object from the image. This has to be done to actually
display an image as you cannot draw an image directly on a window. The
resulting bitmap will use the provided colour depth (or that of the
current system if depth is -1) which entails that a colour reduction has
to take place."

From the error, I understood that the later constructor doesn't
actually exist, and that Python was attempting to use the former. I now
see that this is probably an error in the docs.

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

Hello!

Here is my 2 cents:

wxBitmapFromBits(bits, width, height, depth=-1) Create a bitmap from an

array of bits contained in a string.

- this seems broken (at least I can't get it working). So instead just
saying:

---- this code does not work
bits, size = [ load image somehow... ]
bmp = wx.BitmapFromBits( bits, size[0], size[1], 24 )

···

----

I use the following quirk:

---- this code works okay
bits, size = [ load image somehow... ]
wx_image = wx.EmptyImage( size[0],size[1] )
wx_image.SetData( bits )
bmp = wx.BitmapFromImage( wx_image, 24 )
----

This is win2000 + wx 2.5.1 + Python 2.3.3

    Vladimir Ignatov