From 27ae323c8deba990e531e8aff2a61eb410f90384 Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Mon, 15 Nov 2010 14:23:04 -0800 Subject: [PATCH] Fixed source x/y support for getImageData() --- src/CanvasRenderingContext2d.cc | 2 +- src/PixelArray.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CanvasRenderingContext2d.cc b/src/CanvasRenderingContext2d.cc index a11d3c2..5f6cd5b 100644 --- a/src/CanvasRenderingContext2d.cc +++ b/src/CanvasRenderingContext2d.cc @@ -408,7 +408,7 @@ Context2d::PutImageData(const Arguments &args) { , dw = arr->width() , dh = arr->height(); - uint8_t *srcRows = src + sy + srcStride + sx * 4; + uint8_t *srcRows = src; for (int y = 0; y < dh; ++y) { uint32_t *row = (uint32_t *)(dst + dstStride * (y + dy)); for (int x = 0; x < dw; ++x) { diff --git a/src/PixelArray.cc b/src/PixelArray.cc index 0c98bae..fb83eef 100644 --- a/src/PixelArray.cc +++ b/src/PixelArray.cc @@ -90,10 +90,10 @@ 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 *row = (uint32_t *)(src + srcStride * y); + uint32_t *row = (uint32_t *)(src + srcStride * (y + sy)); for (int x = 0; x < width; ++x) { int bx = x * 4; - uint32_t *pixel = row + x; + uint32_t *pixel = row + x + sx; // ARGB uint8_t a = *pixel >> 24;