Browse Source

Fixed source x/y support for getImageData()

v1.x
Tj Holowaychuk 14 years ago
parent
commit
27ae323c8d
  1. 2
      src/CanvasRenderingContext2d.cc
  2. 4
      src/PixelArray.cc

2
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) {

4
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;

Loading…
Cancel
Save