1. # Demo: Fast double-buffer blitting of images in memory with pygame in Raspian-Stretch
  2.  
  3. from os import listdir
  4. import time
  5. import pygame
  6.  
  7. # Initialize pygame
  8. pygame.init()
  9.  
  10. # create fullscreen display
  11. screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN | pygame.DOUBLEBUF | pygame.NOFRAME | pygame.HWSURFACE)
  12.  
  13. # load all image files (BMP) in folder 'images' into surfaces in RAM
  14. images = []
  15. files = listdir('fotos')
  16. for f in files:
  17.     img = pygame.image.load('fotos/'+f).convert()
  18.     images.append(img)
  19.  
  20. # blit 100 images
  21. cnt = len(images)
  22. t_start = time.time()
  23. for i in range(100):
  24.    
  25.     # blit next image into screen buffer
  26.     screen.blit(images[i % cnt], (0,0))
  27.    
  28.     # load screen buffer into actual screen
  29.     pygame.display.flip()
  30.  
  31. # show fps
  32. sec = time.time()-t_start
  33. print("fps: "+str(100/sec)) # 54
  34.  
  35. # clean up
  36. pygame.quit()
  37.  
[raw code]