From 9c0e79fef3e0fc32e7ee7df23f75d123edebca00 Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Mon, 15 Nov 2010 12:33:13 -0800 Subject: [PATCH] Fixed PixelArray constructor --- src/PixelArray.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/PixelArray.cc b/src/PixelArray.cc index d5d0c85..37c7301 100644 --- a/src/PixelArray.cc +++ b/src/PixelArray.cc @@ -90,19 +90,18 @@ PixelArray::PixelArray(Canvas *canvas, int sx, int sy, int width, int height): // Normalize data (argb -> rgba) for (int y = 0; y < height; ++y) { uint32_t *srcRow = (uint32_t *)(src + _stride * y); - uint32_t *dstRow = (uint32_t *)(dst + _stride * y); for (int x = 0; x < width; ++x) { + int bx = x * 4; uint32_t *pixel = srcRow + x; - uint32_t *dstPixel = dstRow + x; // premultiplied uint8_t a = *pixel >> 24; - uint8_t r = (*pixel >> 16) * 255 / a; - uint8_t g = (*pixel >> 8) * 255 / a; - uint8_t b = *pixel * 255 / a; - - printf("rgba(%d,%d,%d,%d)\n", r,g,b,a); + dst[bx + 3] = a; + dst[bx + 0] = (*pixel >> 16) * 255 / a; + dst[bx + 1] = (*pixel >> 8) * 255 / a; + dst[bx + 2] = *pixel * 255 / a; } + dst += _stride; } }