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

Laurent Pinchart laurent.pinchart at ideasonboard.com
Fri Jan 17 01:26:31 CET 2020


Hi Kieran,

Thank you for the patch.

On Thu, Jan 16, 2020 at 10:50:15PM +0000, Kieran Bingham wrote:
> 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.

s/mataining/maintaining/

> 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.

I've had a look at the QLabel implementation, and scaling a QPixmap is
done by converting to a QImage, scaling the QImage, and converting back
to a QPixmap. I don't think we want that :-)

I think we should at least try to paint the image manually. I'll try to
submit a patch.

>  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);
>  

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list