[cairo-commit] pycairo/test isurface_create_for_data1.py, 1.4, 1.5 isurface_create_for_data2.py, 1.2, 1.3

Steve Chaplin commit at pdx.freedesktop.org
Mon May 12 05:06:39 PDT 2008


Committed by: stevech1097

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

Modified Files:
	isurface_create_for_data1.py isurface_create_for_data2.py 
Log Message:
'SC'

Index: isurface_create_for_data1.py
===================================================================
RCS file: /cvs/cairo/pycairo/test/isurface_create_for_data1.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- isurface_create_for_data1.py	27 Dec 2006 07:13:58 -0000	1.4
+++ isurface_create_for_data1.py	12 May 2008 12:06:36 -0000	1.5
@@ -7,12 +7,12 @@
 import cairo
 
 dir_ = "/tmp/"
-imgW, imgH = 255, 255
-data = array.array('B', [0] * imgW * imgH * 4)
+width, height = 255, 255
+data = array.array('B', [0] * width * height * 4)
 
-for y in range(imgH):
-    for x in range(imgW):
-        offset = (x + (y * imgW)) * 4
+for y in range(height):
+    for x in range(width):
+        offset = (x + (y * width)) * 4
         alpha = y
 
         # cairo.FORMAT_ARGB32 uses pre-multiplied alpha
@@ -21,8 +21,7 @@
         data[offset+2] = 0                    # R
         data[offset+3] = alpha                # A
 
-stride = imgW * 4
-surface = cairo.ImageSurface.create_for_data (data, cairo.FORMAT_ARGB32,
-                                              imgW, imgH, stride)
-ctx = cairo.Context (surface)
-surface.write_to_png (dir_ + 'for_data1.png')
+surface = cairo.ImageSurface.create_for_data(data, cairo.FORMAT_ARGB32,
+                                             width, height)
+ctx = cairo.Context(surface)
+surface.write_to_png(dir_ + 'for_data1.png')

Index: isurface_create_for_data2.py
===================================================================
RCS file: /cvs/cairo/pycairo/test/isurface_create_for_data2.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- isurface_create_for_data2.py	27 Dec 2006 07:13:58 -0000	1.2
+++ isurface_create_for_data2.py	12 May 2008 12:06:36 -0000	1.3
@@ -3,14 +3,15 @@
 """
 
 import cairo
+
 import numpy
 
 dir_ = "/tmp/"
-imgW, imgH = 255, 255
-data = numpy.ndarray (shape=(imgH,imgW,4), dtype=numpy.uint8)
+width, height = 255, 255
+data = numpy.ndarray (shape=(height,width,4), dtype=numpy.uint8)
 
-for x in range(imgW):
-    for y in range(imgH):
+for x in range(width):
+    for y in range(height):
         alpha = y
 
         # cairo.FORMAT_ARGB32 uses pre-multiplied alpha
@@ -19,8 +20,7 @@
         data[y][x][2] = 0
         data[y][x][3] = alpha
 
-stride = imgW * 4
 surface = cairo.ImageSurface.create_for_data (data, cairo.FORMAT_ARGB32,
-                                              imgW, imgH, stride)
-ctx = cairo.Context (surface)
-surface.write_to_png (dir_ + 'for_data2.png')
+                                              width, height)
+ctx = cairo.Context(surface)
+surface.write_to_png(dir_ + 'for_data2.png')



More information about the cairo-commit mailing list