! \brief Render a tile of an image. Rendering in tiles can be used to composite an image in parallel threads. \param xMap X-Scale Map \param yMap Y-Scale Map \param tile Geometry of the tile in image coordinates \param image Image to be rendered */
| 570 | \param image Image to be rendered |
| 571 | */ |
| 572 | void QwtPlotSpectrogram::renderTile( |
| 573 | const QwtScaleMap& xMap, const QwtScaleMap& yMap, |
| 574 | const QRect& tile, QImage* image ) const |
| 575 | { |
| 576 | const QwtInterval range = m_data->data->interval( Qt::ZAxis ); |
| 577 | if ( range.width() <= 0.0 ) |
| 578 | return; |
| 579 | |
| 580 | const bool hasGaps = !m_data->data->testAttribute( QwtRasterData::WithoutGaps ); |
| 581 | |
| 582 | if ( m_data->colorMap->format() == QwtColorMap::RGB ) |
| 583 | { |
| 584 | const int numColors = m_data->colorTable.size(); |
| 585 | const QRgb* rgbTable = m_data->colorTable.constData(); |
| 586 | const QwtColorMap* colorMap = m_data->colorMap; |
| 587 | |
| 588 | for ( int y = tile.top(); y <= tile.bottom(); y++ ) |
| 589 | { |
| 590 | const double ty = yMap.invTransform( y ); |
| 591 | |
| 592 | QRgb* line = reinterpret_cast< QRgb* >( image->scanLine( y ) ); |
| 593 | line += tile.left(); |
| 594 | |
| 595 | for ( int x = tile.left(); x <= tile.right(); x++ ) |
| 596 | { |
| 597 | const double tx = xMap.invTransform( x ); |
| 598 | |
| 599 | const double value = m_data->data->value( tx, ty ); |
| 600 | |
| 601 | if ( hasGaps && qwtIsNaN( value ) ) |
| 602 | { |
| 603 | *line++ = 0u; |
| 604 | } |
| 605 | else if ( numColors == 0 ) |
| 606 | { |
| 607 | *line++ = colorMap->rgb( range, value ); |
| 608 | } |
| 609 | else |
| 610 | { |
| 611 | const uint index = colorMap->colorIndex( numColors, range, value ); |
| 612 | *line++ = rgbTable[index]; |
| 613 | } |
| 614 | } |
| 615 | } |
| 616 | } |
| 617 | else if ( m_data->colorMap->format() == QwtColorMap::Indexed ) |
| 618 | { |
| 619 | for ( int y = tile.top(); y <= tile.bottom(); y++ ) |
| 620 | { |
| 621 | const double ty = yMap.invTransform( y ); |
| 622 | |
| 623 | unsigned char* line = image->scanLine( y ); |
| 624 | line += tile.left(); |
| 625 | |
| 626 | for ( int x = tile.left(); x <= tile.right(); x++ ) |
| 627 | { |
| 628 | const double tx = xMap.invTransform( x ); |
| 629 |
nothing calls this directly
no test coverage detected