[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] Big changes for pygame.image



> > the way that it is setup now, it will be pretty easy to add
> > support for exchanging images with other python projects like
> > PIL and pyopengl textures. i'm planning to add these sometime
> > this week.
> 
> Does this mean that it will be possible to use PIL.ImageDraw with
> pygame images?

yes, although you'll need to convert between a PIL Image and a pygame
Surface to go back and forth. i'll have a function that can go each
way. PIL does offer an extra set of image functionality that pygame
never will, stuff like all the filters, file formats (load and save),
histogram, image cracking, and that kind of stuff. 

anyways, back to the drawing...

    pilimg = pygame.image.to_pil(mysprite)
    draw = ImageDraw.Draw(pilimg)
    draw.line((0, 0) + pilimg.size, fill=128)
    draw.line((0, pilimg.size[1], pilimg.size[0], 0), fill=128)
    mysprite = pygame.image.from_pil(pilimg)

as you can see, this will be possible, but obviously not terribly
efficient, since we need to convert to and from. but it is possible.
btw, are you specifically wanting the ImageDraw module from PIL? we
have support for just about everything it does already in pygame, the
only things missing are arc, chord, ellipse and polygon functions.
was there something specific you were wanting? 

btw, it is very possible that there would be a way to get a PIL Image
and pygame Surface to "share" their image data. i believe it could be
done, but it would need a good digging into the PIL internals, and
i'm not up for that. if someone is motivated and come up with it
though, i'll include it!


____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org