Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Olaf Mandel <o.mandel@menlosystems.com>
To: openembedded-core@lists.openembedded.org
Cc: Paul Eggleton <paul.eggleton@linux.intel.com>
Subject: [PATCH 1/2] Images: handle rowstride != width*bytes_per_pixel
Date: Tue, 07 Oct 2014 18:43:34 +0200	[thread overview]
Message-ID: <54341836.2070604@menlosystems.com> (raw)
In-Reply-To: <5433FB82.5010106@menlosystems.com>


[-- Attachment #1.1: Type: text/plain, Size: 2 bytes --]



[-- Attachment #1.2: 0001-Images-handle-rowstride-width-bytes_per_pixel.patch --]
[-- Type: text/plain, Size: 3591 bytes --]

From 0793aa7daf4b594fae1b412ab16a7d42d8c8560b Mon Sep 17 00:00:00 2001
From: Olaf Mandel <o.mandel@menlosystems.com>
Date: Tue, 7 Oct 2014 15:12:08 +0200
Subject: [PATCH 1/2] Images: handle rowstride != width*bytes_per_pixel

Up till now, image data with a rowstride larger than the value
expected from width and bytes_per_pixel caused a trapezoid
distortion of the displayed image.

Signed-off-by: Olaf Mandel <o.mandel@menlosystems.com>
---
 ChangeLog    |    7 +++++++
 psplash-fb.c |   13 +++++++------
 psplash-fb.h |    1 +
 psplash.c    |    2 ++
 4 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8cf2156..f4fd0ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2014-10-07  Olaf Mandel <o.mandel@menlosystems.com>
+
+	* psplash-fb.c:
+	* psplash-fb.h:
+	* psplash.c:
+	Images: handle rowstride != width*bytes_per_pixel
+
 2009-05-28  Richard Purdie <rpurdie@linux.intel.com>
 
 	* psplash-fb.c:
diff --git a/psplash-fb.c b/psplash-fb.c
index 71740cd..bd9cd9d 100644
--- a/psplash-fb.c
+++ b/psplash-fb.c
@@ -370,13 +370,14 @@ psplash_fb_draw_image (PSplashFB    *fb,
 		       int          img_width,
 		       int          img_height,
 		       int          img_bytes_per_pixel,
+		       int          img_rowstride,
 		       uint8       *rle_data)
 {
   uint8       *p = rle_data;
   int          dx = 0, dy = 0,  total_len;
   unsigned int len;
 
-  total_len = img_width * img_height * img_bytes_per_pixel;
+  total_len = img_rowstride * img_height;
 
   /* FIXME: Optimise, check for over runs ... */
   while ((p - rle_data) < total_len)
@@ -391,11 +392,11 @@ psplash_fb_draw_image (PSplashFB    *fb,
 
 	  do
 	    {
-	      if (img_bytes_per_pixel < 4 || *(p+3))
+	      if ((img_bytes_per_pixel < 4 || *(p+3)) && dx < img_width)
 	        psplash_fb_plot_pixel (fb, x+dx, y+dy, *(p), *(p+1), *(p+2));
-	      if (++dx >= img_width) { dx=0; dy++; }
+	      if (++dx * img_bytes_per_pixel >= img_rowstride) { dx=0; dy++; }
 	    }
-	  while (--len && (p - rle_data) < total_len);
+	  while (--len);
 
 	  p += img_bytes_per_pixel;
 	}
@@ -405,9 +406,9 @@ psplash_fb_draw_image (PSplashFB    *fb,
 
 	  do
 	    {
-	      if (img_bytes_per_pixel < 4 || *(p+3))
+	      if ((img_bytes_per_pixel < 4 || *(p+3)) && dx < img_width)
 	        psplash_fb_plot_pixel (fb, x+dx, y+dy, *(p), *(p+1), *(p+2));
-	      if (++dx >= img_width) { dx=0; dy++; }
+	      if (++dx * img_bytes_per_pixel >= img_rowstride) { dx=0; dy++; }
 	      p += img_bytes_per_pixel;
 	    }
 	  while (--len && (p - rle_data) < total_len);
diff --git a/psplash-fb.h b/psplash-fb.h
index ef5b39e..42592ed 100644
--- a/psplash-fb.h
+++ b/psplash-fb.h
@@ -82,6 +82,7 @@ psplash_fb_draw_image (PSplashFB    *fb,
 		       int          img_width, 
 		       int          img_height,
 		       int          img_bytes_pre_pixel,
+		       int          img_rowstride,
 		       uint8       *rle_data);
 
 void
diff --git a/psplash.c b/psplash.c
index 09cf0d0..543f67e 100644
--- a/psplash.c
+++ b/psplash.c
@@ -274,6 +274,7 @@ main (int argc, char** argv)
 			 POKY_IMG_WIDTH,
 			 POKY_IMG_HEIGHT,
 			 POKY_IMG_BYTES_PER_PIXEL,
+			 POKY_IMG_ROWSTRIDE,
 			 POKY_IMG_RLE_PIXEL_DATA);
 
   /* Draw progress bar border */
@@ -283,6 +284,7 @@ main (int argc, char** argv)
 			 BAR_IMG_WIDTH,
 			 BAR_IMG_HEIGHT,
 			 BAR_IMG_BYTES_PER_PIXEL,
+			 BAR_IMG_ROWSTRIDE,
 			 BAR_IMG_RLE_PIXEL_DATA);
 
   psplash_draw_progress (fb, 0);
-- 
1.7.10.4



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 499 bytes --]

       reply	other threads:[~2014-10-07 16:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <5433FB82.5010106@menlosystems.com>
2014-10-07 16:43 ` Olaf Mandel [this message]
     [not found] <mailman.3924.1412700227.1406.openembedded-core@lists.openembedded.org>
2014-10-07 16:57 ` [PATCH 1/2] Images: handle rowstride != width*bytes_per_pixel Olaf Mandel

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=54341836.2070604@menlosystems.com \
    --to=o.mandel@menlosystems.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=paul.eggleton@linux.intel.com \
    /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