Skip to content

Commit 0c96c55

Browse files
author
BoboTiG
committed
Windows: python 3 support
1 parent dff2e9f commit 0c96c55

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

mss.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@
5151

5252
from ctypes.util import find_library
5353
from struct import pack
54-
import zlib
5554
from platform import system
55+
import sys
56+
import zlib
5657

5758
if system() == 'Darwin':
5859
from Quartz import *
@@ -159,6 +160,13 @@ class BITMAPINFO(Structure):
159160
# --- [ C'est parti mon kiki ! ] ---------------------------------------
160161
# ----------------------------------------------------------------------
161162

163+
if sys.version < '3':
164+
def b(x):
165+
return x
166+
else:
167+
def b(x):
168+
return pack('<B', x)
169+
162170
class MSS(object):
163171
''' This class will be overloaded by a system specific one.
164172
It checkes if there is a class available for the current system.
@@ -688,7 +696,7 @@ def _arrange(self, data, width, height):
688696
offset = total - off
689697
x = 0
690698
while x < width - 2:
691-
scanlines[off+x:off+x+3] = data[offset+x+2], data[offset+x+1], data[offset+x]
699+
scanlines[off+x:off+x+3] = b(data[offset+x+2]), b(data[offset+x+1]), b(data[offset+x])
692700
x += 3
693701
return b''.join(scanlines)
694702

0 commit comments

Comments
 (0)