[cairo-commit] pycairo/test to_rgba.py,NONE,1.1
Steve Chaplin
commit at pdx.freedesktop.org
Sun Oct 16 19:31:33 PDT 2005
- Previous message: [cairo-commit] pycairo patch.cairo.h, NONE,
1.1 patch.cairo-image-surface.c, NONE, 1.1 INSTALL, 1.2,
1.3 configure.ac, 1.39, 1.40 ChangeLog, 1.187, 1.188
- Next message: [cairo-commit] pycairo/cairo pycairo-surface.c,1.59,1.60
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: stevech1097
Update of /cvs/cairo/pycairo/test
In directory gabe:/tmp/cvs-serv7419/test
Added Files:
to_rgba.py
Log Message:
'SC'
--- NEW FILE: to_rgba.py ---
#!/usr/bin/env python
"""
Read a pycairo surface into a PIL image.
Requires a patched version of cairo
"""
import Image
import cairo
filename = "/tmp/file"
# 1 ImageSurface
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 150, 100)
width, height = surface.get_width(), surface.get_height()
ctx = cairo.Context (surface)
ctx.scale (width, height)
pat = cairo.LinearGradient (0.0, 0.0, 0.0, 1.0)
pat.add_color_stop_rgba (1, 0, 0, 0, 1)
pat.add_color_stop_rgba (0, 1, 1, 1, 1)
ctx.rectangle (0,0,1,1)
ctx.set_source (pat)
ctx.fill ()
data = surface.to_rgba()
im = Image.frombuffer ("RGBA", (width, height), data, "raw", "RGBA", 0,1)
im.save (filename + '.out1.png')
# 2 ImageSurface.create_from_png()
surface = cairo.ImageSurface.create_from_png ('/tmp/arc.png')
width, height = surface.get_width(), surface.get_height()
data = surface.to_rgba()
im = Image.frombuffer ("RGBA", (width, height), data, "raw", "RGBA", 0,1)
im.save (filename + '.out2.png')
- Previous message: [cairo-commit] pycairo patch.cairo.h, NONE,
1.1 patch.cairo-image-surface.c, NONE, 1.1 INSTALL, 1.2,
1.3 configure.ac, 1.39, 1.40 ChangeLog, 1.187, 1.188
- Next message: [cairo-commit] pycairo/cairo pycairo-surface.c,1.59,1.60
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the cairo-commit
mailing list