[Pythonmac-SIG] Generating Mac PICT files

Jack Jansen Jack.Jansen@cwi.nl
Tue, 18 Mar 2003 15:01:30 +0100


On Monday, Mar 17, 2003, at 23:55 Europe/Amsterdam, Andy Robinson wrote:
> Does anyone know of existing Python code which
> can take a bitmap image (e.g array of RGB pixels out
> of PIL or something) and generate a PICT file?
> I'd like to make this one of the export formats for
> reportlab/graphics.
>
> It seems easy enough on the Mac (e.g. with piddleQD)
> calling the QuickDraw modules but if possible I'd
> prefer something platform-independent.

The img package can do this, through its imgpict module. If you have
MacPython-OS9 (as I suspect you have:-) you can find it
in :Extensions:img. Otherwise you can download a fairly old version
of img from <http://www.cwi.nl/ftp/jack/python>.

This code is platform independent, and will write 24 bit color
bitmapped PICT files. If you don't want to use all of img then the
dependencies should be fairly easy to rip out (but do notice that
Macintosh rgb byte order is reverse from what most platforms use).
--
Jack Jansen, <Jack.Jansen@cwi.nl>, http://www.cwi.nl/~jack
If I can't dance I don't want to be part of your revolution -- Emma 
Goldman