! \brief Render an image from data and color map. For each pixel of area the value is mapped into a color. \param xMap X-Scale Map \param yMap Y-Scale Map \param area Requested area for the image in scale coordinates \param imageSize Size of the requested image \return A QImage::Format_Indexed8 or QImage::Format_ARGB32 depending on the color map. \sa QwtRaste
| 478 | QwtColorMap::colorIndex() |
| 479 | */ |
| 480 | QImage QwtPlotSpectrogram::renderImage( |
| 481 | const QwtScaleMap& xMap, const QwtScaleMap& yMap, |
| 482 | const QRectF& area, const QSize& imageSize ) const |
| 483 | { |
| 484 | if ( imageSize.isEmpty() || m_data->data == NULL |
| 485 | || m_data->colorMap == NULL ) |
| 486 | { |
| 487 | return QImage(); |
| 488 | } |
| 489 | |
| 490 | const QwtInterval intensityRange = m_data->data->interval( Qt::ZAxis ); |
| 491 | if ( !intensityRange.isValid() ) |
| 492 | return QImage(); |
| 493 | |
| 494 | const QImage::Format format = ( m_data->colorMap->format() == QwtColorMap::RGB ) |
| 495 | ? QImage::Format_ARGB32 : QImage::Format_Indexed8; |
| 496 | |
| 497 | QImage image( imageSize, format ); |
| 498 | |
| 499 | if ( m_data->colorMap->format() == QwtColorMap::Indexed ) |
| 500 | image.setColorTable( m_data->colorMap->colorTable256() ); |
| 501 | |
| 502 | m_data->data->initRaster( area, image.size() ); |
| 503 | |
| 504 | #if DEBUG_RENDER |
| 505 | QElapsedTimer time; |
| 506 | time.start(); |
| 507 | #endif |
| 508 | |
| 509 | #if !defined( QT_NO_QFUTURE ) |
| 510 | uint numThreads = renderThreadCount(); |
| 511 | |
| 512 | if ( numThreads <= 0 ) |
| 513 | numThreads = QThread::idealThreadCount(); |
| 514 | |
| 515 | if ( numThreads <= 0 ) |
| 516 | numThreads = 1; |
| 517 | |
| 518 | const int numRows = imageSize.height() / numThreads; |
| 519 | |
| 520 | QVector< QFuture< void > > futures; |
| 521 | futures.reserve( numThreads - 1 ); |
| 522 | |
| 523 | for ( uint i = 0; i < numThreads; i++ ) |
| 524 | { |
| 525 | QRect tile( 0, i * numRows, image.width(), numRows ); |
| 526 | if ( i == numThreads - 1 ) |
| 527 | { |
| 528 | tile.setHeight( image.height() - i * numRows ); |
| 529 | renderTile( xMap, yMap, tile, &image ); |
| 530 | } |
| 531 | else |
| 532 | { |
| 533 | futures += QtConcurrent::run( |
| 534 | #if QT_VERSION >= 0x060000 |
| 535 | &QwtPlotSpectrogram::renderTile, this, |
| 536 | #else |
| 537 | this, &QwtPlotSpectrogram::renderTile, |
nothing calls this directly
no test coverage detected