|
@ -523,8 +523,8 @@ NAN_METHOD(Context2d::PutImageData) { |
|
|
switch (args.Length()) { |
|
|
switch (args.Length()) { |
|
|
// imageData, dx, dy
|
|
|
// imageData, dx, dy
|
|
|
case 3: |
|
|
case 3: |
|
|
cols = arr->width(); |
|
|
cols = std::min(arr->width(), context->canvas()->width - dx); |
|
|
rows = arr->height(); |
|
|
rows = std::min(arr->height(), context->canvas()->height - dy); |
|
|
break; |
|
|
break; |
|
|
// imageData, dx, dy, sx, sy, sw, sh
|
|
|
// imageData, dx, dy, sx, sy, sw, sh
|
|
|
case 7: |
|
|
case 7: |
|
@ -536,16 +536,17 @@ NAN_METHOD(Context2d::PutImageData) { |
|
|
if (sy < 0) sh += sy, sy = 0; |
|
|
if (sy < 0) sh += sy, sy = 0; |
|
|
if (sx + sw > arr->width()) sw = arr->width() - sx; |
|
|
if (sx + sw > arr->width()) sw = arr->width() - sx; |
|
|
if (sy + sh > arr->height()) sh = arr->height() - sy; |
|
|
if (sy + sh > arr->height()) sh = arr->height() - sy; |
|
|
if (sw <= 0 || sh <= 0) NanReturnUndefined(); |
|
|
|
|
|
cols = sw; |
|
|
|
|
|
rows = sh; |
|
|
|
|
|
dx += sx; |
|
|
dx += sx; |
|
|
dy += sy; |
|
|
dy += sy; |
|
|
|
|
|
cols = std::min(sw, context->canvas()->width - dx); |
|
|
|
|
|
rows = std::min(sh, context->canvas()->height - dy); |
|
|
break; |
|
|
break; |
|
|
default: |
|
|
default: |
|
|
return NanThrowError("invalid arguments"); |
|
|
return NanThrowError("invalid arguments"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (cols <= 0 || rows <= 0) NanReturnUndefined(); |
|
|
|
|
|
|
|
|
uint8_t *srcRows = src + sy * srcStride + sx * 4; |
|
|
uint8_t *srcRows = src + sy * srcStride + sx * 4; |
|
|
for (int y = 0; y < rows; ++y) { |
|
|
for (int y = 0; y < rows; ++y) { |
|
|
uint32_t *row = (uint32_t *)(dst + dstStride * (y + dy)); |
|
|
uint32_t *row = (uint32_t *)(dst + dstStride * (y + dy)); |
|
|