summaryrefslogtreecommitdiff
path: root/test/any2ppm.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-11-07 18:35:39 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2008-11-07 19:35:26 +0000
commitcd2e18ddc65959a736fc7b7f6bbd3e76af0495a9 (patch)
tree3e90f40d2340bc29271c0f32600568b7e855de62 /test/any2ppm.c
parent2554d1759835a174b89107808d81d044c3e2e098 (diff)
downloadcairo-cd2e18ddc65959a736fc7b7f6bbd3e76af0495a9.tar.gz
[test] Fix-up rgb byte packing
Another embarrassing, but thankfully, trivial bug.
Diffstat (limited to 'test/any2ppm.c')
-rw-r--r--test/any2ppm.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/test/any2ppm.c b/test/any2ppm.c
index 94450b2f9..85c1bdbb6 100644
--- a/test/any2ppm.c
+++ b/test/any2ppm.c
@@ -184,26 +184,30 @@ write_ppm (cairo_surface_t *surface, int fd)
len = sprintf (buf, "%s %d %d 255\n", format_str, width, height);
for (j = 0; j < height; j++) {
- const unsigned char *row = data + stride * j;
+ const unsigned int *row = (unsigned int *) (data + stride * j);
switch ((int) format) {
case CAIRO_FORMAT_ARGB32:
len = _write (fd,
buf, sizeof (buf), len,
- row, 4 * width);
+ (unsigned char *) row, 4 * width);
break;
case CAIRO_FORMAT_RGB24:
for (i = 0; i < width; i++) {
+ unsigned char rgb[3];
+ unsigned int p = *row++;
+ rgb[0] = (p & 0xff0000) >> 16;
+ rgb[1] = (p & 0x00ff00) >> 8;
+ rgb[2] = (p & 0x0000ff) >> 0;
len = _write (fd,
buf, sizeof (buf), len,
- row, 3);
- row += 4;
+ rgb, 3);
}
break;
case CAIRO_FORMAT_A8:
len = _write (fd,
buf, sizeof (buf), len,
- row, width);
+ (unsigned char *) row, width);
break;
}
if (len < 0)