On 4/11/07, Douglas Bagnall <[EMAIL PROTECTED]> wrote:
> Alexey,  I think you are completely right about the problem, but the
> solution can be quite a bit simpler:
>
> dtop = Image.open("dtop.png")
> frame = Image.open("frame.png")
>
> dtop.paste(frame.convert('RGB'), (0,0), frame)
> dtop.save("test.png")

Hmm... The good part I see in this solution is that when image is
converted from RGBA to RGB it just so happens that its pixelsize is
still 4 but 4th byte is filled with 255. Then paste_mask_RGBA kicks
in, and if dtop has alpha channel it will composite its alpha channel
with 255, decreasing dtop transparency where frame is not completely
transparent. To be honest I'm not sure what is generally expected in
this situation, though looking at the way antigrain does rgba blending
I see that it essentially has this formula:

    a = a * (1 - alpha) + 1 * alpha

Which is just the way it works in the code above (and absolutely not
the way it'd worked in my code). So if this behavior is expected my
example wouldn't even work as it should, thanks for showing that. :)

Best regards,
Alexey.
_______________________________________________
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig

Reply via email to