ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> wxPython-users
wxPython-users
Re: [wxPython-users] A question on wxPython + PIL and a possible bug
by Robin Dunn other posts by this author
Apr 15 2003 9:26PM messages near this date
[wxPython-users] Re: A question on wxPython + PIL and a possible bug | Re: [wxPython-users] A question on wxPython + PIL and a possible bug
Alberto Griggio wrote:
>  Hello everybody,
>  first I wanted to report what it seems a bug to me: according to the
>  doc, wx.Timer.Start returns True or False depending on the success of
>  the operation. But here (wxPython 2.4.0.6  GTK - but I think also MSW)
>  it always returns None. I can't test it on 2.4.0.7 at the moment, so
>  sorry if it has been already fixed.

It has now.  Thanks.

>  
>  Now, the question. I'm using wxPython together with the PIL to handle
>  images. Browsing the wiki, I found that the suggested way to get a
>  wx.Bitmap from a PIL image is:
>  
>      img = wx.EmptyImage(*pil_image.size)
>      img.SetData(pil_image.convert('RGB').tostring()) bmp =
>      wx.BitmapFromImage(img)
>  
>  This works like a charm on most cases, but if the image is originally
>  in RGBA format, it causes a loss of information. This is annoying when
>  the image has transparency, since it is completely lost.
>  
>  As a workaround, I'm doing something like:
>  
>      if pil_image.mode == 'RGBA':
>          alpha = pil_image.split()[3]
>          mask = wx.EmptyImage(*alpha.size)
>          mask.SetData(alpha.convert('1').convert('RGB').tostring())
>          bmp.SetMask(wx.Mask(wx.BitmapFromImage(mask, 1)))
>  
>  But the results are not perfect (see
>  http://web.tiscali.it/agriggio/wx_pil.html)
>  
>  So I'd like to know if there's a better way to do this.


Not currently, but 2.5 is getting alpha support in wxImage and wxBitmap, 
as well as some other nice image/bitmap enhancements...


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



---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@[...].org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org
Thread:
Alberto Griggio
Alberto Griggio
Robin Dunn
Alberto Griggio
Robin Dunn
Shane Holloway (IEEE)

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved