thanks!
so does that mean the BGRA raw mode is supported in PIL 1.1.6?

Regards
Sreeram

Fredrik Lundh wrote:
> K.S.Sreeram wrote:
> 
>> I was hacking the code trying to support RGBA mode images, and
>> inadvertently i tried im.tostring("raw","BGRX") on the RGBA mode image.
>>
>> So BGRX does indeed work for RGB mode images.
>>
>> While trying to support RGBA mode images, i realized that a BGRA raw
>> mode is needed for working with QImage. It doesn't seem to be supported
>> by PIL. Any workarounds?
> 
> sure!  here's a patch:
> 
> Index: ImageQt.py
> ===================================================================
> --- ImageQt.py  (revision 342)
> +++ ImageQt.py  (working copy)
> @@ -58,6 +61,14 @@
>           elif im.mode == "RGB":
>               data = im.tostring("raw", "BGRX")
>               format = QImage.Format_RGB32
> +        elif im.mode == "RGBA":
> +            try:
> +                data = im.tostring("raw", "BGRA")
> +            except SystemError:
> +                # workaround for earlier versions
> +                r, g, b, a = im.split()
> +                im = Image.merge("RGBA", (b, g, r, a))
> +            format = QImage.Format_ARGB32
>           else:
>               raise ValueError("unsupported image mode %r" % im.mode)
> 
> </F>
> 


Attachment: signature.asc
Description: OpenPGP digital signature

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to