identify x,y coordinates in an image

Steve Holden sholden at holdenweb.com
Wed Nov 7 17:35:15 EST 2001


"Cliff Wells" <logiplexsoftware at earthlink.net> wrote ...
[ ... ]
> Since I've been asked for them so often (three times and counting!), I'll
> post them to the list.  I believe I got the original code from Piddle...
it's
> been a while, so I'm not too sure.  And yes, those are tab-indentations
(damn
> you four-spacers!).
>
Well, in my case that should now read  "were tab-indentations": see what OE
does to your beautiful tabs -- completely lost, along with the sense of the
code:

> def PILToWX(image):
> "convert a PIL image to a wxImage"
> if (image.mode != 'RGB'):
> image = image.convert('RGB')
> imageData = image.tostring('raw', 'RGB')
> imageWx = wxEmptyImage(image.size[0], image.size[1])
> imageWx.SetData(imageData)
> return imageWx
>
> def WXToPIL(image, mode = 'RGBA'):
> "convert a wxImage to a PIL RGBA image"
> imageData = image.GetData()
> size = (image.GetWidth(), image.GetHeight())
> imagePIL = Image.fromstring('RGB', size, imageData)
> if mode != 'RGB':
> imagePIL = imagePIL.convert(mode)
> return imagePIL
>
don't-know-a-mail-tool-that-drops-leading-spaces-ly y'rs  - steve
--
http://www.holdenweb.com/








More information about the Python-list mailing list