From e97407561d66bf0aa4d02905e0b2693455b34a6b Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Mon, 16 Jun 2008 16:25:58 -0700 Subject: fixed ximage() --- src/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index cad5085..e67792f 100644 --- a/src/main.c +++ b/src/main.c @@ -77,13 +77,13 @@ XImage *ximage(struct image *img, int width, int height) { bshift = getshift(vis->blue_mask); if (depth >= 24) { - size_t numNewBufBytes = (4 * (width * height)); + size_t numNewBufBytes = (4 * width * height); u_int32_t *newBuf = malloc(numNewBufBytes); for(y = 0; y < height; y++){ for(x = 0; x < width; x++){ unsigned int r, g, b; - i = ((y * img->height / height + x) * img->width / width) * 3; + i = (y * img->height / height * img->width + x * img->width / width) * 3; r = (img->buf[i++] << rshift) & vis->red_mask; g = (img->buf[i++] << gshift) & vis->green_mask; b = (img->buf[i++] << bshift) & vis->blue_mask; @@ -106,7 +106,7 @@ XImage *ximage(struct image *img, int width, int height) { for(y = 0; y < height; y++){ for(x = 0; x < width; x++){ unsigned int r, g, b; - i = ((y * img->height / height + x) * img->width / width) * 3; + i = (y * img->height / height * img->width + x * img->width / width) * 3; r = (img->buf[i++] << rshift) & vis->red_mask; g = (img->buf[i++] << gshift) & vis->green_mask; b = (img->buf[i++] << bshift) & vis->blue_mask; -- cgit v1.2.3