Skip to content

Commit 316d7fc

Browse files
author
BoboTiG
committed
Fix get_pixels: now it returns an image object with all pixels data
1 parent ce3cd0a commit 316d7fc

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

mss.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ def __init__(self, debug=False):
155155
''' Global vars and class overload. '''
156156

157157
self.DEBUG = debug in [True, 'on' 'yes', 'oui', 1]
158-
159158
self.debug('__init__', 'DEBUG', self.DEBUG)
160159
self.init()
161160

@@ -350,10 +349,10 @@ def get_pixels(self, monitor):
350349
self.image = CGWindowListCreateImage(
351350
rect, kCGWindowListOptionOnScreenOnly,
352351
kCGNullWindowID, kCGWindowImageDefault)
353-
return 1
352+
return self.image
354353

355354
def save_img(self, data, width, height, output):
356-
''' Use our own save_img() method. Because I'm Mac ... '''
355+
''' Use my own save_img() method. Because I'm Mac ... '''
357356

358357
self.debug('MSSMac: save_img()')
359358

@@ -364,7 +363,7 @@ def save_img(self, data, width, height, output):
364363
kCGImagePropertyDPIWidth: dpi,
365364
kCGImagePropertyDPIHeight: dpi,
366365
}
367-
CGImageDestinationAddImage(dest, self.image, properties)
366+
CGImageDestinationAddImage(dest, data, properties)
368367

369368

370369
class MSSLinux(MSS):
@@ -581,7 +580,8 @@ def pix(pixel, _resultats={}):
581580
for y in range(height) for x in range(width)]
582581

583582
self.xlib.XFree(image)
584-
return b''.join(pixels)
583+
self.image = b''.join(pixels)
584+
return self.image
585585

586586

587587
class MSSWindows(MSS):
@@ -733,7 +733,8 @@ def _arrange(self, data, width, height):
733733
for x in range(0, width - 2, 3):
734734
scanlines[off+x:off+x+3] = \
735735
b(data[offset+x+2]), b(data[offset+x+1]), b(data[offset+x])
736-
return b''.join(scanlines)
736+
self.image = b''.join(scanlines)
737+
return self.image
737738

738739

739740
def main(argv=[]):

0 commit comments

Comments
 (0)