Python Imaging Library and PyGTK - color image path?

2005-04-23 Thread Jeremy Bowers
I have an image in the Python Image Library. I'm trying to get it into
PyGTK in color. Is there any way to do this cross-platform, preferably
without writing to anything to the disk?

PIL apparently can't write XPMs. GTK will only take XPMs, that I can see.
Therein lies the rub. I can ship over monochrome bitmaps via XBM, but I'd
rather be able to ship over full color.

(Use case, in case it matters: I am trying to embed a graphic into a text
widget. This is going fine. Because I want the text widget to be able use
different size text, and no one image can look right with everything from
8pt to 40pt text (all reasonable possibilities), I load a large image in
from the disk and scale it down as needed; the images are designed to
scale well and later I can make multiple source images if that is
desirable. But I can't figure out how to get the scaled image into GTK.
This surprises me.)

If there's an easy Google search, it has eluded me.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Imaging Library and PyGTK - color image path?

2005-04-23 Thread Jeremy Bowers
On Fri, 22 Apr 2005 22:43:13 -0400, Jeremy Bowers wrote:
 (Use case, in case it matters: I am trying to embed a graphic into a text
 widget. This is going fine. Because I want the text widget to be able use
 different size text, and no one image can look right with everything from
 8pt to 40pt text (all reasonable possibilities), I load a large image in
 from the disk and scale it down as needed; the images are designed to
 scale well and later I can make multiple source images if that is
 desirable. But I can't figure out how to get the scaled image into GTK.
 This surprises me.)

As usual, posting for help after poking around for a long while guarantees
you'll figure it out in the next few minutes. You need to create GDK
pixbufs, which can be resized and scaled and stuff.

There is definitely some room for confusion here with GTK Images, GDK
Images, GTK pixbufs, and GDK pixbufs
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Imaging Library and PyGTK - color image path?

2005-04-23 Thread Fredrik Lundh
Jeremy Bowers wrote:
I have an image in the Python Image Library. I'm trying to get it into
PyGTK in color. Is there any way to do this cross-platform, preferably
without writing to anything to the disk?
PIL apparently can't write XPMs. GTK will only take XPMs, that I can see.
Therein lies the rub. I can ship over monochrome bitmaps via XBM, but I'd
rather be able to ship over full color.
the first two google hits for PyGTK PIL are
   http://www.daa.com.au/pipermail/pygtk/2005-April/009988.html
which provides a StringIO-based solution, and
   http://www.daa.com.au/pipermail/pygtk/2003-February/004393.html
which discusses draw_rgb_image and friends, and says that if you can convert
your PIL image to a  pixel data string or buffer object, you could use them to
display the image.  here's some code that seems to do exactly that:
   http://www.mail-archive.com/pygtk@daa.com.au/msg07167.html
(but maybe this is some kind of stupid a bitmap isn't a pixmap isn't an image
thing?  if so, I suggest getting a modern windowing system ;-)
/F
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python Imaging Library and PyGTK - color image path?

2005-04-23 Thread Jeremy Bowers
On Sat, 23 Apr 2005 10:20:29 +0200, Fredrik Lundh wrote:
 which discusses draw_rgb_image and friends, and says that if you can
 convert your PIL image to a  pixel data string or buffer object, you could
 use them to display the image.  here's some code that seems to do exactly
 that:
 
 http://www.mail-archive.com/pygtk@daa.com.au/msg07167.html
 
 (but maybe this is some kind of stupid a bitmap isn't a pixmap isn't an
 image thing?  if so, I suggest getting a modern windowing system ;-)

A varient; I was missing the gdk.pixbuf because I assumed that because
there was a gtk.pixbuf that I knew about, that I had all relevant data.
Were that the only pixbuf, that would be an atrocity. (Particularly odd
for GTK, the *Gimp* windowing toolkit.)

(It of course figures that was the google search; I think I tried
everything but that; python imaging library pygtk isn't anywhere near
as helpful, for instance.)
-- 
http://mail.python.org/mailman/listinfo/python-list