Files
old-parkingkoncept/parkingkonceptvenv/lib/python3.7/site-packages/PIL/__pycache__/BlpImagePlugin.cpython-37.pyc

117 lines
10 KiB
Plaintext
Raw Normal View History

2019-11-17 12:44:16 +01:00
B
(U<>]<5D>7<00>@s<>dZddlZddlmZddlmZmZdZdZdZ dZ
dZ dZ dZ d d
<EFBFBD>Zd!d d <0A>Zdd<0F>Zdd<11>ZGdd<13>de<12>ZGdd<15>dej<06>ZGdd<17>dej<15>ZGdd<19>de<16>ZGdd<1B>de<16>Ze<05>ejedd<1D><00>e<05>ejd<1E>e<05>de<17>e<05>d e<18>dS)"a<>
Blizzard Mipmap Format (.blp)
Jerome Leclanche <jerome@leclan.ch>
The contents of this file are hereby released in the public domain (CC0)
Full text of the CC0 license:
https://creativecommons.org/publicdomain/zero/1.0/
BLP1 files, used mostly in Warcraft III, are not fully supported.
All types of BLP2 files used in World of Warcraft are supported.
The BLP file structure consists of a header, up to 16 mipmaps of the
texture
Texture sizes must be powers of two, though the two dimensions do
not have to be equal; 512x256 is valid, but 512x200 is not.
The first mipmap (mipmap #0) is the full size image; each subsequent
mipmap halves both dimensions. The final mipmap should be 1x1.
BLP files come in many different flavours:
* JPEG-compressed (type == 0) - only supported for BLP1.
* RAW images (type == 1, encoding == 1). Each mipmap is stored as an
array of 8-bit values, one per pixel, left to right, top to bottom.
Each value is an index to the palette.
* DXT-compressed (type == 1, encoding == 2):
- DXT1 compression is used if alpha_encoding == 0.
- An additional alpha bit is used if alpha_depth == 1.
- DXT3 compression is used if alpha_encoding == 1.
- DXT5 compression is used if alpha_encoding == 7.
<EFBFBD>N)<01>BytesIO<49>)<02>Image<67> ImageFile<6C><00><00>cCs*|d?d@d>|d?d@d>|d@d>fS)N<> <00>r<00><00>?r<00>)<01>ir r <00>6/tmp/pip-install-pc7tm5jb/Pillow/PIL/BlpImagePlugin.py<70>
unpack_5650srFc Cs<>t|<00>d}t<01>t<01>t<01>t<01>f}<03>x<>t|<02>D<00>]<5D>}|d}t<03>d||<05>\}}}t|<06>\} }
} t|<07>\} } }<0E>x`td<03>D<00>]R}<0F>xJtd<03>D<00>]<}|d@}|d?}d}|dkr<>| |
| }}}n<>|dkr<>| | |}}}n<>|dk<02>rB||k<04>rd| | d}d|
| d}d| |d}n$| | d}|
| d}| |d}nR|dk<02>r<>||k<04>r<>d| | d}d| |
d}d|| d}n d \}}}}|<01>r<>||<00>||||g<04>q<>||<00>|||g<03>q<>WqvWq,W|S)
zE
input: one "row" of data (i.e. will produce 4*width pixels)
<20>z<HHI<48>rr<00><>rr)rrrr)<07>len<65> bytearray<61>range<67>struct<63> unpack_fromr<00>extend)<16>data<74>alpha<68>blocks<6B>ret<65>block<63>idx<64>color0<72>color1<72>bits<74>r0<72>g0<67>b0<62>r1<72>g1<67>b1<62>jr<00>control<6F>a<>r<>g<>br r r<00> decode_dxt14sD 

  

  r/c Cs<>t|<00>d}t<01>t<01>t<01>t<01>f}<02>x<>t|<01>D<00>]<5D>}|d}|||d<00>}t<03>d|<03>}t<03>d|d<04>\}}t<03>d|d<06>\}t|<06>\} }
} t|<07>\} } }<0E>xFtd<07>D<00>]8}d}<10>x,td<07>D<00>]}d||d }||}|r<>d}|dL}n d
}|d M}|d 9}|d d||?d @}|dk<02>r.| |
| }}}n<>|dk<02>rJ| | |}}}nv|d k<02>r<>d | | d }d |
| d }d | |d }n:|d k<02>r<>d | | d }d | |
d }d || d }||<00>||||g<04>q<>Wq<>Wq,W|S)zE
input: one "row" of data (i.e. will produce 4*width pixels)
<20>z<8Bz<HHrz<I<> rFrT<><00>rrr)rrrrrrr)rrrrrr"r r!<00>coder#r$r%r&r'r(r)<00>highr<00>alphacode_indexr+<00>
color_coder,r-r.r r r<00> decode_dxt3ksH  




"r8c Cs<>t|<00>d}t<01>t<01>t<01>t<01>f}<02>x<>t|<01>D<00>]<5D>}|d}|||d<00>}t<03>d|<03>\}}t<03>d|d<04>}|d|dd>B|dd>B|dd >B}|d
|d d>B} t<03>d |d<06>\}
} t<03>d |d<0E>\} t|
<EFBFBD>\} }}t| <0B>\}}}<12>x<>td<07>D<00>]<5D>}<13>x<>td<07>D<00>]<5D>}dd||}|dk<01>r2| |?d@}n0|dk<02>rR| d?|d >d@B}n||d?d@}|d
k<02>rr|}nt|d k<02>r<>|}nd||k<04>r<>d|||d |d}n<|dk<02>r<>d
}n,|dk<02>r<>d}nd|||d |d}| dd||?d@}|d
k<02>r| ||}}}n<>|d k<02>r6|||}}}nv|dk<02>rrd| |d}d||d}d||d}n:|dk<02>r<>d|| d}d||d}d||d}||<00>||||g<04><00>qWq<>Wq,W|S)zG
input: one "row" of data (i.e. will produce 4 * width pixels)
r0z<BBz<6Brrrrr <00>rrz<HHz<Ir1rr2<00>r)rrrrrrr)rrrrrZa0Za1r"Z
alphacode1Z
alphacode2r r!r4r#r$r%r&r'r(r)rr6Z alphacoder+r7r,r-r.r r r<00> decode_dxt5<74>s^ ,










$r;c@s eZdZdS)<02>BLPFormatErrorN)<03>__name__<5F>
__module__<EFBFBD> __qualname__r r r rr<<00>sr<c@s(eZdZdZdZdZdd<05>Zdd<07>ZdS) <09> BlpImageFilez
Blizzard Mipmap Format
ZBLPzBlizzard Mipmap FormatcCs||j<00>d<01>|_|<00><03>|jdkr,d}d|_n.|jdkrLd}|jrDdnd|_ntd|j<00><01>|d |jd
|jd
d ffg|_dS) NrsBLP1<50>BLP1ZRGBsBLP2<50>BLP2ZRGBAzBad BLP magic %r)rrrr) <09>fp<66>read<61>magic<69>_read_blp_header<65>mode<64>_blp_alpha_depthr<<00>size<7A>tile)<02>self<6C>decoderr r r<00>_open<65>s

zBlpImageFile._opencCs<>t<00>d|j<02>d<02><01>\|_t<00>d|j<02>d<04><01>\|_t<00>d|j<02>d<04><01>\|_t<00>d|j<02>d<04><01>\|_t<00>d|j<02>d<04><01>\|_t<00>d|j<02>d<06><01>|_ |j
dkr<>t<00>d|j<02>d<02><01>\|_t<00>d|j<02>d<02><01>\|_ t<00>d|j<02>d <09><01>|_ t<00>d|j<02>d <09><01>|_ dS)
Nz<irz<brz<IIrsBLP1z<16I<36>@)r<00>unpackrCrD<00>_blp_compression<6F> _blp_encodingrH<00>_blp_alpha_encoding<6E> _blp_mips<70>_sizerE<00> _blp_subtype<70> _blp_offsets<74> _blp_lengths)rKr r rrFs
zBlpImageFile._read_blp_headerN)r=r>r?<00>__doc__<5F>format<61>format_descriptionrMrFr r r rr@<00>s
r@c@s(eZdZdZdd<03>Zdd<05>Zdd<07>ZdS) <09>_BLPBaseDecoderTcCsRy.|j<00>d<01>|j<00>d<02>|_|<00><04>|<00><05>Wntjk
rLtd<03><01>YnXdS)NrrzTruncated Blp file)rr) <09>fd<66>seekrDrErF<00>_loadr<00>error<6F>IOError)rK<00>bufferr r r<00>decodes  z_BLPBaseDecoder.decodec Csfg}x\td<01>D]P}y t<01>d|j<03>d<03><01>\}}}}Wntjk
rJPYnX|<01>||||f<04>qW|S)N<>z<4Br)rrrOr\rDr_<00>append)rKrrr.r-r,r+r r r<00> _read_palette!s z_BLPBaseDecoder._read_palettecCs<>t<00>d|j<02>d<02><01>\|_t<00>d|j<02>d<04><01>\|_t<00>d|j<02>d<04><01>\|_t<00>d|j<02>d<04><01>\|_t<00>d|j<02>d<04><01>\|_t<00>d|j<02>d<06><01>|_ |j
dkr<>t<00>d|j<02>d<02><01>\|_t<00>d|j<02>d<02><01>\|_ t<00>d|j<02>d <09><01>|_ t<00>d|j<02>d <09><01>|_ dS)
Nz<irz<brz<IIrsBLP1z<16IrN)rrOr\rDrPrQrHrRrSrIrErUrVrW)rKr r rrF+s
z _BLPBaseDecoder._read_blp_headerN)r=r>r?Z _pulls_fdrbrerFr r r rr[s

r[c@seZdZdd<02>Zdd<04>ZdS)<06> BLP1Decoderc Cs<>|jtkr|<00><02>n<>|jdkr<>|jdkr<>t<04>}|<00><05>}t|j<07>|j d<00><01>}xVyt
<EFBFBD> d|<03>d<01><01>\}Wnt
j k
r~PYnX||\}}}}|<01> |||g<03>qNW|<00>t|<01><01>q<>td|j<00><01>ntd|j<00><01>dS)Nr)rr rz<BzUnsupported BLP encoding %rzUnsupported BLP compression %r)rP<00>BLP_FORMAT_JPEG<45>_decode_jpeg_streamrQrrerr\rDrWrrOr_r<00>
set_as_raw<EFBFBD>bytesr<) rKr<00>palette<74>_data<74>offsetr.r-r,r+r r rr^?s&



zBLP1Decoder._loadcCs<>ddlm}t<02>d|j<04>d<04><01>\}|j<04>|<02>}|j<04>|jd|j<04><07><00>|j<04>|jd<00>}||}t |<04>}||<04>}|j
|_
|j |_|j |_ dS)Nr)<01> JpegImageFilez<Ir) ZPIL.JpegImagePluginrnrrOr\rDrV<00>tellrWrrJrCrG)rKrnZjpeg_header_sizeZ jpeg_headerr<00>imager r rrhZs  zBLP1Decoder._decode_jpeg_streamN)r=r>r?r^rhr r r rrf>srfc@seZdZdd<02>ZdS)<04> BLP2Decoderc Cs:|<00><00>}t<01>}|j<02>|jd<00>|jdk<02>r|jtkr<>t|j<02> |j
d<00><01>}xVyt <0B> d|<03> d<02><01>\}Wnt j k
r~PYnX||\}}}}|<02>|||f<03>qNW<00>q(|jtk<02>r
|jtk<02>r&|jdddd} xLt|jddd<00>D]2}
x,t|j<02> | <09>t|j<16>d<07>D]} || 7}<02>qWq<>Wn<>|jtk<02>r<>|jdddd} x<>t|jddd<00>D]*}
x"t|j<02> | <09><01>D]} || 7}<02>qvW<00>q`Wnx|jtk<02>r<>|jdddd} xTt|jddd<00>D]*}
x"t|j<02> | <09><01>D]} || 7}<02>q<>W<00>q<>Wntd |j<00><01>ntd
|j<00><01>ntd |j<00><01>|<00>t|<02><01>dS) Nrrz<Brrr)rr0zUnsupported alpha encoding %rzUnknown BLP encoding %rzUnknown BLP compression %r)rerr\r]rVrPrQ<00>BLP_ENCODING_UNCOMPRESSEDrrDrWrrOr_r<00>BLP_ENCODING_DXTrR<00>BLP_ALPHA_ENCODING_DXT1rIrr/<00>boolrH<00>BLP_ALPHA_ENCODING_DXT3r8<00>BLP_ALPHA_ENCODING_DXT5r;r<rirj) rKrkrrlrmr.r-r,r+ZlinesizeZyb<79>dr r rr^jsF 
    zBLP2Decoder._loadN)r=r>r?r^r r r rrqisrqcCs|dd<01>dkS)Nr)sBLP1sBLP2r )<01>pr r r<00><lambda><3E><00>rzz.blprArB)F)rXr<00>ior<00>rrrgrrrsZ"BLP_ENCODING_UNCOMPRESSED_RAW_BGRArtrvrwrr/r8r;<00>NotImplementedErrorr<r@Z PyDecoderr[rfrqZ register_openrYZregister_extensionZregister_decoderr r r r<00><module>s0 
75F**+5