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
When using context.drawImage() with a slice of an image as the source, and then scaling the result up occasionally results in areas outside the slice being included in the final output. Changing the scaling factor can change the position of or remove these issues. (Try a scaling factor of 24 or 30 in the example below and see how the issue goes away).
In this example, the expected output vs. actual output (notice the 1px line at the top, which is from the character above in the supplied sprite sheet):
While I'm not able to verify this, I think the entire imaged might be shifted by 1px when this artifact is included.
Also note that many, but not all characters experience this issue. Some include lines on the bottom and others on the top.
constfs=require('fs');constpath=require('path');const{ createCanvas, Image }=require('canvas');constSCALING=27;constSIDE_LENGTH=8;constimage=newImage();image.onload=()=>{constcanvas=createCanvas(250,250);constctx=canvas.getContext('2d');ctx.imageSmoothingEnabled=false;ctx.drawImage(image,15*SIDE_LENGTH,// This is \udf3661*SIDE_LENGTH,// This is \udf36SIDE_LENGTH,SIDE_LENGTH,0,0,SIDE_LENGTH*SCALING,SIDE_LENGTH*SCALING);canvas.createPNGStream().pipe(fs.createWriteStream(path.join(__dirname,'df36.png')));};image.src=path.resolve(__dirname,'nonlatin_european.png');
Your Environment
Version of node-canvas: 2.10.2
Environment: node v20.12.0 on Windows 10
The text was updated successfully, but these errors were encountered:
Issue or Feature
When using
context.drawImage()
with a slice of an image as the source, and then scaling the result up occasionally results in areas outside the slice being included in the final output. Changing the scaling factor can change the position of or remove these issues. (Try a scaling factor of24
or30
in the example below and see how the issue goes away).In this example, the expected output vs. actual output (notice the 1px line at the top, which is from the character above in the supplied sprite sheet):
While I'm not able to verify this, I think the entire imaged might be shifted by 1px when this artifact is included.
Also note that many, but not all characters experience this issue. Some include lines on the bottom and others on the top.
Steps to Reproduce
Place the nonlatin_european.png in the directory and run the following code:
Your Environment
2.10.2
v20.12.0
on Windows 10The text was updated successfully, but these errors were encountered: