[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame]



It builds OK, and the examples seem to work too. Is there anything specific that you want to test? Some minor changes that I am using are attached.

Christoph

On 2/26/2011 11:10 AM, Lenard Lindstrom wrote:
Hi Christoph,

I commit the patch and additional changes to SVN rev 3007. Would you
please test it as I don't have a web camera handy and, before now, the
camera module was not built by default for Python 3.

Lenard

On 26/02/11 10:03 AM, Lenard Lindstrom wrote:
Great. I will apply the patch.

Lenard

On 26/02/11 09:44 AM, Christoph Gohlke wrote:
Hello,

Pygame works well on Python 3.2 for Windows 32 and 64 bit. I have
installers at <http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame>.
The _movie module seems to work. The changes to _camera.c are attached.

Christoph




Index: lib/_camera_vidcapture.py
===================================================================
--- lib/_camera_vidcapture.py	(revision 3007)
+++ lib/_camera_vidcapture.py	(working copy)
@@ -17,13 +17,15 @@
 
 
 def init():
-    global vidcap
-    vidcap = vc
 
+
     try:
         import vidcap as vc
     except ImportError:
         from VideoCapture import vidcap as vc
+        
+    global vidcap
+    vidcap = vc        
 
 
 def quit():
Index: examples/vgrade.py
===================================================================
--- examples/vgrade.py	(revision 3007)
+++ examples/vgrade.py	(working copy)
@@ -1,12 +1,12 @@
 #!/usr/bin/env python
 
-"""This example demonstrates creating an image with Numeric
+"""This example demonstrates creating an image with numpy
 python, and displaying that through SDL. You can look at the
-method of importing numeric and pygame.surfarray. This method
+method of importing numpy and pygame.surfarray. This method
 will fail 'gracefully' if it is not available.
 I've tried mixing in a lot of comments where the code might
 not be self explanatory, nonetheless it may still seem a bit
-strange. Learning to use numeric for images like this takes a
+strange. Learning to use numpy for images like this takes a
 bit of learning, but the payoff is extremely fast image
 manipulation in python.
 
@@ -24,12 +24,12 @@
 from pygame.locals import *
 
 try:
-    from Numeric import *
-    from RandomArray import *
+    from numpy import *
+    from numpy.random import *
 except ImportError:
-    raise SystemExit('This example requires Numeric and the pygame surfarray module')
+    raise SystemExit('This example requires numpy and the pygame surfarray module')
 
-pygame.surfarray.use_arraytype('numeric')
+pygame.surfarray.use_arraytype('numpy')
 
 timer = 0
 def stopwatch(message = None):
@@ -53,12 +53,12 @@
     diff = bottomcolor - topcolor
     width, height = surf.get_size()
     # create array from 0.0 to 1.0 triplets
-    column = arange(height, typecode=Float)/height
-    column = repeat(column[:, NewAxis], [3], 1)
+    column = arange(height, dtype='float')/height
+    column = repeat(column[:, newaxis], [3], 1)
     # create a single column of gradient
-    column = topcolor + (diff * column).astype(Int)
+    column = topcolor + (diff * column).astype('int')
     # make the column a 3d image column by adding X
-    column = column.astype(UnsignedInt8)[NewAxis,:,:]
+    column = column.astype('uint8')[newaxis,:,:]
     #3d array into 2d array
     column = pygame.surfarray.map_array(surf, column)
     # stretch the column into a full image
Index: examples/blit_blends.py
===================================================================
--- examples/blit_blends.py	(revision 3007)
+++ examples/blit_blends.py	(working copy)
@@ -8,9 +8,9 @@
 
 try:
     import pygame.surfarray
-    import Numeric
+    import numpy
 except:
-    print ("no surfarray for you!  install Numeric")
+    print ("no surfarray for you!  install numpy")
 
 import time
         
@@ -134,10 +134,10 @@
                 t1 = time.time()
                 im1p = pygame.surfarray.pixels3d(im1)
                 im2p = pygame.surfarray.pixels3d(im2)
-                im1p16 = im1p.astype(Numeric.UInt16)
-                im2p16 = im1p.astype(Numeric.UInt16)
+                im1p16 = im1p.astype(numpy.uint16)
+                im2p16 = im1p.astype(numpy.uint16)
                 im1p16 += im2p16
-                im1p16 = Numeric.minimum(im1p16, 255)
+                im1p16 = numpy.minimum(im1p16, 255)
                 pygame.surfarray.blit_array(im1, im1p16)
 
                 del im1p