From 0f292e7821b809df77de443dd30148a609cc4f49 Mon Sep 17 00:00:00 2001 From: Kieran Bingham Date: Wed, 5 Feb 2020 16:02:05 +0000 Subject: qcam: Provide save image functionality Implement a save image button on the toolbar which will take a current viewfinder image and present the user with a QFileDialog to allow them to choose where to save the image. Utilise the QImageWriter to perform the output task. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/qcam/viewfinder.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/qcam/viewfinder.cpp') diff --git a/src/qcam/viewfinder.cpp b/src/qcam/viewfinder.cpp index 6de284d1..d51eebb1 100644 --- a/src/qcam/viewfinder.cpp +++ b/src/qcam/viewfinder.cpp @@ -6,6 +6,8 @@ */ #include +#include +#include #include #include "format_converter.h" @@ -23,10 +25,25 @@ ViewFinder::~ViewFinder() void ViewFinder::display(const unsigned char *raw, size_t size) { + QMutexLocker locker(&mutex_); + + /* + * \todo We're not supposed to block the pipeline handler thread + * for long, implement a better way to save images without + * impacting performances. + */ + converter_.convert(raw, size, image_); update(); } +QImage ViewFinder::getCurrentImage() +{ + QMutexLocker locker(&mutex_); + + return image_->copy(); +} + int ViewFinder::setFormat(unsigned int format, unsigned int width, unsigned int height) { -- cgit v1.2.1