|
@@ -218,39 +218,16 @@ class BitArray:
|
|
|
return bb
|
|
|
|
|
|
|
|
|
-if PY3:
|
|
|
+def intToUint32(i):
|
|
|
+ return int(i).to_bytes(4, "little")
|
|
|
|
|
|
- def intToUint32(i):
|
|
|
- return int(i).to_bytes(4, "little")
|
|
|
|
|
|
- def intToUint16(i):
|
|
|
- return int(i).to_bytes(2, "little")
|
|
|
+def intToUint16(i):
|
|
|
+ return int(i).to_bytes(2, "little")
|
|
|
|
|
|
- def intToUint8(i):
|
|
|
- return int(i).to_bytes(1, "little")
|
|
|
|
|
|
-
|
|
|
-else:
|
|
|
-
|
|
|
- def intToUint32(i):
|
|
|
- number = int(i)
|
|
|
- n1, n2, n3, n4 = 1, 256, 256 * 256, 256 * 256 * 256
|
|
|
- b4, number = number // n4, number % n4
|
|
|
- b3, number = number // n3, number % n3
|
|
|
- b2, number = number // n2, number % n2
|
|
|
- b1 = number
|
|
|
- return chr(b1) + chr(b2) + chr(b3) + chr(b4)
|
|
|
-
|
|
|
- def intToUint16(i):
|
|
|
- i = int(i)
|
|
|
- # divide in two parts (bytes)
|
|
|
- i1 = i % 256
|
|
|
- i2 = int(i // 256)
|
|
|
- # make string (little endian)
|
|
|
- return chr(i1) + chr(i2)
|
|
|
-
|
|
|
- def intToUint8(i):
|
|
|
- return chr(int(i))
|
|
|
+def intToUint8(i):
|
|
|
+ return int(i).to_bytes(1, "little")
|
|
|
|
|
|
|
|
|
def intToBits(i, n=None):
|
|
@@ -875,7 +852,7 @@ def _readPixels(bb, i, tagType, L1):
|
|
|
raise RuntimeError("Need Numpy to read an SWF file.")
|
|
|
|
|
|
# Get info
|
|
|
- charId = bb[i : i + 2]
|
|
|
+ # charId = bb[i : i + 2] # unused
|
|
|
i += 2
|
|
|
format = ord(bb[i : i + 1])
|
|
|
i += 1
|
|
@@ -884,7 +861,7 @@ def _readPixels(bb, i, tagType, L1):
|
|
|
height = bitsToInt(bb[i : i + 2], 16)
|
|
|
i += 2
|
|
|
|
|
|
- # If we can, get pixeldata and make nunmpy array
|
|
|
+ # If we can, get pixeldata and make numpy array
|
|
|
if format != 5:
|
|
|
print("Can only read 24bit or 32bit RGB(A) lossless images.")
|
|
|
else:
|