#NEWLINE# def dxt5( data , width , height ) : #NEWLINE# #INDENT# ret = bytearray ( ( ( 4 * width ) * height ) ) #NEWLINE# data = BytesIO ( data ) #NEWLINE# for y in range ( 0 , height , 4 ) : #NEWLINE# #INDENT# for x in range ( 0 , width , 4 ) : #NEWLINE# #INDENT# ( a0 , a1 , ac0 , ac1 , c0 , c1 , code ) = struct . unpack ( '<2BHI2HI' , data . read ( 16 ) ) #NEWLINE# ( r0 , g0 , b0 ) = decode565 ( c0 ) #NEWLINE# ( r1 , g1 , b1 ) = decode565 ( c1 ) #NEWLINE# for j in range ( 4 ) : #NEWLINE# #INDENT# for i in range ( 4 ) : #NEWLINE# #INDENT# ai = ( 3 * ( ( 4 * j ) + i ) ) #NEWLINE# alpha = _dxtc_alpha ( a0 , a1 , ac0 , ac1 , ai ) #NEWLINE# cc = ( ( code >> ( 2 * ( ( 4 * j ) + i ) ) ) & 3 ) #NEWLINE# if ( cc == 0 ) : #NEWLINE# #INDENT# ( r , g , b ) = ( r0 , g0 , b0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( cc == 1 ) : #NEWLINE# #INDENT# ( r , g , b ) = ( r1 , g1 , b1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( cc == 2 ) : #NEWLINE# #INDENT# ( r , g , b ) = ( _c2a ( r0 , r1 ) , _c2a ( g0 , g1 ) , _c2a ( b0 , b1 ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( cc == 3 ) : #NEWLINE# #INDENT# ( r , g , b ) = ( _c3 ( r0 , r1 ) , _c3 ( g0 , g1 ) , _c3 ( b0 , b1 ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# idx = ( 4 * ( ( ( y + j ) * width ) + ( x + i ) ) ) #NEWLINE# ret [ idx : ( idx + 4 ) ] = bytes ( [ r , g , b , alpha ] ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return ret