You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it must return an ImageData object representing the underlying pixel data for the area of the canvas denoted by the rectangle whose corners are the four points (sx, sy), (sx+sw, sy), (sx+sw, sy+sh), (sx, sy+sh), in canvas coordinate space units. Pixels outside the canvas must be returned as transparent black.
As a result, I would expect that if I had a canvas size 500x500 filled black, and called getImageData(100,100,1000,1000), I would receive an ImageData object of size 1000x1000, with the top-left 400x400 opaque black and the remainder transparent black. Instead, in node-canvas, the bounds of the result are contained by the bounds of the canvas I'm calling getImageData on, and so I would receive an ImageData 400x400 of opaque black.
The text was updated successfully, but these errors were encountered:
Yep seeing the same thing, the imagedata gets cropped even though it shouldn't.
My hacky workaround is to make the canvas larger than it needs to be, i.e adding the overflow as additional "padding" on the canvas, then cropping it to get the final image + imagedata. Would be nice if this wasn't necessary though.
fix a crash in getImageData if the rectangle is outside the canvas
return transparent black pixels when getting image data outside the canvas
remove dead code, add comments
Fixes#2024Fixes#1849
https://www.w3.org/TR/2dcontext/#pixel-manipulation
Per spec, for getImageData(sx, sy, sw, sh):
As a result, I would expect that if I had a canvas size 500x500 filled black, and called getImageData(100,100,1000,1000), I would receive an ImageData object of size 1000x1000, with the top-left 400x400 opaque black and the remainder transparent black. Instead, in node-canvas, the bounds of the result are contained by the bounds of the canvas I'm calling getImageData on, and so I would receive an ImageData 400x400 of opaque black.
The text was updated successfully, but these errors were encountered: