+
    UBi                       R t ^ RIHt ^ RIt^ RIHt ^ RIHt ^RIH	t	H
t
 Rt ! R R]4      t ! R	 R
]
P                  4      tR R lt]	P                  ! ]P                   ]]4       ]	P"                  ! ]P                   RR.4       R# )a  
A Pillow loader for .ftc and .ftu files (FTEX)
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/

Independence War 2: Edge Of Chaos - Texture File Format - 16 October 2001

The textures used for 3D objects in Independence War 2: Edge Of Chaos are in a
packed custom format called FTEX. This file format uses file extensions FTC
and FTU.
* FTC files are compressed textures (using standard texture compression).
* FTU files are not compressed.
Texture File Format
The FTC and FTU texture files both use the same format. This
has the following structure:
{header}
{format_directory}
{data}
Where:
{header} = {
    u32:magic,
    u32:version,
    u32:width,
    u32:height,
    u32:mipmap_count,
    u32:format_count
}

* The "magic" number is "FTEX".
* "width" and "height" are the dimensions of the texture.
* "mipmap_count" is the number of mipmaps in the texture.
* "format_count" is the number of texture formats (different versions of the
same texture) in this file.

{format_directory} = format_count * { u32:format, u32:where }

The format value is 0 for DXT1 compressed textures and 1 for 24-bit RGB
uncompressed textures.
The texture data for a format starts at the position "where" in the file.

Each set of texture data in the file has the following structure:
{data} = format_count * { u32:mipmap_size, mipmap_size * { u8 } }
* "mipmap_size" is the number of bytes in that mip level. For compressed
textures this is the size of the texture data compressed with DXT1. For 24 bit
uncompressed textures, this is 3 * width * height. Following this are the image
bytes for that mipmap level.

Note: All data is stored in little-Endian (Intel) byte order.
)annotationsN)IntEnum)BytesIO)Image	ImageFiles   FTEXc                      ] tR t^At^ t^tRtR# )Format N)__name__
__module____qualname____firstlineno__DXT1UNCOMPRESSED__static_attributes__r	       8/usr/lib/python3.14/site-packages/PIL/FtexImagePlugin.pyr   r   A   s    DLr   r   c                  6    ] tR t^FtRtRtR R ltR R ltRtR# )	FtexImageFileFTEXzTexture File Format (IW2:EOC)c                   V ^8  d   QhRR/# )   returnNoner	   )formats   "r   __annotate__FtexImageFile.__annotate__J   s        t  r   c                	   \        V P                  P                  ^4      4      '       g   Rp\        V4      h\        P
                  ! RV P                  P                  ^4      4       \        P
                  ! RV P                  P                  ^4      4      V n        \        P
                  ! RV P                  P                  ^4      4      w  r#V^8X  g   Q h\        P
                  ! RV P                  P                  ^4      4      w  rEV P                  P                  V4       \        P
                  ! RV P                  P                  ^4      4      w  pV P                  P                  V4      pV\        P                  8X  d9   RV n
        \        P                  ! RR
V P                  ,           ^ R4      .V n        MfV\        P                  8X  d9   RV n
        \        P                  ! RR
V P                  ,           ^ R4      .V n        MR\!        V4       2p\#        V4      hV P                  P%                  4        \'        V4      V n        R	# )   znot an FTEX filez<iz<2iRGBAbcnRGBrawz$Invalid texture compression format: N)    r#   )   )_acceptfpreadSyntaxErrorstructunpack_sizeseekr   r   _moder   _Tilesizetiler   repr
ValueErrorcloser   )selfmsgmipmap_countformat_countr   wheremipmap_sizedatas   &       r   _openFtexImageFile._openJ   s   tww||A''$Cc""dDGGLLO,]]5$'',,q/:
%+]]5$'',,q/%J" q   eTWW\\!_=UtTWW\\!_=ww||K(V[[ DJ"0BAtLMDIv***DJ"0BAuMNDI8fGCS/!$-r   c                    V ^8  d   QhRRRR/# )r   posintr   r   r	   )r   s   "r   r   r   i   s      S T r   c                	    R # Nr	   )r4   r>   s   &&r   	load_seekFtexImageFile.load_seeki   s    r   )r-   r+   r&   r0   N)	r
   r   r   r   r   format_descriptionr;   rB   r   r	   r   r   r   r   F   s    F8 > r   r   c                    V ^8  d   QhRRRR/# )r   prefixbytesr   boolr	   )r   s   "r   r   r   m   s     $ $E $d $r   c                ,    V P                  \        4      # rA   )
startswithMAGIC)rF   s   &r   r%   r%   m   s    U##r   z.ftcz.ftu)__doc__
__future__r   r)   enumr   ior    r   r   rK   r   r   r%   register_openr   register_extensionsr	   r   r   <module>rS      sz   3j #    W 
$I'' $N$   M((- A   -..0@ Ar   