mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-05 20:33:24 +03:00
Updated i16 and i32 to be in sync with _binary
This commit is contained in:
parent
cfedc8093c
commit
a662a94316
|
@ -477,23 +477,20 @@ def i16(c, o = 0):
|
||||||
"""
|
"""
|
||||||
Converts a 2-bytes (16 bits) string to an integer.
|
Converts a 2-bytes (16 bits) string to an integer.
|
||||||
|
|
||||||
:param c: string containing bytes to convert
|
c: string containing bytes to convert
|
||||||
:param o: offset of bytes to convert in string
|
o: offset of bytes to convert in string
|
||||||
"""
|
"""
|
||||||
return i8(c[o]) | (i8(c[o+1])<<8)
|
return struct.unpack("<H", c[o:o+2])[0]
|
||||||
|
|
||||||
|
|
||||||
def i32(c, o = 0):
|
def i32(c, o = 0):
|
||||||
"""
|
"""
|
||||||
Converts a 4-bytes (32 bits) string to an integer.
|
Converts a 4-bytes (32 bits) string to an integer.
|
||||||
|
|
||||||
:param c: string containing bytes to convert
|
c: string containing bytes to convert
|
||||||
:param o: offset of bytes to convert in string
|
o: offset of bytes to convert in string
|
||||||
"""
|
"""
|
||||||
## return int(ord(c[o])+(ord(c[o+1])<<8)+(ord(c[o+2])<<16)+(ord(c[o+3])<<24))
|
return struct.unpack("<I", c[o:o+4])[0]
|
||||||
## # [PL]: added int() because "<<" gives long int since Python 2.4
|
|
||||||
# copied from Pillow's _binary:
|
|
||||||
return i8(c[o]) | (i8(c[o+1])<<8) | (i8(c[o+2])<<16) | (i8(c[o+3])<<24)
|
|
||||||
|
|
||||||
|
|
||||||
def _clsid(clsid):
|
def _clsid(clsid):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user