55from demosys .conf import settings
66
77
8- def create (window , format = 'png' ):
8+ def create (format = 'png' ):
99 """
1010 Create a screenshot
1111 :param format: formats supported by PIL (png, jpeg etc)
@@ -20,15 +20,13 @@ def create(window, format='png'):
2020 else :
2121 print ("SCREENSHOT_PATH {} does not exist. Using cwd as fallback" .format (settings .SCREENSHOT_PATH ))
2222
23- # x, y, width, height = GL.glGetIntegerv(GL.GL_VIEWPORT)
24- # print("Screenshot viewport:", x, y, width, height)
25- # FIXME: Snap to viewport
26- print ("Screenshot viewport:" , window .buffer_width , window .buffer_height )
23+ x , y , width , height = GL .glGetIntegerv (GL .GL_VIEWPORT )
24+ print ("Screenshot viewport:" , x , y , width , height )
2725 GL .glPixelStorei (GL .GL_PACK_ALIGNMENT , 1 )
2826
29- data = GL .glReadPixels (0 , 0 , window . buffer_width , window . buffer_height , GL .GL_RGB , GL .GL_UNSIGNED_BYTE )
27+ data = GL .glReadPixels (x , y , width , height , GL .GL_RGB , GL .GL_UNSIGNED_BYTE )
3028
31- image = Image .frombytes ("RGB" , (window . buffer_width , window . buffer_height ), data )
29+ image = Image .frombytes ("RGB" , (width , height ), data )
3230 image = image .transpose (Image .FLIP_TOP_BOTTOM )
3331 name = "{}.{}" .format (datetime .now ().strftime ("%Y-%m-%d-%H-%M-%S" ), format )
3432 image .save (os .path .join (dest , name ), format = format )
0 commit comments