Skip to content

Commit

Permalink
Revert changes from PR python-pillow#1121, for python-pillow#1163
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Apr 2, 2015
1 parent aeb1e61 commit 4bcedc8
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions PIL/_binary.py
Expand Up @@ -11,8 +11,6 @@
# See the README file for information on usage and redistribution.
#

from struct import unpack, pack

if bytes is str:
def i8(c):
return ord(c)
Expand All @@ -36,7 +34,7 @@ def i16le(c, o=0):
c: string containing bytes to convert
o: offset of bytes to convert in string
"""
return unpack("<H", c[o:o+2])
return i8(c[o]) | (i8(c[o+1]) << 8)


def i32le(c, o=0):
Expand All @@ -46,31 +44,33 @@ def i32le(c, o=0):
c: string containing bytes to convert
o: offset of bytes to convert in string
"""
return unpack("<I", c[o:o+4])
return (i8(c[o]) | (i8(c[o+1]) << 8) | (i8(c[o+2]) << 16) |
(i8(c[o+3]) << 24))


def i16be(c, o=0):
return unpack(">H", c[o:o+2])
return (i8(c[o]) << 8) | i8(c[o+1])


def i32be(c, o=0):
return unpack(">I", c[o:o+4])
return ((i8(c[o]) << 24) | (i8(c[o+1]) << 16) |
(i8(c[o+2]) << 8) | i8(c[o+3]))


# Output, le = little endian, be = big endian
def o16le(i):
return pack("<H", i)
return o8(i) + o8(i >> 8)


def o32le(i):
return pack("<I", i)
return o8(i) + o8(i >> 8) + o8(i >> 16) + o8(i >> 24)


def o16be(i):
return pack(">H", i)
return o8(i >> 8) + o8(i)


def o32be(i):
return pack(">I", i)
return o8(i >> 24) + o8(i >> 16) + o8(i >> 8) + o8(i)

# End of file

0 comments on commit 4bcedc8

Please sign in to comment.