~ubuntu-branches/ubuntu/saucy/python-imaging/saucy-proposed

« back to all changes in this revision

Viewing changes to PIL/SunImagePlugin.py

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-01-31 20:49:20 UTC
  • mfrom: (27.1.1 raring-proposed)
  • Revision ID: package-import@ubuntu.com-20130131204920-b5zshy6vgfvdionl
Tags: 1.1.7+1.7.8-1ubuntu1
Rewrite build dependencies to allow cross builds.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
__version__ = "0.3"
21
21
 
22
22
 
23
 
import Image, ImageFile, ImagePalette
24
 
 
25
 
 
26
 
def i16(c):
27
 
    return ord(c[1]) + (ord(c[0])<<8)
28
 
 
29
 
def i32(c):
30
 
    return ord(c[3]) + (ord(c[2])<<8) + (ord(c[1])<<16) + (ord(c[0])<<24)
 
23
from . import Image, ImageFile, ImagePalette, _binary
 
24
 
 
25
i16 = _binary.i16be
 
26
i32 = _binary.i32be
31
27
 
32
28
 
33
29
def _accept(prefix):
46
42
        # HEAD
47
43
        s = self.fp.read(32)
48
44
        if i32(s) != 0x59a66a95:
49
 
            raise SyntaxError, "not an SUN raster file"
 
45
            raise SyntaxError("not an SUN raster file")
50
46
 
51
47
        offset = 32
52
48
 
60
56
        elif depth == 24:
61
57
            self.mode, rawmode = "RGB", "BGR"
62
58
        else:
63
 
            raise SyntaxError, "unsupported mode"
 
59
            raise SyntaxError("unsupported mode")
64
60
 
65
61
        compression = i32(s[20:24])
66
62
 
71
67
            if self.mode == "L":
72
68
                self.mode = rawmode = "P"
73
69
 
74
 
        stride = (((self.size[0] * depth + 7) / 8) + 3) & (~3)
 
70
        stride = (((self.size[0] * depth + 7) // 8) + 3) & (~3)
75
71
 
76
72
        if compression == 1:
77
73
            self.tile = [("raw", (0,0)+self.size, offset, (rawmode, stride))]