MCPcopy Create free account
hub / github.com/carbonengine/trinity / CompressImageDXT1

Function CompressImageDXT1

trinity/Tr2DxtCompressor.cpp:732–754  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

730}
731
732void CompressImageDXT1( const uint8_t* inBuf, uint8_t* outBuf, int width, int height, ptrdiff_t& outputBytes, volatile const bool& cancel )
733{
734 uint8_t block[64];
735 uint8_t minColor[4];
736 uint8_t maxColor[4];
737 uint8_t** outData = &outBuf;
738 for( int j = 0; j < height; j += 4, inBuf += width * 4 * 4 )
739 {
740 if( cancel )
741 {
742 return;
743 }
744 for( int i = 0; i < width; i += 4 )
745 {
746 ExtractBlock( inBuf + i * 4, width, block );
747 GetMinMaxColors( block, minColor, maxColor );
748 EmitWord( ColorTo565( maxColor ), outData );
749 EmitWord( ColorTo565( minColor ), outData );
750 EmitColorIndices( block, minColor, maxColor, outData );
751 }
752 }
753 outputBytes = *outData - outBuf;
754}
755
756// below works fine, but doesn't support a material id in the alpha channel
757void CompressNormalMapDXT5NoAlpha( const uint8_t* inBuf, uint8_t* outBuf, int width, int height, ptrdiff_t& outputBytes, volatile const bool& cancel )

Callers 1

Tr2DxtCompressSurfaceFunction · 0.85

Calls 5

ExtractBlockFunction · 0.85
GetMinMaxColorsFunction · 0.85
EmitWordFunction · 0.85
ColorTo565Function · 0.85
EmitColorIndicesFunction · 0.85

Tested by

no test coverage detected