File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change 7
7
from demosys import context
8
8
9
9
10
+ class Config :
11
+ """Container for screenshot target"""
12
+ target = None
13
+ alignment = 1
14
+
15
+
10
16
def create (file_format = 'png' , name = None ):
11
17
"""
12
18
Create a screenshot
@@ -21,12 +27,18 @@ def create(file_format='png', name=None):
21
27
else :
22
28
print ("SCREENSHOT_PATH not defined in settings. Using cwd as fallback." )
23
29
24
- fbo = context .ctx ().screen
25
- image = Image .frombytes ("RGB" , (fbo .width , fbo .height ), fbo .read ())
30
+ if not Config .target :
31
+ Config .target = context .ctx ().screen
32
+
33
+ image = Image .frombytes (
34
+ "RGB" ,
35
+ (Config .target .width , Config .target .height ), Config .target .read (alignment = Config .alignment )
36
+ )
26
37
image = image .transpose (Image .FLIP_TOP_BOTTOM )
27
38
28
39
if not name :
29
40
name = "{}.{}" .format (datetime .now ().strftime ("%Y-%m-%d-%H-%M-%S-%f" ), file_format )
30
41
31
- print ("Creating screenshot:" , name )
32
- image .save (os .path .join (dest , name ), format = file_format )
42
+ dest = os .path .join (dest , name )
43
+ print ("Creating screenshot:" , dest )
44
+ image .save (dest , format = file_format )
You can’t perform that action at this time.
0 commit comments