[Pixman] [PATCH] utils.c: Make print_image actually cope with negative strides
Søren Sandmann
sandmann at cs.au.dk
Thu Sep 19 23:45:32 PDT 2013
From: Søren Sandmann Pedersen <ssp at redhat.com>
Commit 4312f077365bf9f59423b1694136089c6da6216b claimed to have made
print_image() work with negative strides, but it didn't actually
work. When the stride was negative, the image buffer would be accesses
as if the stride was positive.
Fix the bug by not changing the stride variable and instead use a
temporary, s, that contains the absolute value of stride.
---
test/utils.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/test/utils.c b/test/utils.c
index 3400747..a83fc06 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -251,6 +251,7 @@ print_image (pixman_image_t *image)
int width, height, stride;
pixman_format_code_t format;
uint8_t *buffer;
+ int s;
width = pixman_image_get_width (image);
height = pixman_image_get_height (image);
@@ -258,13 +259,12 @@ print_image (pixman_image_t *image)
format = pixman_image_get_format (image);
buffer = (uint8_t *)pixman_image_get_data (image);
- if (stride < 0)
- stride = - stride;
+ s = (stride >= 0)? stride : - stride;
printf ("---\n");
for (i = 0; i < height; i++)
{
- for (j = 0; j < stride; j++)
+ for (j = 0; j < s; j++)
{
if (j == (width * PIXMAN_FORMAT_BPP (format) + 7) / 8)
printf ("| ");
--
1.7.1
More information about the Pixman
mailing list