Files
serveur-d-authentification/venv/lib/python3.10/site-packages/PIL/__pycache__/BlpImagePlugin.cpython-310.pyc

147 lines
13 KiB
Plaintext
Raw Normal View History

o
<00>Q<EFBFBD>j<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)ejej<1B>ZGd*d+<2B>d+e<1C>ZGd,d-<2D>d-e<1C>ZGd.d/<2F>d/ej<1F>Z dBd7d8<64>Z!e <0A>"ej#ee<18>e <0A>$ej#d9<64>e <0A>%d:e<1D>e <0A>%d;e<1E>e <0A>&ej#e!<21>e <0A>'d<e <20>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>u/home/sorel/systeme_gestion_cerfig/serveur-d-authentification/venv/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
|<00>d<01>S)N)<02>BLP1<50>BLP2)<01>
startswith)r_rrr<00>_accept<70>s
rcc@s"eZdZdZdZdZd dd<07>ZdS)
<EFBFBD> BlpImageFilez
Blizzard Mipmap Format
<20>BLPzBlizzard Mipmap Formatr<00>Nonec Csx|jdusJ<00>|j<00>d<01>|_t|j<02>sdt|j<02><01><00>}t|<01><01>t<06>d|j<00>d<01><01>d}|jdkr?t<06>d|j<00>d<01><01>ddk}n.t<06>d|j<00>d<08><01>d}t<06>d|j<00>d<08><01>ddk}t<06>d|j<00>d<08><01>d}|j<00>dt j
<EFBFBD>t<06>d |j<00>d
<EFBFBD><01>|_ |jdkr<>t<06>d|j<00>d<01><01>d}|j<00>dt j
<EFBFBD>|||f}d }n||||f}d }|j<02> <0C>}|r<>d nd|_ t<0E>|d|j||<06>g|_dS)Nr-zBad BLP magic <20><irr`rL<00><br<00><IIr,<00><00><00>RGBA<42>RGB<47>rr)<12>fp<66>read<61>magicrc<00>reprr^r3<00>unpack<63>seek<65>os<6F>SEEK_CUR<55>_size<7A>decode<64>_moder<00>_Tile<6C>size<7A>tile) <09>self<6C>msg<73> compressionr(<00>encoding<6E>alpha_encoding<6E>args<67>offset<65>decoderrrr<00>_opens.



 
zBlpImageFile._openN<6E>rrf)r
r r <00>__doc__<5F>format<61>format_descriptionr<6E>rrrrrd<00>s
rdc@sReZdZdZddd<07>Zejdd d
<EFBFBD><04>Zdd d <0C>Zddd<11>Z ddd<14>Z
d dd<1A>Z dS)!<21>_BLPBaseDecoderT<72>buffer<65>$bytes | Image.SupportsArrayInterfacer<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_header<65>_loadr3<00>error<6F>OSError)r}r<><00>er~rrrrx*s
<10>
<08><02>z_BLPBaseDecoder.decoderfcCsdS<00>Nr<00>r}rrrr<>3sz_BLPBaseDecoder._loadcCs,t<00>d|<00>d<02><01>|_t<00>d|<00>d<02><01>|_dS)N<><16I<36>@)r3rs<00>
_safe_read<EFBFBD>_offsets<74>_lengthsr<73>rrrr<>7sz_BLPBaseDecoder._read_header<65>lengthrr'cCs|jdusJ<00>t<01>|j|<01>Sr<>)<03>fdrr<>)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-)r2r3rsr<>r<><00>append)r}r7rrHrGrFrErrr<00> _read_palette?s <02>z_BLPBaseDecoder._read_palette<74>paletter(r)r1c Cs<>t<00>}t|<00>|jd<00><01>} z t<04>d|<04>d<04><01>\}Wn tjy%Y|Sw||\}}}} |||f}
|r:|
| f7}
|<03>|
<EFBFBD>q)NrT<><Br) r1rr<>r<>r3rsrpr<>r5) r}r<>r(r&<00>_datar<61>rHrGrFrE<00>drrr<00>
_read_bgraIs<02>


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



r<EFBFBD>c@s eZdZddd<04>Zddd<06>ZdS) <09> BLP1DecoderrrfcCs<>|j\|_|_}|jtjkr|<00><05>dS|jdkr;|jdvr/|<00><06>}|<00>||<01>}|<00>|<03>dSdt |j<02><01><00>}t
|<04><01>dt |j<02><01><00>}t
|<04><01>)Nr)r-r#zUnsupported BLP encoding zUnsupported BLP compression ) r<><00> _compression<6F> _encodingr r <00>_decode_jpeg_streamr<6D>r<><00>
set_as_rawrrr^)r}r(r<>r&r~rrrr<>\s  

 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 dkrb|jdj}t|t<11>sSJ<00>|jdj|ddfd<07>g|_|<00>|<05>d<08><01><15>d <09>dS)
Nr)<01> JpegImageFilerLr-r<00>CMYK)r<>rm<00>BGR)<16>JpegImagePluginr<6E>r3rsr<>r<>r<><00>tellr<6C>rr<00>_decompression_bomb_checkr{<00>moder|r<><00>
isinstance<EFBFBD>tuple<6C>_replacer<65><00>convert<72>tobytes)r}r<><00>jpeg_header_size<7A> jpeg_headerr&<00>imager<65>rrrr<>ns 
  
 zBLP1Decoder._decode_jpeg_streamNr<4E>)r
r r r<>r<>rrrrr<>[s
r<>c@seZdZddd<04>ZdS)<07> BLP2DecoderrrfcCs<>|j\|_|_}|_|<00><04>}|jdusJ<00>|j<05>|jd<00>|jdkr<>|jtj kr0|<00>
||<01>}n<>|jtj kr<>t <0C>}|jt jkrf|jjddd}t|jjdd<00>D]}t|<00>|<04>|<01>D]}||7}q]qSn||jt jkr<>|jjddd}t|jjdd<00>D]}t|<00>|<04><01>D]}||7}q<>q<EFBFBD>nP|jt jkr<>|jjddd}t|jjdd<00>D]}t|<00>|<04><01>D]}||7}q<>q<EFBFBD>n$dt|j<03><01><00>}t|<07><01>dt|j<02><01><00>}t|<07><01>d t|j<01><01><00>}t|<07><01>|<00>|<03>dS)
Nrrrr-r,rJzUnsupported alpha encoding zUnknown BLP encoding zUnknown BLP compression )r<>r<>r<><00>_alpha_encodingr<67>r<>rtr<>rrr<>rr1rr<00>state<74>xsizer2<00>ysizerIr<>rrUrr]rrr^r<>)r}r(r<>r&<00>linesize<7A>ybr<62>r~rrrr<><00>sJ
   
<02><02> 
<02><02> 
<02><02>zBLP2Decoder._loadNr<4E>)r
r r r<>rrrrr<><00>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<>rlr-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<>r{r2<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.Imagero<00> IO[bytes]<5D>filename<6D> str | bytesrfc
Cs@|jdkr d}t|<03><01>|j<02>d<03>dkrdnd}|<01>|<04>|jdus#J<00>|<01>t<06>dd<08><02>|jjd kr4dnd
}|dkrD|<01>t<06>d |<05><02>n%|<01>t<06>d tj <09><02>|<01>t<06>d |<05><02>|<01>t<06>d d
<EFBFBD><02>|<01>t<06>d d
<EFBFBD><02>|<01>tjd g|j
<EFBFBD>R<00><00>|dkr<>|<01>t<06>dd<0E><02>|<01>t<06>dd
<EFBFBD><02>t <0B> ||t <0B> dd|j
d
|j<00>g<01>dS)N<>PzUnsupported BLP image mode<64> blp_version<6F>BLP1r`rargrrlrz<Lrhrir#rern)r<><00>
ValueError<EFBFBD> encoderinfo<66>get<65>writer<65>r3r<>rrr{r<00>_saverz)r<>ror<>r~rq<00> alpha_depthrrrr<><00>s&

(r<>z.blpr<70><00>BLP2re)rrrr )F)r&r'r(r)rr*)r&r'rr*)r_r'rr))r<>r<>ror<>r<>r<>rrf)(r<><00>
__future__rr<>rur3<00>enumr<00>ior<00>typingr<00>rrr rrr%rIrUr]<00>NotImplementedErrorr^rcrd<00>ABC<42> 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
+4%0
!