[Image-SIG] Does the experimental RGBA-on-RGB drawing mode work?
Uttam M. Narsu
unarsu at gmail.com
Wed Dec 10 20:05:25 CET 2008
Looks like it might be a bug in the ImageDraw init function. If I
change the 3rd line to:
ml = Image.new("RGB", (200,200), (0,0,0,0))
it works. Looking at the source of ImageDraw.py:
blend = 0
if mode is None:
mode = im.mode
if mode != im.mode:
if mode == "RGBA" and im.mode == "RGB":
blend = 1
blend is set to 1, only if the modes are "RGBA" and "RGB". Shouldn't
blending occur if I create an RGBA image and draw onto it? Or do I
have to explicitly set a blend mode somewhere?
-u
On Wed, Dec 10, 2008 at 1:32 PM, Uttam M. Narsu <unarsu at gmail.com> wrote:
> Apologies if this is a dup, since I wasn't subscribed to the list.
> I'm trying to draw using the experimental RGBA-on-RGB interface. I
> can't seem to get it to work. My code is below:
>
> from PIL import Image, ImageDraw
>
> ml = Image.new("RGBA", (200,200))
> D = ImageDraw.Draw(ml, "RGBA")
>
> red = (0xff, 0x00, 0x00, 0xA9)
> green = (0x00, 0xbf, 0x00, 0x83)
>
> D.polygon([(40, 40), (40, 100), (100, 100), (100, 40)], fill=red)
> D.polygon([(20, 20), (20, 80), (80, 80), (80, 20)], fill=green)
> ml.save("test.png", "PNG")
>
> Results in the attached image. The red polygon doesn't show through
> beneath the green one.
>
> I'd appreciate any pointers on this. It seems fairly simple.
>
> I'm using python/py25-pil 1.1.6 installed through macports on leopard. Thanks.
>
> -
> uman
>
More information about the Image-SIG
mailing list