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
{{ message }}
Repository navigation
getImageData behaviour when bounds outside source canvas #1849
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.
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.
Activity
AugustGSP commentedon Nov 17, 2022
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.
getImageData fixes when rectangle is outside of canvas
getImageData fixes when rectangle is outside of canvas