| 572 | |
| 573 | |
| 574 | uint32_t Tr2HostBitmap::CountPixelsOfValue( const std::string& channels, uint32_t value ) const |
| 575 | { |
| 576 | // Count the number of pixels for which all rgba channels listed in "channels" param match value. |
| 577 | |
| 578 | if( !IsValid() || GetBytesPerPixel( m_format ) != 4 || IsCompressed() ) |
| 579 | { |
| 580 | return 0; |
| 581 | } |
| 582 | |
| 583 | uint32_t numpix = 0; |
| 584 | |
| 585 | for( uint32_t x = 0; x < m_width; x++ ) |
| 586 | { |
| 587 | for( uint32_t y = 0; y < m_height; y++ ) |
| 588 | { |
| 589 | uint32_t pixval; |
| 590 | if( GetPixel( x, y, &pixval ) ) |
| 591 | { |
| 592 | bool matches = true; |
| 593 | if( chan_selected( channels, 'a' ) ) |
| 594 | { |
| 595 | matches &= check_chan_value( 0xFF000000, 24, pixval, value ); |
| 596 | } |
| 597 | |
| 598 | if( chan_selected( channels, 'r' ) ) |
| 599 | { |
| 600 | matches &= check_chan_value( 0x00FF0000, 16, pixval, value ); |
| 601 | } |
| 602 | |
| 603 | if( chan_selected( channels, 'g' ) ) |
| 604 | { |
| 605 | matches &= check_chan_value( 0x0000FF00, 8, pixval, value ); |
| 606 | } |
| 607 | |
| 608 | if( chan_selected( channels, 'b' ) ) |
| 609 | { |
| 610 | matches &= check_chan_value( 0x000000FF, 0, pixval, value ); |
| 611 | } |
| 612 | |
| 613 | if( matches ) |
| 614 | { |
| 615 | numpix++; |
| 616 | } |
| 617 | } |
| 618 | } |
| 619 | } |
| 620 | |
| 621 | return numpix; |
| 622 | } |
| 623 | |
| 624 | bool Tr2HostBitmap::IsMonochrome() const |
| 625 | { |
nothing calls this directly
no test coverage detected