MCPcopy Create free account
hub / github.com/codestation/qcma / LoadRXGB

Function LoadRXGB

common/dds.cpp:672–719  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

670}
671
672static bool LoadRXGB( QDataStream & s, const DDSHeader & header, QImage & img )
673{
674 const uint w = header.width;
675 const uint h = header.height;
676
677 BlockDXT block;
678 BlockDXTAlphaLinear alpha;
679 QRgb * scanline[4];
680
681 for( uint y = 0; y < h; y += 4 ) {
682 for( uint j = 0; j < 4; j++ ) {
683 scanline[j] = (QRgb *) img.scanLine( y + j );
684 }
685 for( uint x = 0; x < w; x += 4 ) {
686
687 // Read 128bit color block.
688 s >> alpha;
689 s >> block;
690
691 // Decode color block.
692 Color8888 color_array[4];
693 block.GetColors(color_array);
694
695 uchar alpha_array[8];
696 alpha.GetAlphas(alpha_array);
697
698 uchar bit_array[16];
699 alpha.GetBits(bit_array);
700
701 // bit masks = 00000011, 00001100, 00110000, 11000000
702 const uint masks[4] = { 3, 3<<2, 3<<4, 3<<6 };
703 const int shift[4] = { 0, 2, 4, 6 };
704
705 // Write color block.
706 for( uint j = 0; j < 4; j++ ) {
707 for( uint i = 0; i < 4; i++ ) {
708 if( img.valid( x+i, y+j ) ) {
709 uint idx = (block.row[j] & masks[i]) >> shift[i];
710 color_array[idx].a = alpha_array[bit_array[j*4+i]];
711 scanline[j][x+i] = qRgb(color_array[idx].a, color_array[idx].g, color_array[idx].b);
712 }
713 }
714 }
715 }
716 }
717
718 return true;
719}
720
721static bool LoadATI2( QDataStream & s, const DDSHeader & header, QImage & img )
722{

Callers

nothing calls this directly

Calls 3

GetColorsMethod · 0.80
GetAlphasMethod · 0.80
GetBitsMethod · 0.80

Tested by

no test coverage detected