qv4l2: Adding width and height scaling to the status bar
authorAnton Arbring <aarbring@cisco.com>
Tue, 5 Aug 2014 13:38:27 +0000 (15:38 +0200)
committerHans Verkuil <hans.verkuil@cisco.com>
Thu, 7 Aug 2014 06:28:16 +0000 (08:28 +0200)
Signed-off-by: Anton Arbring <aarbring@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
utils/qv4l2/capture-win.cpp
utils/qv4l2/capture-win.h
utils/qv4l2/qv4l2.cpp

index 3437cf1..d388b03 100644 (file)
@@ -26,6 +26,8 @@
 #include <QApplication>
 #include <QDesktopWidget>
 
+#include <math.h>
+
 #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();
index 618f4d6..7330efe 100644 (file)
@@ -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;
index 7a34683..0e168e8 100644 (file)
@@ -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) {