|
@ -419,8 +419,8 @@ Context2d::PutImageData(const Arguments &args) { |
|
|
, sy = 0 |
|
|
, sy = 0 |
|
|
, sw = 0 |
|
|
, sw = 0 |
|
|
, sh = 0 |
|
|
, sh = 0 |
|
|
, dx = args[1]->NumberValue() |
|
|
, dx = args[1]->Int32Value() |
|
|
, dy = args[2]->NumberValue() |
|
|
, dy = args[2]->Int32Value() |
|
|
, rows |
|
|
, rows |
|
|
, cols; |
|
|
, cols; |
|
|
|
|
|
|
|
@ -432,10 +432,10 @@ Context2d::PutImageData(const Arguments &args) { |
|
|
break; |
|
|
break; |
|
|
// imageData, dx, dy, sx, sy, sw, sh
|
|
|
// imageData, dx, dy, sx, sy, sw, sh
|
|
|
case 7: |
|
|
case 7: |
|
|
sx = args[3]->NumberValue(); |
|
|
sx = args[3]->Int32Value(); |
|
|
sy = args[4]->NumberValue(); |
|
|
sy = args[4]->Int32Value(); |
|
|
sw = args[5]->NumberValue(); |
|
|
sw = args[5]->Int32Value(); |
|
|
sh = args[6]->NumberValue(); |
|
|
sh = args[6]->Int32Value(); |
|
|
if (sx < 0) sw += sx, sx = 0; |
|
|
if (sx < 0) sw += sx, sx = 0; |
|
|
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; |
|
@ -520,26 +520,26 @@ Context2d::DrawImage(const Arguments &args) { |
|
|
switch (args.Length()) { |
|
|
switch (args.Length()) { |
|
|
// img, sx, sy, sw, sh, dx, dy, dw, dh
|
|
|
// img, sx, sy, sw, sh, dx, dy, dw, dh
|
|
|
case 9: |
|
|
case 9: |
|
|
sx = args[1]->NumberValue(); |
|
|
sx = args[1]->Int32Value(); |
|
|
sy = args[2]->NumberValue(); |
|
|
sy = args[2]->Int32Value(); |
|
|
sw = args[3]->NumberValue(); |
|
|
sw = args[3]->Int32Value(); |
|
|
sh = args[4]->NumberValue(); |
|
|
sh = args[4]->Int32Value(); |
|
|
dx = args[5]->NumberValue(); |
|
|
dx = args[5]->Int32Value(); |
|
|
dy = args[6]->NumberValue(); |
|
|
dy = args[6]->Int32Value(); |
|
|
dw = args[7]->NumberValue(); |
|
|
dw = args[7]->Int32Value(); |
|
|
dh = args[8]->NumberValue(); |
|
|
dh = args[8]->Int32Value(); |
|
|
break; |
|
|
break; |
|
|
// img, dx, dy, dw, dh
|
|
|
// img, dx, dy, dw, dh
|
|
|
case 5: |
|
|
case 5: |
|
|
dx = args[1]->NumberValue(); |
|
|
dx = args[1]->Int32Value(); |
|
|
dy = args[2]->NumberValue(); |
|
|
dy = args[2]->Int32Value(); |
|
|
dw = args[3]->NumberValue(); |
|
|
dw = args[3]->Int32Value(); |
|
|
dh = args[4]->NumberValue(); |
|
|
dh = args[4]->Int32Value(); |
|
|
break; |
|
|
break; |
|
|
// img, dx, dy
|
|
|
// img, dx, dy
|
|
|
case 3: |
|
|
case 3: |
|
|
dx = args[1]->NumberValue(); |
|
|
dx = args[1]->Int32Value(); |
|
|
dy = args[2]->NumberValue(); |
|
|
dy = args[2]->Int32Value(); |
|
|
dw = img->width; |
|
|
dw = img->width; |
|
|
dh = img->height; |
|
|
dh = img->height; |
|
|
break; |
|
|
break; |
|
@ -561,8 +561,8 @@ Context2d::DrawImage(const Arguments &args) { |
|
|
|
|
|
|
|
|
// Scale src
|
|
|
// Scale src
|
|
|
if (dw != sw || dh != sh) { |
|
|
if (dw != sw || dh != sh) { |
|
|
double fx = (double) dw / sw; |
|
|
float fx = (float) dw / sw; |
|
|
double fy = (double) dh / sh; |
|
|
float fy = (float) dh / sh; |
|
|
cairo_scale(ctx, fx, fy); |
|
|
cairo_scale(ctx, fx, fy); |
|
|
dx /= fx; |
|
|
dx /= fx; |
|
|
dy /= fy; |
|
|
dy /= fy; |
|
|