[libcamera-devel] [RFC PATCH] qcam: Support software scaling of the ViewFinder

Kieran Bingham kieran.bingham at ideasonboard.com
Thu Jan 16 23:50:15 CET 2020


Introduce software rescaling of the ViewFinder.
When rescaling, this will introduce a performance penalty.

The resizing is not limited to the aspect ratio of the image.
If supporting software resizing is desireable, we may wish to impose at
least mataining the aspect ratio of the capture images.

Suggested-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
---

I'm not actually expecting this patch to be integrated (maybe we decide it's
useful, I'm not sure yet), but I wanted to post it in case it is useful to
anyone else.

The topic of being able to resize the QCam window (even at the expense of
software scaling) came up and we discovered it is only a few lines to remove
our fixed size restrictions.


 src/qcam/main_window.cpp | 1 -
 src/qcam/viewfinder.cpp  | 3 +--
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
index 1d9c756f147a..df51fa888342 100644
--- a/src/qcam/main_window.cpp
+++ b/src/qcam/main_window.cpp
@@ -33,7 +33,6 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)
 
 	viewfinder_ = new ViewFinder(this);
 	setCentralWidget(viewfinder_);
-	viewfinder_->setFixedSize(500, 500);
 	adjustSize();
 
 	ret = openCamera(cm);
diff --git a/src/qcam/viewfinder.cpp b/src/qcam/viewfinder.cpp
index 98a8ab68e5f6..9f92e11d5cf6 100644
--- a/src/qcam/viewfinder.cpp
+++ b/src/qcam/viewfinder.cpp
@@ -14,6 +14,7 @@
 ViewFinder::ViewFinder(QWidget *parent)
 	: QLabel(parent), format_(0), width_(0), height_(0), image_(nullptr)
 {
+	setScaledContents(true);
 }
 
 ViewFinder::~ViewFinder()
@@ -42,8 +43,6 @@ int ViewFinder::setFormat(unsigned int format, unsigned int width,
 	width_ = width;
 	height_ = height;
 
-	setFixedSize(width, height);
-
 	delete image_;
 	image_ = new QImage(width, height, QImage::Format_RGB32);
 
-- 
2.20.1



More information about the libcamera-devel mailing list