From patchwork Fri Oct 3 16:55:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 493 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759510598; bh=8ohRtP0h47iRZ+Qozds+YgL+kcC3M+KrEBzt93g0vdQ=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=onduiPGrqUde6UmrRqukADRMk7uutzzKvU5Esm/4otvFQLcH6/QJ7IOdqJw+btwTl 4zSfmjh+thhFHB5fveUMe5Slr2PZv2ckTvvSXOdbx9SVhY/Z0kVp6+QDQ5LOt+gUBF 128flTh9AUgztzM9ZnZHJd18T7c8ZdUKPHQWbWEpCRY2HFhmhxhWmyJYnxI1aLj/8G uE9g8pCuXx+2MtUbkkt8Q1QEsQyrIUsqn3RFtzXctOGwinbXtSlBGfQYTlzKqeHqIj DeThtB8KIE0RROSQAscxTWe2oF6NaeZKo4cnBEiU/tTEU5vPlIflnLZBLFGratwdkT 1PtQoY8Qv7IUA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CF9BC67F47 for ; Fri, 3 Oct 2025 10:56:38 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id aG-ZrJAAC56i for ; Fri, 3 Oct 2025 10:56:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759510597; bh=8ohRtP0h47iRZ+Qozds+YgL+kcC3M+KrEBzt93g0vdQ=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=HlLnBTAaNlTXu6cRyGoCqsttpl1ihvo0a2GW8NCxwuM9+IScDB32vNimwGM+ypToJ aKnml6+alB344kAJ46gE5omHvarr1EQVePR76j1sH1sGiYgtmAo8r8V7g1tr7tMNvY kr6mEKJHcJ5X6VsBrn/2PlkKXxjBAoJ4IPgrF/A0Elo37sOb6s2MeLELJ6NncuXT8Q hAZM+xZLGGLlKh1TGylfALP3oWLqtNxLYntveNrsc0KD1+9u9Z8j/wKoxxyemNj7AC 3abqHlEIPKiRFa1g+vMub+idemJvd7XncLFbA5L2RFGaqjg3iuikh2cJOuZICWxg/a MX3hHTs1pUyiQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0054C67F4C for ; Fri, 3 Oct 2025 10:56:36 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759510595; bh=TjJOlQtf0fNvCJDCUjgJxOAtWAy2iIjkVyPW/gCXsBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vdS8+TqCMmYDeRGEINHhLbOzULcnlKGon1gjtICZAYSLGssLCt/lKJHspl67WHigz /sWfb+zVbDD4zvnJGxjx65VMtgmFyVfqzHql5n464PtoBMwhhf3oxJ4Gz4/b5ogtnI yLzVJVEO5+4bXFLFQpraCxiT3F6KeicGtjTrBBbLFqAUNucVcEyyyNN1xGCXdT/CPM MY6WhSLXoOULBs5BRj9GMB5nL3NX6SBeam9NbOMAFHUbFgb7cpbHgb5BDJ+BJnubZN 4MytXaLSVZ093Y3SGRc9+qen7jyHx1k7eZJQw6Cj1DiYe/7Rso/4FRmRrdd6veMPWE yt4Dul1JZ2uNQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1B35B67E12; Fri, 3 Oct 2025 10:56:35 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 4veYiLj5PryY; Fri, 3 Oct 2025 10:56:35 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759510591; bh=cXMOETEA6bgMjYWQzgHQNF+PBRsIAhdUU2YHNFe6osg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wcNm13nPpzxfrnirr8KTNUfHaNhiGGJkpdrhbMuReLBq5lOYInK95OWmfiLGpkVsC UYYqLlPxqvYJ/ZDKNhtFhvBRfC27UA0UxhOaYQpWYuaxiFLv+jhJTj1y+XeY0lP5sx E+dLMLsHJtyPLi8WPbbR7WozRl1TIWw8NO6O2thY6X/kVD9yYIXuHcd9GznRBS3KFE +EccqW0YdrkOo8dkxIj3ejdAWq5rMPa0DiJJAYe/BlXQcTzYDMFs1v0R4H1tpr/tlG +fZ/BTLYV/0+wFJX3DVg/S9uFv7pD4QjHzwQl1P4/vwJndZGQKjnLhNGkIHSZgwGdY GTbgo/BpEGrjg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id C470367E7C; Fri, 3 Oct 2025 10:56:30 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 3 Oct 2025 10:55:05 -0600 Message-ID: <20251003165525.440173-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251003165525.440173-1-sjg@u-boot.org> References: <20251003165525.440173-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: GQV6R3UHZ7OQRLW3GWKS55CWPABQTYQC X-Message-ID-Hash: GQV6R3UHZ7OQRLW3GWKS55CWPABQTYQC X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 12/22] video: Support transparency with BMP palette List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Check the palette entry against the transparency colour and skip writing it to the display if it matches. Signed-off-by: Simon Glass --- drivers/video/video_bmp.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c index 9c9d9b2091b..ebdf73e25a9 100644 --- a/drivers/video/video_bmp.c +++ b/drivers/video/video_bmp.c @@ -53,6 +53,20 @@ static u32 get_bmp_col_rgba8888(struct bmp_color_table_entry *cte) (cte->blue << 16U) | 0xff << 24U); } +/** + * matches_alpha() - Check if a palette entry matches the alpha color + * + * @ent: BMP palette entry + * @col: Alpha color to compare (RGB888 format) + * Return: true if the palette entry matches the alpha color + */ +static bool matches_alpha(struct bmp_color_table_entry *ent, u32 col) +{ + u32 colour = (ent->red << 16) | (ent->green << 8) | ent->blue; + + return colour == col; +} + /** * write_pix8() - Write a pixel from a BMP image into the framebuffer * @@ -73,6 +87,10 @@ static void write_pix8(u8 *fb, uint bpix, enum video_format eformat, { struct bmp_color_table_entry *cte = &palette[*bmap]; + /* Check for transparent pixel */ + if (alpha && matches_alpha(cte, acol)) + return; + if (bpix == 8) { *fb++ = *bmap; } else if (bpix == 16) {