ó <×ï[c@sMdZddlZddlmZddlmZmZdZdZdZ dZ dZ dZ d Z d „Zed „Zd „Zd „Zdefd„ƒYZdejfd„ƒYZdejfd„ƒYZdefd„ƒYZdefd„ƒYZejejed„ƒejejdƒejdeƒejdeƒdS(sÑ Blizzard Mipmap Format (.blp) Jerome Leclanche 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. iÿÿÿÿN(tBytesIOi(tImaget ImageFileiiiicCs-|d?d@d>|d?d@d>|d@d>fS(Ni iiii?i((ti((s2/tmp/pip-build-SKekGm/pillow/PIL/BlpImagePlugin.pyt unpack_5651scCsMt|ƒd}tƒtƒtƒtƒf}xt|ƒD] }|d}tjd||ƒ\}}}t|ƒ\} } } t|ƒ\} } }x¯tdƒD]¡}x˜tdƒD]Š}|d@}|d?}d}|dkrö| | | }}}n|dkr| | |}}}nä|dkr—||krjd| | d}d| | d}d| |d}qý| | d}| | d}| |d}nf|dkrý||krèd| | d}d| | d}d|| d}qýd \}}}}n|r#||j||||gƒq³||j|||gƒq³Wq Wq;W|S( sE input: one "row" of data (i.e. will produce 4*width pixels) isB|dd>B|dd >B}|d |d d>B} tjd |dƒ\} } tjd |dƒ\} t| ƒ\} }}t| ƒ\}}}x7tdƒD])}x tdƒD]}dd||}|dkr| |?d@}n7|dkr¤| d?|d >d@B}n||d?d@}|d krË|}nŠ|d krà|}nu||kr d|||d |d}nH|dkr"d }n3|dkr7d}nd|||d |d}| dd||?d@}|d kr’| ||}}}n­|d krµ|||}}}nŠ|dkrúd| |d}d||d}d||d}nE|dkr?d|| d}d||d}d||d}n||j||||gƒqJWq7Wq;W|S(sG input: one "row" of data (i.e. will produce 4 * width pixels) isR7R;(R?Ratjpeg_header_sizet jpeg_headerR timage((s2/tmp/pip-build-SKekGm/pillow/PIL/BlpImagePlugin.pyR[cs!$     (R/R0RQR[(((s2/tmp/pip-build-SKekGm/pillow/PIL/BlpImagePlugin.pyRYFs t BLP2DecodercBseZd„ZRS(c CsÍ|jƒ}tƒ}|jj|jdƒ|jdkr£|jtkrßt|jj |j dƒƒ}x4t rÛy"t j d|j dƒƒ\}Wnt jk r«PnX||\}}}}|j|||fƒqlWq¶|jtkr|jtkr{|jdddd} xqt|jdddƒD]B} x9t|jj | ƒdt|jƒƒD]} || 7}q`Wq2Wq |jtkrù|jdddd} xät|jdddƒD]3} x*t|jj | ƒƒD]} || 7}qÞWq¿Wq |jtkrw|jdddd} xft|jdddƒD]3} x*t|jj | ƒƒD]} || 7}q\Wq=Wq td |jƒ‚q¶td |jƒ‚ntd |jƒ‚|jt|ƒƒdS( Niis®ss.blpR3R5(RKRtioRtRRRZRhRit"BLP_ENCODING_UNCOMPRESSED_RAW_BGRARjRlRmRR!R R'R-tNotImplementedErrorR.R1t PyDecoderRNRYRgt register_openRLtregister_extensiontregister_decoder(((s2/tmp/pip-build-SKekGm/pillow/PIL/BlpImagePlugin.pyts0   7 5 H+*,;