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
/
GbrImagePlugin.pyc
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2001-12-25
|
2KB
|
51 lines
# Source Generated with Decompyle++
# File: in.pyc (Python 2.2)
import Image
import ImageFile
def i32(c):
return ord(c[3]) + (ord(c[2]) << 8) + (ord(c[1]) << 16) + (ord(c[0]) << 24)
def _accept(prefix):
if i32(prefix) >= 20:
pass
return i32(prefix[4:8]) == 1
class GbrImageFile(ImageFile.ImageFile):
format = 'GBR'
format_description = 'GIMP brush file'
def _open(self):
header_size = i32(self.fp.read(4))
version = i32(self.fp.read(4))
if header_size < 20 or version != 1:
raise SyntaxError, 'not a GIMP brush'
width = i32(self.fp.read(4))
height = i32(self.fp.read(4))
bytes = i32(self.fp.read(4))
if width <= 0 and height <= 0 or bytes != 1:
raise SyntaxError, 'not a GIMP brush'
comment = self.fp.read(header_size - 20)[:-1]
self.mode = 'L'
self.size = (width, height)
self.info['comment'] = comment
self.data = self.fp.read(width * height)
def load(self):
if not (self.data):
return None
self.im = Image.core.new(self.mode, self.size)
self.im.fromstring(self.data)
self.data = ''
Image.register_open('GBR', GbrImageFile, _accept)
Image.register_extension('GBR', '.gbr')