Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

High-quality prescale panzoom image to max size needed.

Then use lower quality QPainter transform scaling for remaining scales.
This should be faster and results in higher quality zoom overall.
  • Loading branch information...
commit 127f374e3c4c32976dedeee632644e0aea4c7f98 1 parent b1be540
Andrew Wason authored

Showing 1 changed file with 7 additions and 13 deletions. Show diff stats Hide diff stats

  1. +7 13 mlt/panzoom_producer.cpp
20 mlt/panzoom_producer.cpp
@@ -84,9 +84,6 @@ static QImage* getPrescaledSourceImage(mlt_producer producer, mlt_geometry geome
84 84 QSize imageSize(image->size());
85 85 if (maxSize.width() < imageSize.width() && maxSize.height() < imageSize.height())
86 86 *image = image->scaled(maxSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
87   - // Image smooth scaling is more efficient for RGB32
88   - if (image->format() != QImage::Format_RGB32)
89   - *image = image->convertToFormat(QImage::Format_RGB32);
90 87 }
91 88 else {
92 89 mlt_log(MLT_PRODUCER_SERVICE(producer), MLT_LOG_ERROR,
@@ -137,23 +134,20 @@ static int producerGetImage(mlt_frame frame, uint8_t **buffer, mlt_image_format
137 134 item.x += (item.w - scaleHeight * image->width()) / 2.0;
138 135 else if (scaleHeight > scaleWidth)
139 136 item.y += (item.h - scaleWidth * image->height()) / 2.0;
140   - QPointF offset(item.x, item.y);
141   -
142   - QImage scaledImage;
143   - if (scale != 1.0)
144   - scaledImage = image->scaled(scale * image->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
145   - else
146   - scaledImage = *image;
147 137
148 138 QImage targetImage(static_cast<uchar*>(*buffer), *width, *height, *width * 3, QImage::Format_RGB888);
149 139
  140 + QTransform tx(QTransform::fromTranslate(item.x, item.y).scale(scale, scale));
  141 +
150 142 // Clear buffer if image doesn't fill it
151   - QRectF imageRect(offset, scaledImage.size());
152   - if (!imageRect.contains(targetImage.rect()))
  143 + QRect rect(tx.mapRect(image->rect()));
  144 + if (!rect.contains(targetImage.rect()))
153 145 memset(*buffer, 0, size);
154 146
155 147 QPainter painter(&targetImage);
156   - painter.drawImage(offset, scaledImage);
  148 + painter.setTransform(tx);
  149 + painter.setRenderHint(QPainter::SmoothPixmapTransform);
  150 + painter.drawImage(QPointF(0, 0), *image);
157 151
158 152 return error;
159 153 }

0 comments on commit 127f374

Please sign in to comment.
Something went wrong with that request. Please try again.