tzh
2024-08-22 c7d0944258c7d0943aa7b2211498fd612971ce27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
]\¬Qc@s¬dZddlmZedddƒddlmZddlmZddlZddlZddlZddl    Z    id    d
6d d 6d d6dd6dd6dd6dd6dd6dd6d    d6d    d6d    d6dd6dd6dd6dd6d    d6d    d6d    d6Z
id d
6d!d 6d"d6d"d6d#d6d$d6d%d6d&d6d'd6d(d6d)d6d*d6d+d6d,d6d-d6d.d6d/d6d0d6d1d6Z d2d5d3„ƒYZ d4„Z dS(6s&PixMapWrapper - defines the PixMapWrapper class, which wraps an opaque
QuickDraw PixMap data structure in a handy Python class.  Also provides
methods to convert to/from pixel data (from, e.g., the img module) or a
Python Imaging Library Image object.
 
J. Strout <joe@strout.net>  February 1999iÿÿÿÿ(twarnpy3ks,In 3.x, the PixMapWrapper module is removed.t
stackleveli(tQd(t    QuickDrawNtltbaseAddrtHtrowBytesthhhhtboundsthttoptlefttbottomtrightt    pmVersiontpackTypetpackSizethRestvRest    pixelTypet    pixelSizetcmpCounttcmpSizet
planeBytestpmTablet
pmReservediiiii
i iiiiiii i"i$i&i*i.t PixMapWrappercBsŒeZdZd„Zd„Zd„Zd„Zd„Zd„Zddd d d d„Z
e j d    „Z e j d
„Zd „Zd „ZRS(sµPixMapWrapper -- wraps the QD PixMap object in a Python class,
    with methods to easily get/set various pixmap fields.  Note: Use the
    PixMap() method when passing to QD calls.cCs…d|jd<tjdt|jƒtjddddddddd
d tjddddddƒ|_    t
j |j    ƒ|jd    <dS( NttdatatlhhhhhhhlllhhhhllliiHiiit_pmiHiH( t__dict__tstructtpacktidRtMacOStstring_id_to_bufferRt    RGBDirectt_headerRt    RawBitMap(tself((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/PixMapWrapper.pyt__init__Fs      cCs]t|}t|}|j| tj||ƒ|j|tj|ƒ|_d|jd<dS(NR(t _pmElemOffsett _pmElemFormatR'R!R"tcalcsizetNoneR (R)telementtbytestoffsettfmt((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/PixMapWrapper.pyt_stuffUs
 
8cCs?t|}t|}tj||j||tj|ƒ!ƒdS(Ni(R+R,R!tunpackR'R-(R)R/R1R2((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/PixMapWrapper.pyt_unstuff]s
 
cCsA|dkrdd‚n%|dkrT||jd<|jdt|jƒtjƒné|dkrw|jd|dBƒnÆ|dkrÖ|jd|d    ƒ|jd
|d ƒ|jd |d ƒ|jd|dƒng|dksî|dkr |j|t|ƒd>ƒn2|tjƒkr0|j||ƒn ||j|<dS(NRtUseErrs4don't assign to .baseAddr -- assign to .data insteadRRi€R    R iR iRiR iRRi(    R R3R#RR$R%tintR,tkeys(R)tattrtval((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/PixMapWrapper.pyt __setattr__bs"    #  cCs´|dkr|jdƒd@S|dkr]|jdƒ|jdƒ|jdƒ|jdƒfS|dksu|d    kr†|j|ƒd
?S|tjƒkr¥|j|ƒS|j|SdS( NRiÿR    R R RR RRi(R5R,R8R (R)R9((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/PixMapWrapper.pyt __getattr__zs      cCs4|jds)tj|jƒ|jd<n|jdS(s5Return a QuickDraw PixMap corresponding to this data.R(R RR(R'(R)((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/PixMapWrapper.pytPixMaps icCs·|j}||||g}|dkrD||d|d|d<n|dkrm||d|d|d<n|s‚tjƒ}ntj|jƒ|jƒ|t|ƒtj    dƒdS(s;Draw this pixmap into the given (default current) grafport.iiiiN(
R    R.RtGetPorttCopyBitsR=tGetPortBitMapForCopyBitsttupleRtsrcCopy(R)tx1ty1tx2ty2tporttsrctdest((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/PixMapWrapper.pytblit•s      $cCs«|tjkr*|tjkr*dd‚n||_dd||f|_d|_tj|_|tjkrd|_    d|_
nd|_    d|_
||j    d|_ d    S(
swStuff this pixmap with raw pixel data from a string.
        Supply width, height, and one of the imgformat specifiers.tNotImplementedErrors conversion to macrgb or macrgb16iii iiiN( t    imgformattmacrgbtmacrgb16RR    RRR&RRRR(R)tstwidththeighttformat((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/PixMapWrapper.pyt
fromstring¡s                       cCsS|tjkr|jdks<|tjkrO|jdkrO|jSdd‚ndS(s4Return raw data as a string in the specified format.i iRKsdata format conversionN(RLRMRRNt    pixelsizeR(R)RR((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/PixMapWrapper.pyttostringµscCs\|jdkr!|jdƒ}ntdƒ|jƒ}|j||jd|jdƒdS(s/Initialize this PixMap from a PIL Image object.tRGBAiiN(tmodetconverttchrRURStsize(R)timR((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/PixMapWrapper.pyt    fromImage¿scCs`ddl}|jƒdtdƒ}|j}|jd|d|d|d|df|ƒS(s9Return the contents of this PixMap as a PIL Image object.iÿÿÿÿNiiRVii(tImageRURYR    RS(R)R]RR    ((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/PixMapWrapper.pyttoImageÈs     N(t__name__t
__module__t__doc__R*R3R5R;R<R=R.RJRLRMRSRUR\R^(((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/PixMapWrapper.pyRAs                         
       cCspddl}ddl}ddl}|jdƒ}|s=dStƒ}|j|j|ƒƒ|jddƒ|S(Niÿÿÿÿs Image File:i(R$t EasyDialogsR]tAskFileForOpenRR\topenRJ(R$RbR]tpathtpm((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/PixMapWrapper.pyttestÑs       ((RatwarningsRtCarbonRRR!R$timgRLR,R+RRg(((s^/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/plat-mac/PixMapWrapper.pyt<module>sd    
 
