home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
pypil112.zip
/
PIL-1.1.2.zip
/
Lib
/
site-packages
/
PIL
/
SunImagePlugin.pyc
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2001-12-25
|
3KB
|
63 lines
# Source Generated with Decompyle++
# File: in.pyc (Python 2.2)
__version__ = '0.2'
import string
import Image
import ImageFile
import ImagePalette
def i16(c):
return ord(c[1]) + (ord(c[0]) << 8)
def i32(c):
return ord(c[3]) + (ord(c[2]) << 8) + (ord(c[1]) << 16) + (ord(c[0]) << 24)
def _accept(prefix):
return i32(prefix) == 1504078485
class SunImageFile(ImageFile.ImageFile):
format = 'SUN'
format_description = 'Sun Raster File'
def _open(self):
s = self.fp.read(32)
if i32(s) != 1504078485:
raise SyntaxError, 'not an SUN raster file'
offset = 32
self.size = (i32(s[4:8]), i32(s[8:12]))
depth = i32(s[12:16])
if depth == 1:
(self.mode, rawmode) = ('1', '1;I')
elif depth == 8:
self.mode = rawmode = 'L'
elif depth == 24:
(self.mode, rawmode) = ('RGB', 'BGR')
else:
raise SyntaxError, 'unsupported mode'
compression = i32(s[20:24])
if i32(s[24:28]) != 0:
length = i32(s[28:32])
offset = offset + length
self.palette = ImagePalette.raw('RGB;L', self.fp.read(length))
if self.mode == 'L':
self.mode = 'P'
stride = (self.size[0] * depth + 7) / 8 + 3 & -4
if compression == 1:
self.tile = [
('raw', (0, 0) + self.size, offset, (rawmode, stride))]
elif compression == 2:
self.tile = [
('sun_rle', (0, 0) + self.size, offset, rawmode)]
Image.register_open('SUN', SunImageFile, _accept)
Image.register_extension('SUN', '.ras')