pygame.surfarray.
array3d
()Copy the pixels from a Surface into a 3D array. The bit depth of the surface will control the size of the integer values, and will work for any type of pixel format.
This function will temporarily lock the Surface as pixels are copied (see the pygame.Surface.lock()
lock the Surface memory for pixel access - lock the Surface memory for pixel access method).
本函数主要锁住表面,然后把像素拷贝到一个三维数组,数组表示为:RGB的颜色整数值。
例子:
image_data = pygame.surfarray.array3d(pygame.display.get_surface()) pygame.display.update() FPSCLOCK.tick(FPS) #print self.upperPipes[0]['y'] + PIPE_HEIGHT - int(BASEY * 0.2) return image_data, reward, terminal