Changeset 9383 in ntrip for trunk/BNC/qwt/qwt_plot_rasteritem.cpp
- Timestamp:
- Mar 19, 2021, 9:15:03 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_plot_rasteritem.cpp
r8127 r9383 159 159 py0 += strippedRect.top() - paintRect.top(); 160 160 161 QImage expanded(sz, image.format()); 161 QImage expanded( sz, image.format() ); 162 if ( image.format() == QImage::Format_Indexed8 ) 163 expanded.setColorTable( image.colorTable() ); 162 164 163 165 switch( image.depth() ) … … 191 193 } 192 194 193 const quint32 *line1 = 195 const quint32 *line1 = 194 196 reinterpret_cast<const quint32 *>( image.scanLine( y1 ) ); 195 197 … … 223 225 for ( int y2 = yy1; y2 < yy2; y2++ ) 224 226 { 225 quint32 *line2 = reinterpret_cast<quint32 *>( 227 quint32 *line2 = reinterpret_cast<quint32 *>( 226 228 expanded.scanLine( y2 ) ); 227 229 228 for ( int x2 = xx1; x2 < xx2; x2++ ) 230 for ( int x2 = xx1; x2 < xx2; x2++ ) 229 231 line2[x2] = rgb; 230 } 231 } 232 } 232 } 233 } 234 } 233 235 break; 234 236 } … … 241 243 { 242 244 yy1 = 0; 243 } 245 } 244 246 else 245 247 { 246 248 yy1 = qRound( y1 * ph - py0 ); 247 249 if ( yy1 < 0 ) 248 yy1 = 0; 249 } 250 250 yy1 = 0; 251 } 252 251 253 int yy2; 252 254 if ( y1 == h - 1 ) 253 255 { 254 256 yy2 = sz.height(); 255 } 257 } 256 258 else 257 259 { … … 260 262 yy2 = sz.height(); 261 263 } 262 264 263 265 const uchar *line1 = image.scanLine( y1 ); 264 266 … … 293 295 uchar *line2 = expanded.scanLine( y2 ); 294 296 memset( line2 + xx1, line1[x1], xx2 - xx1 ); 295 } 296 } 297 } 298 } 297 299 } 298 300 break; … … 301 303 expanded = image; 302 304 } 303 305 304 306 return expanded; 305 } 307 } 306 308 307 309 static QRectF qwtExpandToPixels(const QRectF &rect, const QRectF &pixelRect) … … 385 387 } 386 388 387 static void qwtToRgba( const QImage* from, QImage* to, 389 static void qwtToRgba( const QImage* from, QImage* to, 388 390 const QRect& tile, int alpha ) 389 391 { … … 573 575 574 576 The geometry of a pixel is used to calculated the resolution and 575 alignment of the rendered image. 576 577 Width and height of the hint need to be the horizontal 578 and vertical distances between 2 neighbored points. 579 The center of the hint has to be the position of any point 577 alignment of the rendered image. 578 579 Width and height of the hint need to be the horizontal 580 and vertical distances between 2 neighbored points. 581 The center of the hint has to be the position of any point 580 582 ( it doesn't matter which one ). 581 583 582 584 Limiting the resolution of the image might significantly improve 583 585 the performance and heavily reduce the amount of memory when rendering 584 a QImage from the raster data. 586 a QImage from the raster data. 585 587 586 588 The default implementation returns an empty rectangle (QRectF()), … … 664 666 { 665 667 /* 666 If only one dimension is of the data pixel is higher 668 If only one dimension is of the data pixel is higher 667 669 we expand the pixel rect to the resolution of the target device. 668 670 */ … … 690 692 // data pixels we render in resolution of the paint device. 691 693 692 image = compose(xxMap, yyMap, 694 image = compose(xxMap, yyMap, 693 695 area, paintRect, paintRect.size().toSize(), doCache); 694 696 if ( image.isNull() ) … … 698 700 // excluded in the intervals 699 701 700 imageRect = qwtStripRect(paintRect, area, 702 imageRect = qwtStripRect(paintRect, area, 701 703 xxMap, yyMap, xInterval, yInterval); 702 704 703 705 if ( imageRect != paintRect ) 704 706 { 705 const QRect r( 707 const QRect r( 706 708 qRound( imageRect.x() - paintRect.x()), 707 709 qRound( imageRect.y() - paintRect.y() ), 708 710 qRound( imageRect.width() ), 709 711 qRound( imageRect.height() ) ); 710 712 711 713 image = image.copy(r); 712 } 714 } 713 715 } 714 716 else … … 735 737 imageSize.setHeight( qRound( imageArea.height() / pixelRect.height() ) ); 736 738 737 image = compose(xxMap, yyMap, 739 image = compose(xxMap, yyMap, 738 740 imageArea, paintRect, imageSize, doCache ); 739 741 … … 741 743 return; 742 744 743 imageRect = qwtStripRect(paintRect, area, 745 imageRect = qwtStripRect(paintRect, area, 744 746 xxMap, yyMap, xInterval, yInterval); 745 747 … … 747 749 testPaintAttribute( PaintInDeviceResolution ) ) 748 750 { 749 // Because of rounding errors the pixels 750 // need to be expanded manually to rectangles of 751 // Because of rounding errors the pixels 752 // need to be expanded manually to rectangles of 751 753 // different sizes 752 754 753 image = qwtExpandImage(image, xxMap, yyMap, 755 image = qwtExpandImage(image, xxMap, yyMap, 754 756 imageArea, area, paintRect, xInterval, yInterval ); 755 757 } … … 758 760 painter->save(); 759 761 painter->setWorldTransform( QTransform() ); 760 762 761 763 QwtPainter::drawImage( painter, imageRect, image ); 762 764 … … 769 771 This method is intended to be reimplemented by derived classes. 770 772 The default implementation returns an invalid interval. 771 773 772 774 \param axis X, Y, or Z axis 773 775 */ … … 817 819 } 818 820 819 QImage QwtPlotRasterItem::compose( 821 QImage QwtPlotRasterItem::compose( 820 822 const QwtScaleMap &xMap, const QwtScaleMap &yMap, 821 const QRectF &imageArea, const QRectF &paintRect, 823 const QRectF &imageArea, const QRectF &paintRect, 822 824 const QSize &imageSize, bool doCache) const 823 825 { … … 842 844 dx = imageArea.width() / imageSize.width(); 843 845 844 const QwtScaleMap xxMap = 846 const QwtScaleMap xxMap = 845 847 imageMap(Qt::Horizontal, xMap, imageArea, imageSize, dx); 846 848 847 849 double dy = 0.0; 848 850 if ( paintRect.toRect().height() > imageSize.height() ) 849 851 dy = imageArea.height() / imageSize.height(); 850 852 851 const QwtScaleMap yyMap = 853 const QwtScaleMap yyMap = 852 854 imageMap(Qt::Vertical, yMap, imageArea, imageSize, dy); 853 855 … … 937 939 } 938 940 939 if ( pixelSize > 0.0 )941 if ( pixelSize > 0.0 || p2 == 1.0 ) 940 942 { 941 943 double off = 0.5 * pixelSize;
Note:
See TracChangeset
for help on using the changeset viewer.