Files
old-saburly-wagtail-web/env/lib/python3.10/site-packages/PIL/__pycache__/BlpImagePlugin.cpython-310.pyc

139 lines
13 KiB
Plaintext
Raw Normal View History

2024-08-27 20:33:44 +02:00
o
<00><><EFBFBD>f<EFBFBD>?<00>@s<>dZddlmZddlZddlZddlZddlmZddlm Z ddl
m Z ddl m Z mZGd d
<EFBFBD>d
e<07>ZGd d <0C>d e<07>ZGd d<0E>de<07>Zd=dd<14>Z d>d?dd<1C>Zd@dd<1E>Zd@dd <20>ZGd!d"<22>d"e<16>ZdAd$d%<25>ZGd&d'<27>d'ej<0E>ZGd(d)<29>d)ej<1A>ZGd*d+<2B>d+e<1B>ZGd,d-<2D>d-e<1B>ZGd.d/<2F>d/ej<1E>ZdBd7d8<64>Z e <0A>!ej"ee<18>e <0A>#ej"d9<64>e <0A>$d:e<1C>e <0A>$d;e<1D>e <0A>%ej"e <20>e <0A>&d<e<1F>dS)Ca<43>
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>)<01> annotationsN)<01>IntEnum)<01>BytesIO)<01>IO<49>)<02>Image<67> ImageFilec@seZdZdZdS)<03>FormatrN)<04>__name__<5F>
__module__<EFBFBD> __qualname__<5F>JPEG<45>rr<00>T/home/amir/Desktop/saburlyweb/env/lib/python3.10/site-packages/PIL/BlpImagePlugin.pyr ,sr c@<01>eZdZdZdZdZdS)<05>Encodingr<00><00>N)r
r r <00> UNCOMPRESSED<45>DXT<58>UNCOMPRESSED_RAW_BGRArrrrr0<00>rc@r)<05> AlphaEncodingrr<00>N)r
r r <00>DXT1<54>DXT3<54>DXT5rrrrr6rr<00>i<>int<6E>return<72>tuple[int, int, int]cCs*|d?d@d>|d?d@d>|d@d>fS)N<> <00>r<00><00>?rr)rrrr<00>
unpack_565<s*r%F<>data<74>bytes<65>alpha<68>bool<6F>1tuple[bytearray, bytearray, bytearray, bytearray]c Cs<>t|<00>d}t<01>t<01>t<01>t<01>f}t|<02>D]<5D>}|d}t<03>d||<05>\}}}t|<06>\} }
} t|<07>\} } }td<03>D]<5D>}td<03>D]<5D>}|d@}|d?}d}|dkrU| |
| }}}nh|dkrb| | |}}}n[|dkr<>||kr<>d| | d}d|
| d}d| |d}n:| | d}|
| d}| |d}n'|dkr<>||kr<>d| | d}d| |
d}d|| d}nd \}}}}|r<>||<00>||||g<04>q<||<00>|||g<03>q<q6q|S)
<EFBFBD>E
input: one "row" of data (i.e. will produce 4*width pixels)
<20>z<HHI<48>rr<00><>rr)rrrr<00><07>len<65> bytearray<61>range<67>struct<63> unpack_fromr%<00>extend)r&r(<00>blocks<6B>ret<65> block_index<65>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<>brrr<00> decode_dxt1@sH       <02><02>"rIc Cs<>t|<00>d}t<01>t<01>t<01>t<01>f}t|<01>D]<5D>}|d}|||d<00>}t<03>d|<05>}t<03>d|d<04>\}}t<03>d|d<06>\} t|<07>\}
} } t|<08>\} }}td<07>D]<5D>}d}td<07>D]<5D>}d||d }||}|rjd}|dL}nd
}|d M}|d 9}| d d||?d @}|dkr<>|
| | }}}nF|dkr<>| ||}}}n9|d kr<>d |
| d }d | |d }d | |d }n|d kr<>d | |
d }d || d }d || d }||<00>||||g<04>qSqKq|S)r+<00>z<8B<38><HHr,<00><I<> r-FrT<><00>rrrr/)r&r6r7r8r9<00>blockr<r:r;<00>coder=r>r?r@rArBrC<00>highr<00>alphacode_indexrE<00>
color_coderFrGrHrrr<00> decode_dxt3ysL     
<02><02>rUc Cs<>t|<00>d}t<01>t<01>t<01>t<01>f}t|<01>D<00>]>}|d}|||d<00>}t<03>d|<05>\}}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| <0B>\}}}t| <0C>\}}}td<07>D]<5D>}td<07>D]<5D>}dd||}|dkr<>|
|?d@}n|dkr<>|
d?| d >d@B}n| |d?d@}|d
kr<>|}n6|d kr<>|}n/||kr<>d|||d |d}n|dkr<>d
}n|dkr<>d}nd|||d |d}| dd||?d@}|d
kr<>|||}}}nI|d k<02>r |||}}}n;|dk<02>r)d||d}d||d}d||d}n|dk<02>rFd||d}d||d}d||d}||<00>||||g<04>q{quq|S)zG
input: one "row" of data (i.e. will produce 4 * width pixels)
rJz<BBz<6Brrr,r-r#<00>rrrKrLrMrrN<00>r.r/)r&r6r7r8r9rP<00>a0<61>a1r<<00>
alphacode1<EFBFBD>
alphacode2r:r;rQr=r>r?r@rArBrCrrS<00> alphacoderErTrFrGrHrrr<00> decode_dxt5<74>sb ,  


<02><02>*r]c@s eZdZdS)<02>BLPFormatErrorN)r
r r rrrrr^<00>sr^<00>prefixcCs|dd<01>dvS)Nr-<00><02>BLP1<50>BLP2r)r_rrr<00>_accept<70>srcc@s"eZdZdZdZdZd dd<07>ZdS)
<EFBFBD> BlpImageFilez
Blizzard Mipmap Format
<20>BLPzBlizzard Mipmap Formatr<00>NonecCs<>|j<00>d<01>|_|j<00>dtj<05>t<06>d|j<00>d<04><01>\|_|j<00>dtj<05>t<06>d|j<00>d<07><01>|_ |jdvr9|j<02>
<EFBFBD>}n d t |j<02><01><00>}t |<02><01>|jrJd
nd |_ |d |jd |jd dffg|_dS)Nr-r#<00><brr<00><IIr,r`zBad BLP magic <20>RGBA<42>RGB<47>rrr)<11>fp<66>read<61>magic<69>seek<65>os<6F>SEEK_CURr3<00>unpack<63>_blp_alpha_depth<74>_size<7A>decode<64>reprr^<00>_mode<64>size<7A>mode<64>tile)<03>self<6C>decoder<65>msgrrr<00>_opens
 "zBlpImageFile._openN<6E>rrf)r
r r <00>__doc__<5F>format<61>format_descriptionr~rrrrrd<00>s
rdc@sReZdZdZddd<07>Zejdd d
<EFBFBD><04>Zdd d <0C>Zddd<10>Z ddd<13>Z
ddd<17>Z dS)<1E>_BLPBaseDecoderT<72>bufferr'r<00>tuple[int, int]c
Cs@z |<00><00>|<00><01>WdStjy}zd}t|<03>|<02>d}~ww)NzTruncated BLP file)<02><><EFBFBD><EFBFBD><EFBFBD>r)<05>_read_blp_header<65>_loadr3<00>error<6F>OSError)r{r<><00>er}rrrrus
<10>
<08><02>z_BLPBaseDecoder.decoderfcCsdS<00>Nr<00>r{rrrr<>#sz_BLPBaseDecoder._loadcCs<>|jdusJ<00>|j<00>d<01>t<02>d|<00>d<01><01>\|_t<02>d|<00>d<04><01>\|_t<02>d|<00>d<04><01>\|_t<02>d|<00>d<04><01>\|_|j<00>dt j
<EFBFBD>t<02>d|<00>d<06><01>|_ t |t <0A>rct<02>d|<00>d<01><01>\|_|j<00>dt j
<EFBFBD>t<02>d|<00>d<08><01>|_t<02>d|<00>d<08><01>|_dS) Nr-<00><irgrrhr,<00><16I<36>@)<10>fdror3rr<00>
_safe_read<EFBFBD>_blp_compression<6F> _blp_encodingrs<00>_blp_alpha_encodingrprqrx<00>
isinstance<EFBFBD> BLP1Decoder<65> _blp_offsets<74> _blp_lengthsr<73>rrrr<>'s 
z _BLPBaseDecoder._read_blp_header<65>lengthrcCst<00>|j|<01>Sr<>)rr<>r<>)r{r<>rrrr<>;sz_BLPBaseDecoder._safe_read<61>list[tuple[int, int, int, int]]c Cs`g}td<01>D]'}zt<01>d|<00>d<03><01>\}}}}Wn tjy#Y|Sw|<01>||||f<04>q|S)N<><00><4Br-)r2r3rrr<>r<><00>append)r{r7rrHrGrFrErrr<00> _read_palette>s <02>z_BLPBaseDecoder._read_palette<74>paletter1c
Cs<>t<00>}t|<00>|jd<00><01>} z t<04>d|<03>d<04><01>\}Wn tjy%Y|Sw||\}}}}|||f} |jr;| |f7} |<02> | <09>q)NrT<><Br)
r1rr<>r<>r3rrrmr<>rsr5)
r{r<>r&<00>_data<74>offsetrHrGrFrE<00>drrr<00>
_read_bgraHs<02>


<02>z_BLPBaseDecoder._read_bgraN)r<>r'rr<>r)r<>rrr')rr<>)r<>r<>rr1) r
r r <00> _pulls_fdru<00>abc<62>abstractmethodr<64>r<>r<>r<>r<>rrrrr<>s
 



r<EFBFBD>c@s eZdZddd<04>Zddd<06>ZdS) r<>rrfcCs||jtjkr |<00><03>dS|jdkr2|jdvr&|<00><05>}|<00>|<01>}|<00>|<02>dSdt|j<04><01><00>}t |<03><01>dt|j<04><01><00>}t |<03><01>)Nr)r-r#zUnsupported BLP encoding zUnsupported BLP compression )
r<EFBFBD>r r <00>_decode_jpeg_streamr<6D>r<>r<><00>
set_as_rawrvr^)r{r<>r&r}rrrr<>Ys  


zBLP1Decoder._loadcCs<>ddlm}t<02>d|<00>d<04><01>\}|<00>|<02>}|jdusJ<00>|<00>|jd|j<05><07><00>|<00>|jd<00>}||}|t |<04><01>}t
<EFBFBD> |j <0C>|j dkr[|jd\}}}} |||| ddffg|_|<05>d<07><01><10>\}
} } t
<EFBFBD>d| | |
f<03>} |<00>| <0A><13><00>dS)Nr)<01> JpegImageFilerLr-r<00>CMYKrj)<14>JpegImagePluginr<6E>r3rrr<>r<>r<><00>tellr<6C>rr<00>_decompression_bomb_checkrxryrz<00>convert<72>split<69>merger<65><00>tobytes)r{r<><00>jpeg_header_size<7A> jpeg_headerr&<00>image<67> decoder_name<6D>extentsr<73><00>argsrFrGrH<00>reversed_imagerrrr<>is 
  
zBLP1Decoder._decode_jpeg_streamNr)r
r r r<>r<>rrrrr<>Xs
r<>c@seZdZddd<04>ZdS)<07> BLP2DecoderrrfcCs<>|<00><00>}|jdus J<00>|j<01>|jd<00>|jdkr<>|jtjkr%|<00>|<01>}n<>|jtj kr<>t
<EFBFBD>}|j t j kra|jdddd}t|jddd<00>D]}t|<00>|<03>t|j<13>d<06>D]}||7}qXqJn<4A>|j t jkr<>|jdddd}t|jddd<00>D]}t|<00>|<03><01>D]}||7}q<>q}nR|j t jkr<>|jdddd}t|jddd<00>D]}t|<00>|<03><01>D]}||7}q<>q<EFBFBD>n$dt|j <0B><01><00>}t|<06><01>d t|j<05><01><00>}t|<06><01>d
t|j<04><01><00>}t|<06><01>|<00>|<02>dS) Nrrrr-r,)r(rJzUnsupported alpha encoding zUnknown BLP encoding zUnknown BLP compression )r<>r<>ror<>r<>r<>rrr<>rr1r<>rrrxr2rIr<>r)rsrrUrr]rvr^r<>)r{r<>r&<00>linesize<7A>ybr<62>r}rrrr<>}sL
    
<EFBFBD>
<02><02> 
<02><02> 
<02><02>zBLP2Decoder._loadNr)r
r r r<>rrrrr<>|sr<>c@s$eZdZdZd dd<05>Zd d d
<EFBFBD>Zd S)<0E>
BLPEncoderTrr'c Cs<>d}|jdus J<00>|j<00>dd<02>}tt|<02>d<00>D]}||d|dd<00>\}}}}|t<04>d||||<07>7}qt|<01>dkrF|d7}t|<01>dks<|S)N<>rir-rr<>is)<06>im<69>
getpaletter2r0r3<00>pack)r{r&r<>rrFrGrHrErrr<00>_write_palette<74>s   <0C>zBLPEncoder._write_palette<74>bufsizer<00>tuple[int, int, bytes]c
Cs<>|<00><00>}dt|<02>}tjd|gd<03>R<00>}|jdusJ<00>|jj\}}|tjd||gd<03>R<00>7}||7}t|<06>D]}t|<05>D]}|t<02>d|j<04>||f<02><01>7}q=q7t|<04>d|fS)N<><4E>r<>)rrrrrrrrrrrrrrrr<>r)r<>r0r3r<>r<>rxr2<00>getpixel) r{r<><00> palette_datar<61>r&<00>w<>h<>y<>xrrr<00>encode<64>s    <02>zBLPEncoder.encodeN)rr')r<>rrr<>)r
r r <00>
_pushes_fdr<EFBFBD>r<>rrrrr<><00>s
 r<>r<><00> Image.Imagerl<00> IO[bytes]<5D>filename<6D> str | bytesrfcCs|jdkr d}t|<03><01>|j<02>d<03>dkrdnd}|<01>|<04>|<01>t<05>dd<08><02>|<01>t<05>d tj<08><02>|<01>t<05>d |j jd
kr<dnd <0B><02>|<01>t<05>d d <0B><02>|<01>t<05>d d <0B><02>|<01>tjd g|j
<EFBFBD>R<00><00>|dkru|<01>t<05>dd <0A><02>|<01>t<05>dd <0B><02>t <0B> ||dd|j
d |jfg<01>dS)N<>PzUnsupported BLP image mode<64> blp_version<6F>BLP1rarbr<>rrgrirrhr#rerk) ry<00>
ValueError<EFBFBD> encoderinfo<66>get<65>writer3r<>rrr<>rxr<00>_save)r<>rlr<>r}rnrrrr<><00>s

"$r<>z.blpr<70><00>BLP2re)rrrr )F)r&r'r(r)rr*)r&r'rr*)r_r'rr))r<>r<>rlr<>r<>r<>rrf)'r<><00>
__future__rr<>rpr3<00>enumr<00>ior<00>typingr<00>rrr rrr%rIrUr]<00>NotImplementedErrorr^rcrd<00> PyDecoderr<72>r<>r<><00> PyEncoderr<72>r<><00> register_openr<6E><00>register_extension<6F>register_decoder<65> register_save<76>register_encoderrrrr<00><module>s>    
 <0C>
9
5F
A$0
!