qcam: Add Qt-based GUI application
qcam is a sample camera GUI application based on Qt. It demonstrates integration of the Qt event loop with libcamera. The application lets the user select a camera through the GUI, and then captures a single stream from the camera and displays it in a window. Only streams in YUYV formats are supported for now. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
/*
|
||||
* Copyright (C) 2019, Google Inc.
|
||||
*
|
||||
* viewfinder.cpp - qcam - Viewfinder
|
||||
*/
|
||||
|
||||
#include <QImage>
|
||||
#include <QPixmap>
|
||||
|
||||
#include "format_converter.h"
|
||||
#include "viewfinder.h"
|
||||
|
||||
ViewFinder::ViewFinder(QWidget *parent)
|
||||
: QLabel(parent), format_(0), width_(0), height_(0), image_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
void ViewFinder::display(const unsigned char *raw)
|
||||
{
|
||||
converter_.convert(raw, image_->bits());
|
||||
|
||||
QPixmap pixmap = QPixmap::fromImage(*image_);
|
||||
setPixmap(pixmap);
|
||||
}
|
||||
|
||||
int ViewFinder::setFormat(unsigned int format, unsigned int width,
|
||||
unsigned int height)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = converter_.configure(format, width, height);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
format_ = format;
|
||||
width_ = width;
|
||||
height_ = height;
|
||||
|
||||
setFixedSize(width, height);
|
||||
|
||||
delete image_;
|
||||
image_ = new QImage(width, height, QImage::Format_RGB32);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user