File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -1011,14 +1011,18 @@ Context2d::GetImageData(const Napi::CallbackInfo& info) {
10111011 sh = -sh;
10121012 }
10131013
1014+ // Width and height to actually copy
10141015 int cw = sw;
10151016 int ch = sh;
1017+ // Offsets in the destination image
10161018 int ox = 0 ;
10171019 int oy = 0 ;
10181020
1021+ // Clamp the copy width and height if the copy would go outside the image
10191022 if (sx + sw > width) cw = width - sx;
10201023 if (sy + sh > height) ch = height - sy;
10211024
1025+ // Clamp the copy origin if the copy would go outside the image
10221026 if (sx < 0 ) {
10231027 ox = -sx;
10241028 cw += sx;
@@ -1030,10 +1034,6 @@ Context2d::GetImageData(const Napi::CallbackInfo& info) {
10301034 sy = 0 ;
10311035 }
10321036
1033- // WebKit/moz functionality. node-canvas used to return in either case.
1034- if (sw <= 0 ) sw = 1 ;
1035- if (sh <= 0 ) sh = 1 ;
1036-
10371037 int srcStride = canvas->stride ();
10381038 int bpp = srcStride / width;
10391039 int size = sw * sh * bpp;
You can’t perform that action at this time.
0 commit comments