| 642 | } |
| 643 | |
| 644 | void CompressImageSquish( const uint8_t* inBuf, |
| 645 | unsigned width, |
| 646 | unsigned height, |
| 647 | uint8_t* outBuf, |
| 648 | size_t outputPitch, |
| 649 | int squish_flags, |
| 650 | volatile const bool& cancel ) |
| 651 | { |
| 652 | uint8_t block[64]; |
| 653 | const unsigned outDx = ( squish_flags & squish::kDxt1 ) ? 8 : 16; |
| 654 | for( unsigned j = 0; j < height; j += 4, inBuf += width * 4 * 4 ) |
| 655 | { |
| 656 | uint8_t* outData = outBuf + ( j / 4 ) * outputPitch; |
| 657 | |
| 658 | if( cancel ) |
| 659 | { |
| 660 | return; |
| 661 | } |
| 662 | |
| 663 | for( unsigned i = 0; i < width; i += 4 ) |
| 664 | { |
| 665 | ExtractBlock( inBuf + i * 4, width, block ); |
| 666 | // Swap the R and B |
| 667 | // Squish wants RGB but our format is BGR |
| 668 | for( int k = 0; k < 16; ++k ) |
| 669 | { |
| 670 | std::swap( block[k * 4], block[k * 4 + 2] ); |
| 671 | } |
| 672 | squish::Compress( block, outData, squish_flags ); |
| 673 | outData += outDx; |
| 674 | } |
| 675 | } |
| 676 | } |
| 677 | |
| 678 | void CompressImageDXT5( const uint8_t* inBuf, uint8_t* outBuf, int width, int height, ptrdiff_t& outputBytes, volatile const bool& cancel ) |
| 679 | { |
no test coverage detected