summaryrefslogtreecommitdiffhomepage
path: root/cv/video-widget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cv/video-widget.cpp')
-rw-r--r--cv/video-widget.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/cv/video-widget.cpp b/cv/video-widget.cpp
index 4c9a73e6..f125bf76 100644
--- a/cv/video-widget.cpp
+++ b/cv/video-widget.cpp
@@ -85,8 +85,27 @@ void cv_video_widget::update_image(const QImage& img)
void cv_video_widget::paintEvent(QPaintEvent*)
{
QMutexLocker foo(&mtx);
+
QPainter painter(this);
+
+ double dpr = devicePixelRatioF();
+
+ int W = int(QWidget::width() * dpr);
+ int H = int(QWidget::height() * dpr);
+
painter.drawImage(rect(), texture);
+
+ if (texture.width() != W || texture.height() != H)
+ {
+ texture = QImage(W, H, QImage::Format_ARGB32);
+ texture.setDevicePixelRatio(dpr);
+
+ width = W, height = H;
+
+ _frame = cv::Mat();
+ _frame2 = cv::Mat();
+ _frame3 = cv::Mat();
+ }
}
void cv_video_widget::update_and_repaint()
@@ -102,3 +121,10 @@ void cv_video_widget::update_and_repaint()
repaint();
}
}
+
+void cv_video_widget::get_preview_size(int& w, int& h)
+{
+ QMutexLocker l(&mtx);
+
+ w = width, h = height;
+}