source: trunk/essentials/dev-lang/python/Lib/plat-mac/PixMapWrapper.py@ 3393

Last change on this file since 3393 was 3225, checked in by bird, 19 years ago

Python 2.5

File size: 7.8 KB
Line 
1"""PixMapWrapper - defines the PixMapWrapper class, which wraps an opaque
2QuickDraw PixMap data structure in a handy Python class. Also provides
3methods to convert to/from pixel data (from, e.g., the img module) or a
4Python Imaging Library Image object.
5
6J. Strout <[email protected]> February 1999"""
7
8from Carbon import Qd
9from Carbon import QuickDraw
10import struct
11import MacOS
12import img
13import imgformat
14
15# PixMap data structure element format (as used with struct)
16_pmElemFormat = {
17 'baseAddr':'l', # address of pixel data
18 'rowBytes':'H', # bytes per row, plus 0x8000
19 'bounds':'hhhh', # coordinates imposed over pixel data
20 'top':'h',
21 'left':'h',
22 'bottom':'h',
23 'right':'h',
24 'pmVersion':'h', # flags for Color QuickDraw
25 'packType':'h', # format of compression algorithm
26 'packSize':'l', # size after compression
27 'hRes':'l', # horizontal pixels per inch
28 'vRes':'l', # vertical pixels per inch
29 'pixelType':'h', # pixel format
30 'pixelSize':'h', # bits per pixel
31 'cmpCount':'h', # color components per pixel
32 'cmpSize':'h', # bits per component
33 'planeBytes':'l', # offset in bytes to next plane
34 'pmTable':'l', # handle to color table
35 'pmReserved':'l' # reserved for future use
36}
37
38# PixMap data structure element offset
39_pmElemOffset = {
40 'baseAddr':0,
41 'rowBytes':4,
42 'bounds':6,
43 'top':6,
44 'left':8,
45 'bottom':10,
46 'right':12,
47 'pmVersion':14,