From 086994e0497ba81b79cb0c8e15020797b3cf764c Mon Sep 17 00:00:00 2001 From: Anton Arbring Date: Tue, 5 Aug 2014 15:38:27 +0200 Subject: [PATCH] qv4l2: Adding width and height scaling to the status bar Signed-off-by: Anton Arbring Signed-off-by: Hans Verkuil --- utils/qv4l2/capture-win.cpp | 24 ++++++++++++++++++++++++ utils/qv4l2/capture-win.h | 2 ++ utils/qv4l2/qv4l2.cpp | 6 +++--- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/utils/qv4l2/capture-win.cpp b/utils/qv4l2/capture-win.cpp index 3437cf1..d388b03 100644 --- a/utils/qv4l2/capture-win.cpp +++ b/utils/qv4l2/capture-win.cpp @@ -26,6 +26,8 @@ #include #include +#include + #define MIN_WIN_SIZE_WIDTH 160 #define MIN_WIN_SIZE_HEIGHT 120 @@ -281,6 +283,28 @@ void CaptureWin::setPixelAspectRatio(double ratio) resetSize(); } +float CaptureWin::getHorScaleFactor() +{ + float ow, sw, wscale; + + sw = m_scaledSize.width(); + ow = m_origFrameSize.width(); + wscale = floor(100 * (sw / ow)) / 100.0; + + return wscale; +} + +float CaptureWin::getVertScaleFactor() +{ + float oh, sh, hscale; + + sh = m_scaledSize.height(); + oh = m_origFrameSize.height(); + hscale = floor(100 * (sh / oh)) / 100.0; + + return hscale; +} + void CaptureWin::mouseDoubleClickEvent(QMouseEvent *e) { m_appWin->m_makeFullScreenAct->toggle(); diff --git a/utils/qv4l2/capture-win.h b/utils/qv4l2/capture-win.h index 618f4d6..7330efe 100644 --- a/utils/qv4l2/capture-win.h +++ b/utils/qv4l2/capture-win.h @@ -67,6 +67,8 @@ public: void setWindowSize(QSize size); void enableScaling(bool enable); void setPixelAspectRatio(double ratio); + float getHorScaleFactor(); + float getVertScaleFactor(); virtual void setColorspace(unsigned colorspace) = 0; virtual void setField(unsigned field) = 0; virtual void setDisplayColorspace(unsigned colorspace) = 0; diff --git a/utils/qv4l2/qv4l2.cpp b/utils/qv4l2/qv4l2.cpp index 7a34683..0e168e8 100644 --- a/utils/qv4l2/qv4l2.cpp +++ b/utils/qv4l2/qv4l2.cpp @@ -777,7 +777,6 @@ void ApplicationWindow::outFrame() m_tv = tv; } - status = QString("Frame: %1 Fps: %2").arg(++m_frame).arg(m_fps); if (m_capMethod == methodMmap || m_capMethod == methodUser) { @@ -897,8 +896,9 @@ void ApplicationWindow::capFrame() m_tv = tv; } - - status = QString("Frame: %1 Fps: %2").arg(++m_frame).arg(m_fps); + float wscale = m_capture->getHorScaleFactor(); + float hscale = m_capture->getVertScaleFactor(); + status = QString("Frame: %1 Fps: %2 Scale Factors: %3x%4").arg(++m_frame).arg(m_fps).arg(wscale).arg(hscale); #ifdef HAVE_ALSA if (alsa_thread_is_running()) { if (tv_alsa.tv_sec || tv_alsa.tv_usec) { -- 2.7.4