[cairo-commit] pycairo/test cairo_image_surface_create_for_array.py, NONE, 1.1

Steve Chaplin commit at pdx.freedesktop.org
Fri Apr 15 22:09:53 PDT 2005


Committed by: stevech1097

Update of /cvs/cairo/pycairo/test
In directory gabe:/tmp/cvs-serv4690/test

Added Files:
	cairo_image_surface_create_for_array.py 
Log Message:
SC 2005/04/16

--- NEW FILE: cairo_image_surface_create_for_array.py ---
#!/usr/bin/env python

import Numeric

import cairo
import cairo.numpy

# create an array
array = Numeric.zeros((80,80,4), Numeric.UInt8)
for i in range(80):
    for j in range(80):
        array[i][j][0] = chr(255-3*i)        # B
        array[i][j][1] = chr(255-3*abs(i-j)) # G
        array[i][j][2] = chr(255-3*j)        # R
        array[i][j][3] = 255                 # Alpha

ctx = cairo.Context()
surface = cairo.ImageSurface.create_for_array(array)
ctx.set_target_surface(surface)

try:
    fileObject = file('cairo_image_surface_create_for_array.png', 'wb')
except IOError, exc:
    raise SystemExit("%s: %s" % (exc.filename, exc.strerror))

surface.write_png(fileObject)




More information about the cairo-commit mailing list