comparison layer/Colour3DPlotRenderer.cpp @ 1084:db976e9f385a spectrogram-minor-refactor

Scale and copy
author Chris Cannam
date Fri, 01 Jul 2016 11:37:46 +0100
parents 7122aae95a88
children c8c747783110
comparison
equal deleted inserted replaced
1083:7122aae95a88 1084:db976e9f385a
280 usePeaksCache, 280 usePeaksCache,
281 rightToLeft, 281 rightToLeft,
282 timeConstrained); 282 timeConstrained);
283 283
284 //!!! now scale-copy to cache 284 //!!! now scale-copy to cache
285
286 if (attainedWidth == 0) return;
287
288 int paintedLeft = x0;
289 if (rightToLeft) {
290 paintedLeft += (repaintWidth - attainedWidth);
291 }
292
293 if (bufferIsBinResolution) {
294
295 int scaledLeft = v->getXForFrame(leftBoundaryFrame);
296 int scaledRight = v->getXForFrame(rightBoundaryFrame);
297
298 QImage scaled = m_drawBuffer.scaled
299 (scaledRight - scaledLeft, h,
300 Qt::IgnoreAspectRatio, (m_params.interpolate ?
301 Qt::SmoothTransformation :
302 Qt::FastTransformation));
303
304 int scaledLeftCrop = v->getXForFrame(leftCropFrame);
305 int scaledRightCrop = v->getXForFrame(rightCropFrame);
306
307 int targetLeft = scaledLeftCrop;
308 if (targetLeft < 0) {
309 targetLeft = 0;
310 }
311
312 int targetWidth = scaledRightCrop - targetLeft;
313 if (targetLeft + targetWidth > m_cache.getSize().width()) {
314 targetWidth = m_cache.getSize().width() - targetLeft;
315 }
316
317 int sourceLeft = targetLeft - scaledLeft;
318 if (sourceLeft < 0) {
319 sourceLeft = 0;
320 }
321
322 int sourceWidth = targetWidth;
323
324 if (targetWidth > 0) {
325 m_cache.drawImage(targetLeft, targetWidth,
326 scaled,
327 sourceLeft, sourceWidth);
328 }
329
330 } else {
331
332 m_cache.drawImage(paintedLeft, attainedWidth,
333 m_drawBuffer,
334 paintedLeft - x0, attainedWidth);
335 }
285 } 336 }
286 337
287 338
288 int 339 int
289 Colour3DPlotRenderer::renderDrawBuffer(int w, int h, 340 Colour3DPlotRenderer::renderDrawBuffer(int w, int h,