[wxPython] Is there a TGA image handler Somewhere ?

I have a wxPython application that loads and diplays images lists in a window. I would like to load and display TGA images using wxBitmap objects, as for the other image formats. Has anyone seen or used an image handler for that type of bitmaps as there don't seem to exist one by default in wxWindows/wxPython ? Thanx.

···

-----------------------------------
  Frederic Jaume - R & D
  Cryo Interactive Entertainment
  Mel: f.jaume@cryo-interactive.fr
  ICQ: 23383289
  Tel: 33 (0)1 44 65 25 65
-----------------------------------

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

Look in the archives for information about using the so-called Python
Imaging Library with wxPython--I think this was around the beginning of the
year. Sorry, I haven't got time at the moment for any more!

Cheerio...

···

-------------------------------------------------------------------------
Chris Fama <mailto:Chris.Fama@uq.net.au> Phone:(07) 3870 5639
Brisbane, Australia Mobile:(0400) 833 700
-------------------------------------------------------------------------
"This 'telephone' has too many shortcomings to be seriously
considered as a means of communication. The device is inherently of
no value to us."
--Western Union internal memo, 1876.

-----Original Message-----
From: wxpython-users-admin@lists.sourceforge.net
[mailto:wxpython-users-admin@lists.sourceforge.net]On Behalf Of Frédéric
Jaume
Sent: Tuesday, 19 December 2000 2:35 AM
To: wxpython-users@lists.sourceforge.net
Subject: [wxPython] Is there a TGA image handler Somewhere ?

  I have a wxPython application that loads and diplays images lists in a
window. I would like to load and display TGA images using
wxBitmap objects,
as for the other image formats. Has anyone seen or used an image handler
for that type of bitmaps as there don't seem to exist one by default in
wxWindows/wxPython ? Thanx.
-----------------------------------
  Frederic Jaume - R & D
  Cryo Interactive Entertainment
  Mel: f.jaume@cryo-interactive.fr
  ICQ: 23383289
  Tel: 33 (0)1 44 65 25 65
-----------------------------------

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

PIL (http://www.pythonware.com/products/pil/index.htm) is, indeed, able to read TGA files, so that's a viable way to go.

Here's some code to convert a PIL Image to a wxBitmap:

def PilImgToWxBmp(pilImg):
   wxImg = wxEmptyImage(pilImg.size[0],pilImg.size[1])
   wxImg.SetData(pilImg.tostring())
   bmp = wxImg.ConvertToBitmap()
   return bmp

You can load the TGA file quite simply into a PIL Image with:
from Pil import Image
img = Image.open('foo.tga')

I hope this helps,
-greg

···

At 08:35 AM 12/18/2000, Frédéric Jaume wrote:

I have a wxPython application that loads and diplays images lists in a window. I would like to load and display TGA images using wxBitmap objects, as for the other image formats. Has anyone seen or used an image handler for that type of bitmaps as there don't seem to exist one by default in wxWindows/wxPython ? Thanx.

----
greg Landrum (greglandrum@earthlink.net)
Software Carpenter/Computational Chemist

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

Also I believe (unless wxPython2.0 fixed this) that SetData input is to be
an RGB image; grayscale might give an error. Could do:

if pilImg.mode == 'L':
    pilImg= pilImg.convert("RGB")
wxImg = wxEmptyImage(pilImg.size[0], pilImg.size[1])
wxImg.SetData(pilImg.tostring('raw','RGB'))

Bob

···

At 07:34 AM 12/19/00 -0800, you wrote:

At 08:35 AM 12/18/2000, Frédéric Jaume wrote:

I have a wxPython application that loads and diplays images lists in a
window. I would like to load and display TGA images using wxBitmap
objects, as for the other image formats. Has anyone seen or used an image
handler for that type of bitmaps as there don't seem to exist one by
default in wxWindows/wxPython ? Thanx.

PIL (http://www.pythonware.com/products/pil/index.htm) is, indeed, able to
read TGA files, so that's a viable way to go.

Here's some code to convert a PIL Image to a wxBitmap:

def PilImgToWxBmp(pilImg):
  wxImg = wxEmptyImage(pilImg.size[0],pilImg.size[1])
  wxImg.SetData(pilImg.tostring())
  bmp = wxImg.ConvertToBitmap()
  return bmp

You can load the TGA file quite simply into a PIL Image with:
from Pil import Image
img = Image.open('foo.tga')

-------------------------------------------------
Robert B. Klimek
NASA Glenn Research Center
robert.klimek@grc.nasa.gov
(216) 433-2837
--------------------------------------------------

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users