Patch Detail
Show a patch.
GET /api/patches/11733/?format=api
{ "id": 11733, "url": "https://patchwork.libcamera.org/api/patches/11733/?format=api", "web_url": "https://patchwork.libcamera.org/patch/11733/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20210326220540.1479330-1-kieran.bingham@ideasonboard.com>", "date": "2021-03-26T22:05:40", "name": "[libcamera-devel] qcam: viewfinder: Maintain aspect ratio", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "f6bfef6c65d1af30a0981c07e51332c50277baf5", "submitter": { "id": 4, "url": "https://patchwork.libcamera.org/api/people/4/?format=api", "name": "Kieran Bingham", "email": "kieran.bingham@ideasonboard.com" }, "delegate": { "id": 11, "url": "https://patchwork.libcamera.org/api/users/11/?format=api", "username": "kbingham", "first_name": "Kieran", "last_name": "Bingham", "email": "kieran.bingham@ideasonboard.com" }, "mbox": "https://patchwork.libcamera.org/patch/11733/mbox/", "series": [ { "id": 1842, "url": "https://patchwork.libcamera.org/api/series/1842/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1842", "date": "2021-03-26T22:05:40", "name": "[libcamera-devel] qcam: viewfinder: Maintain aspect ratio", "version": 1, "mbox": "https://patchwork.libcamera.org/series/1842/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/11733/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/11733/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 7B989C32EB\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 26 Mar 2021 22:05:46 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 36ECC68D6D;\n\tFri, 26 Mar 2021 23:05:46 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A740F68D6A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Mar 2021 23:05:44 +0100 (CET)", "from localhost.localdomain\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 02537885;\n\tFri, 26 Mar 2021 23:05:43 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"DU3SfTMd\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1616796344;\n\tbh=U8EmImkQo83KLt+f/aEsqHU+nCJQQhIGPtD7byXvAiE=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=DU3SfTMdDYir9jKA27uH8nU2D1JLnOx0HoVFEEZme67XNE1mu+ZZobmGzrmMT9S7u\n\t7i2J11kjlXPieeCo95pjXXuYpTYoWZ7Pg2K+LpZoywGW9ITuH/RL9YCMNzNiOsxld3\n\tpQQfgwtLv+Bzy9vkfKpaNTolgs2VRBnpaTwtgtwI=", "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>", "To": "libcamera devel <libcamera-devel@lists.libcamera.org>", "Date": "Fri, 26 Mar 2021 22:05:40 +0000", "Message-Id": "<20210326220540.1479330-1-kieran.bingham@ideasonboard.com>", "X-Mailer": "git-send-email 2.25.1", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH] qcam: viewfinder: Maintain aspect ratio", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Keep the image aspect ratio when displaying in the viewfinder.\n\nWhen the window is adjusted to a size that differs in aspect ratio to\nthe image, keep the image centered in the main viewpoint while\nmaintaining the image's aspect ratio.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\nIt's been really annoying me that the QCam viewfinder can scale to fit\nthe window, but that it breaks the aspect ratio of the image it\ncontains.\n\nI can't imagine why we would want to viewfind with an incorrect aspect\nratio, but if we do we can add that as an option later. For now -\nenforce aspect ratio on the QT viewfinder.\n\nOf course I'm aware that this doesn't cover the GL viewfinder. That can\neither be handled on top, or independently if this is deemed a worthy\nfeature.\n\n\n src/qcam/viewfinder_qt.cpp | 19 +++++++++++++++++--\n src/qcam/viewfinder_qt.h | 2 ++\n 2 files changed, 19 insertions(+), 2 deletions(-)", "diff": "diff --git a/src/qcam/viewfinder_qt.cpp b/src/qcam/viewfinder_qt.cpp\nindex e436714c6bdb..f6ca6793b4e4 100644\n--- a/src/qcam/viewfinder_qt.cpp\n+++ b/src/qcam/viewfinder_qt.cpp\n@@ -15,6 +15,7 @@\n #include <QMap>\n #include <QMutexLocker>\n #include <QPainter>\n+#include <QResizeEvent>\n #include <QtDebug>\n \n #include <libcamera/formats.h>\n@@ -34,7 +35,7 @@ static const QMap<libcamera::PixelFormat, QImage::Format> nativeFormats\n };\n \n ViewFinderQt::ViewFinderQt(QWidget *parent)\n-\t: QWidget(parent), buffer_(nullptr)\n+\t: QWidget(parent), place_(rect()), buffer_(nullptr)\n {\n \ticon_ = QIcon(\":camera-off.svg\");\n }\n@@ -146,7 +147,7 @@ void ViewFinderQt::paintEvent(QPaintEvent *)\n \n \t/* If we have an image, draw it. */\n \tif (!image_.isNull()) {\n-\t\tpainter.drawImage(rect(), image_, image_.rect());\n+\t\tpainter.drawImage(place_, image_, image_.rect());\n \t\treturn;\n \t}\n \n@@ -179,3 +180,17 @@ QSize ViewFinderQt::sizeHint() const\n {\n \treturn size_.isValid() ? size_ : QSize(640, 480);\n }\n+\n+void ViewFinderQt::resizeEvent(QResizeEvent *event)\n+{\n+\tif (!size_.isValid()) {\n+\t\tevent->accept();\n+\t\treturn;\n+\t}\n+\n+\tQPoint zero(0, 0);\n+\tplace_ = QRect(zero, size_.scaled(event->size(), Qt::KeepAspectRatio));\n+\tplace_.moveCenter(QRect(zero, size()).center());\n+\n+\tevent->accept();\n+}\ndiff --git a/src/qcam/viewfinder_qt.h b/src/qcam/viewfinder_qt.h\nindex d755428887c0..bf31b81b3437 100644\n--- a/src/qcam/viewfinder_qt.h\n+++ b/src/qcam/viewfinder_qt.h\n@@ -42,6 +42,7 @@ Q_SIGNALS:\n \n protected:\n \tvoid paintEvent(QPaintEvent *) override;\n+\tvoid resizeEvent(QResizeEvent *) override;\n \tQSize sizeHint() const override;\n \n private:\n@@ -49,6 +50,7 @@ private:\n \n \tlibcamera::PixelFormat format_;\n \tQSize size_;\n+\tQRect place_;\n \n \t/* Camera stopped icon */\n \tQSize vfSize_;\n", "prefixes": [ "libcamera-devel" ] }