From 04e8348ea557eb643ea45837ed4cac99ed453f4f Mon Sep 17 00:00:00 2001 From: Ben Wiley Sittler Date: Fri, 7 Nov 2008 04:31:04 +0000 Subject: [PATCH] fix yet another bug i wrote :( -- be endian-neutral. --- caca-php/php_caca.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/caca-php/php_caca.c b/caca-php/php_caca.c index 5481af8..8ae199d 100644 --- a/caca-php/php_caca.c +++ b/caca-php/php_caca.c @@ -382,12 +382,11 @@ void *gd_get_pixels(gdImage *img) { { for (i = 0; i < img->sy; i++) { for (j = 0; j < img->sx; j++) { - uint8_t *dst = ((uint8_t *) result) + i * pitch + j * sizeof(int); + int *dst = (int *) (((char *) result) + i * pitch + j * sizeof(int)); - dst[3] = 255 - (uint8_t) ((((uint32_t) img->tpixels[i][j]) & 0x7f000000) >> 23); - dst[2] = (((uint32_t) img->tpixels[i][j]) & 0x00ff0000) >> 16; - dst[1] = (((uint32_t) img->tpixels[i][j]) & 0x0000ff00) >> 8; - dst[0] = ((uint32_t) img->tpixels[i][j]) & 0x000000ff; + *dst = (((255 - (uint8_t) ((((uint32_t) img->tpixels[i][j]) & 0x7f000000) >> 23)) << 24) + | + (img->tpixels[i][j] & 0x00ffffff)); } } }