# HG changeset patch # User Chris Cannam # Date 1467369466 -3600 # Node ID db976e9f385aeee70e027001a6a33cb0770d8538 # Parent 7122aae95a8821a3aab7b1ce39a34c8a8e41c8de Scale and copy diff -r 7122aae95a88 -r db976e9f385a layer/Colour3DPlotRenderer.cpp --- a/layer/Colour3DPlotRenderer.cpp Fri Jul 01 11:21:09 2016 +0100 +++ b/layer/Colour3DPlotRenderer.cpp Fri Jul 01 11:37:46 2016 +0100 @@ -282,6 +282,57 @@ timeConstrained); //!!! now scale-copy to cache + + if (attainedWidth == 0) return; + + int paintedLeft = x0; + if (rightToLeft) { + paintedLeft += (repaintWidth - attainedWidth); + } + + if (bufferIsBinResolution) { + + int scaledLeft = v->getXForFrame(leftBoundaryFrame); + int scaledRight = v->getXForFrame(rightBoundaryFrame); + + QImage scaled = m_drawBuffer.scaled + (scaledRight - scaledLeft, h, + Qt::IgnoreAspectRatio, (m_params.interpolate ? + Qt::SmoothTransformation : + Qt::FastTransformation)); + + int scaledLeftCrop = v->getXForFrame(leftCropFrame); + int scaledRightCrop = v->getXForFrame(rightCropFrame); + + int targetLeft = scaledLeftCrop; + if (targetLeft < 0) { + targetLeft = 0; + } + + int targetWidth = scaledRightCrop - targetLeft; + if (targetLeft + targetWidth > m_cache.getSize().width()) { + targetWidth = m_cache.getSize().width() - targetLeft; + } + + int sourceLeft = targetLeft - scaledLeft; + if (sourceLeft < 0) { + sourceLeft = 0; + } + + int sourceWidth = targetWidth; + + if (targetWidth > 0) { + m_cache.drawImage(targetLeft, targetWidth, + scaled, + sourceLeft, sourceWidth); + } + + } else { + + m_cache.drawImage(paintedLeft, attainedWidth, + m_drawBuffer, + paintedLeft - x0, attainedWidth); + } }