mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/1] Correct BMP renderer to support arbitrary sized files in Microsoft BMP format.
@ 2014-05-08 18:48 Michael D. Burkey
  0 siblings, 0 replies; only message in thread
From: Michael D. Burkey @ 2014-05-08 18:48 UTC (permalink / raw)
  To: barebox

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-05-08 18:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-08 18:48 [PATCH 1/1] Correct BMP renderer to support arbitrary sized files in Microsoft BMP format Michael D. Burkey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox