[cairo-commit] pycairo/test isurface_get_data.py,1.2,1.3

Steve Chaplin commit at pdx.freedesktop.org
Mon Nov 27 02:49:17 PST 2006


Committed by: stevech1097

Update of /cvs/cairo/pycairo/test
In directory kemper:/tmp/cvs-serv365/test

Modified Files:
	isurface_get_data.py 
Log Message:
'SC'

Index: isurface_get_data.py
===================================================================
RCS file: /cvs/cairo/pycairo/test/isurface_get_data.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- isurface_get_data.py	27 Nov 2006 01:17:42 -0000	1.2
+++ isurface_get_data.py	27 Nov 2006 10:49:13 -0000	1.3
@@ -6,7 +6,7 @@
 import cairo
 import numpy
 
-filename_base = "/tmp/file"
+dir_ = "/tmp/"
 w, h = 128, 128
 
 surface = cairo.ImageSurface (cairo.FORMAT_ARGB32, w, h)
@@ -25,7 +25,7 @@
 ctx.set_source_rgb (0, 0, 0)  # black
 ctx.set_line_width(15)
 ctx.stroke()
-surface.write_to_png (filename_base + "get_data_test1.png")
+surface.write_to_png (dir_ + "get_data_test1.png")
 
 # modify surface using numpy
 buf = surface.get_data()
@@ -34,11 +34,10 @@
 # - is a Python bug?
 #buf = buffer (surface1)
 
-a = numpy.frombuffer (buf, numpy.uint8)
-a.shape = (w, h, 4)
+a = numpy.ndarray (shape=(w,h,4), dtype=numpy.uint8, buffer=buf)
 
 # draw a vertical line
 a[:,40,0] = 255  # byte 0 is blue on little-endian systems
 a[:,40,1] = 0
 a[:,40,2] = 0
-surface.write_to_png (filename_base + "get_data_test2.png")
+surface.write_to_png (dir_ + "get_data_test2.png")



More information about the cairo-commit mailing list