diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2008-11-07 18:35:39 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2008-11-07 19:35:26 +0000 |
commit | cd2e18ddc65959a736fc7b7f6bbd3e76af0495a9 (patch) | |
tree | 3e90f40d2340bc29271c0f32600568b7e855de62 /test/any2ppm.c | |
parent | 2554d1759835a174b89107808d81d044c3e2e098 (diff) | |
download | cairo-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.c | 14 |
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) |