Here is a .png image (on the right), and the canvas element which I drew the image on (on the left). Can you notice the quality difference? Canvas renders the image with noticeable quality loss. What can we do?
I observed this result on Chrome and IE9. Others will probably do the same thing.
How I render the image is quite usual: In the script I create a new Image()
object, after it's loaded I call
context.drawImage(myimage, x, y);
![Right: What I want, Left: What I get](https://i.stack.imgur.com/KLSHN.png)
EDIT:
This is the initial image i observed on the canvas:
![In more detail: What I got first](https://i.stack.imgur.com/6TGfk.png)
And here's what the canvas renders after I wrote:
context.drawImage(myimage,parseInt(x),parseInt(y));
![In more detail: What I get with rounded coordinates](https://i.stack.imgur.com/NRrMk.png)
What can I say, great answer man. Sharpshooting at its best. The hat is off to you.
EDIT2:
I tried context.drawImage(myimage, parseInt(x) + 0.5, parseInt(y)+ 0.5);
, here's the result:
![In more detail: Worst case](https://i.stack.imgur.com/hfRVu.png)
I think it's worse than the first one. I observed this on chrome, on IE9 it's somewhat same as bad.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…