From: "Michael D. Burkey" <mdburkey@gmail.com>
To: barebox@lists.infradead.org
Subject: [PATCH 1/1] Correct BMP renderer to support arbitrary sized files in Microsoft BMP format.
Date: Thu, 8 May 2014 14:48:54 -0400 [thread overview]
Message-ID: <CAO6XYUtOCoUBi4CC=WUO2oukJC1ORGJU49JUdtrnpOEh9taqpw@mail.gmail.com> (raw)
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 <mdburkey at gmail.com>
---
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
reply other threads:[~2014-05-08 18:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAO6XYUtOCoUBi4CC=WUO2oukJC1ORGJU49JUdtrnpOEh9taqpw@mail.gmail.com' \
--to=mdburkey@gmail.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox