Patch Detail
Show a patch.
GET /api/1.1/patches/23854/?format=api
{ "id": 23854, "url": "https://patchwork.libcamera.org/api/1.1/patches/23854/?format=api", "web_url": "https://patchwork.libcamera.org/patch/23854/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20250718144456.58625-1-mzamazal@redhat.com>", "date": "2025-07-18T14:44:55", "name": "[1/2] libcamera: geometry: Add Rectangle::croppedBy", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "8c64388987dd1a26bdb4dacb5bf1664c1ad8f3ec", "submitter": { "id": 177, "url": "https://patchwork.libcamera.org/api/1.1/people/177/?format=api", "name": "Milan Zamazal", "email": "mzamazal@redhat.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/23854/mbox/", "series": [ { "id": 5301, "url": "https://patchwork.libcamera.org/api/1.1/series/5301/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5301", "date": "2025-07-18T14:44:55", "name": "[1/2] libcamera: geometry: Add Rectangle::croppedBy", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5301/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/23854/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/23854/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 79561BE175\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 18 Jul 2025 14:45:07 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2313968FA9;\n\tFri, 18 Jul 2025 16:45:07 +0200 (CEST)", "from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4F9E06150F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 18 Jul 2025 16:45:04 +0200 (CEST)", "from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com\n\t(ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97])\n\tby relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n\tcipher=TLS_AES_256_GCM_SHA384) id us-mta-37-IpKdcSQuPwm0Cuk2PbsrfA-1;\n\tFri, 18 Jul 2025 10:45:01 -0400", "from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com\n\t(mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com\n\t[10.30.177.111])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS id 7FFEA1800295; Fri, 18 Jul 2025 14:45:00 +0000 (UTC)", "from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.45.224.221])\n\tby mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id 0742E18016F9; Fri, 18 Jul 2025 14:44:58 +0000 (UTC)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"LEBzIl2X\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1752849903;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding;\n\tbh=qT/UBPjhhcJev+ryH481zvijqJFqDwbKqTE5d9NJD+k=;\n\tb=LEBzIl2X1sgHK/hMF4TjLj/SfEFSeRtDWaZx9+FZywK33yLUcNHs59h3xUGQWUMOTWAHkZ\n\tHjq8s1pf3IyXyyNGh0cKn3+TJiArCoMwW0wOiP9+XN32BrgoXYeOH/z5SlBi5bVeptygz9\n\tlKfP2gYvvBJk1dMWHvT2JqQHJlCz2ik=", "X-MC-Unique": "IpKdcSQuPwm0Cuk2PbsrfA-1", "X-Mimecast-MFC-AGG-ID": "IpKdcSQuPwm0Cuk2PbsrfA_1752849900", "From": "Milan Zamazal <mzamazal@redhat.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Milan Zamazal <mzamazal@redhat.com>,\n\tBryan O'Donoghue <bryan.odonoghue@linaro.org>", "Subject": "[PATCH 1/2] libcamera: geometry: Add Rectangle::croppedBy", "Date": "Fri, 18 Jul 2025 16:44:55 +0200", "Message-ID": "<20250718144456.58625-1-mzamazal@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 3.4.1 on 10.30.177.111", "X-Mimecast-Spam-Score": "0", "X-Mimecast-MFC-PROC-ID": "pFajDI99eBJWmU4gUYrrZqDLEqI3ENsYJsbMCC1TT5E_1752849900", "X-Mimecast-Originator": "redhat.com", "Content-Transfer-Encoding": "8bit", "content-type": "text/plain; charset=\"US-ASCII\"; x-default=true", "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>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Let's add a new Rectangle method that returns the coordinates of the\ncentral area of the original rectangle cropped by given\nnumerator/denominator fraction. This is useful to specify a limited\narea of the image to operate on, for example computing statistics only\nfrom a reduced area for speedup.\n\nSigned-off-by: Milan Zamazal <mzamazal@redhat.com>\n---\n include/libcamera/geometry.h | 2 ++\n src/libcamera/geometry.cpp | 18 ++++++++++++++++++\n 2 files changed, 20 insertions(+)", "diff": "diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h\nindex f322e3d5b..603c9a117 100644\n--- a/include/libcamera/geometry.h\n+++ b/include/libcamera/geometry.h\n@@ -297,6 +297,8 @@ public:\n \t[[nodiscard]] Rectangle scaledBy(const Size &numerator,\n \t\t\t\t\t const Size &denominator) const;\n \t[[nodiscard]] Rectangle translatedBy(const Point &point) const;\n+\t[[nodiscard]] Rectangle croppedBy(const unsigned int numerator,\n+\t\t\t\t\t const unsigned int denominator) const;\n \n \tRectangle transformedBetween(const Rectangle &source,\n \t\t\t\t const Rectangle &target) const;\ndiff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp\nindex 81cc8cd53..8c1b156c5 100644\n--- a/src/libcamera/geometry.cpp\n+++ b/src/libcamera/geometry.cpp\n@@ -837,6 +837,24 @@ Rectangle Rectangle::translatedBy(const Point &point) const\n \treturn { x + point.x, y + point.y, width, height };\n }\n \n+/**\n+ * \\brief Return a central area crop of the rectangle\n+ * \\param[in] numerator The numerator of the crop factor\n+ * \\param[in] denominator The denominator of the crop factor\n+ *\n+ * The rectangle of the central part of the original rectangle is computed, of\n+ * numerator/denominator times the original width and height.\n+ *\n+ * \\return The cropped Rectangle coordinates\n+ */\n+Rectangle Rectangle::croppedBy(const unsigned int numerator,\n+\t\t\t const unsigned int denominator) const\n+{\n+\tconst unsigned int w = numerator * width / denominator;\n+\tconst unsigned int h = numerator * height / denominator;\n+\treturn Rectangle((width - w) / 2, (height - h) / 2, w, h);\n+}\n+\n /**\n * \\brief Transform a Rectangle from one reference rectangle to another\n * \\param[in] source The \\a source reference rectangle\n", "prefixes": [ "1/2" ] }