From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-ig0-x22e.google.com ([2607:f8b0:4001:c05::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WiTNb-0005in-F7 for barebox@lists.infradead.org; Thu, 08 May 2014 18:49:15 +0000 Received: by mail-ig0-f174.google.com with SMTP id h3so166035igd.1 for ; Thu, 08 May 2014 11:48:54 -0700 (PDT) MIME-Version: 1.0 Date: Thu, 8 May 2014 14:48:54 -0400 Message-ID: From: "Michael D. Burkey" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH 1/1] Correct BMP renderer to support arbitrary sized files in Microsoft BMP format. To: barebox@lists.infradead.org This patch allows barebox to properly load and display BMP files of any arbitrary size that are generated by most common image editing packages (e.g. Microsoft Paint, GIMP, etc). The standard Microsoft BMP format always packs each line of data to a 32-bit boundary (which means from 0-3 bytes may be unused at the end of each line). Without this patch, any BMP image with a width that does not result in a fully packed 32-bit data field at the end of each line will be displayed incorrectly. Signed-off-by: Michael Burkey --- diff -rupN a/lib/gui/bmp.c b/lib/gui/bmp.c --- a/lib/gui/bmp.c 2014-05-05 04:33:13.000000000 -0400 +++ b/lib/gui/bmp.c 2014-05-08 13:48:17.448986921 -0400 @@ -77,7 +77,7 @@ static int bmp_renderer(struct screen *s for (y = 0; y < height; y++) { image = (char *)bmp + le32_to_cpu(bmp->header.data_offset); - image += (img->height - y - 1) * img->width * (bits_per_pixel >> 3); + image += (img->height - y - 1) * (((img->width * bits_per_pixel + 31) >> 5) << 2); adr = buf + (y + starty) * sc->info.line_length + startx * (sc->info.bits_per_pixel >> 3); for (x = 0; x < width; x++) { @@ -99,7 +99,7 @@ static int bmp_renderer(struct screen *s for (y = 0; y < height; y++) { image = (char *)bmp + le32_to_cpu(bmp->header.data_offset); - image += (img->height - y - 1) * img->width * (bits_per_pixel >> 3); + image += (img->height - y - 1) * (((img->width * bits_per_pixel + 31) >> 5) << 2); adr = buf + (y + starty) * sc->info.line_length + startx * (sc->info.bits_per_pixel >> 3); for (x = 0; x < width; x++) { _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox