Can I disable Safari's smooth image scaling?
I'd like to scale some pixel-art images up in-browser. Because they're pixel art it looks horrible if image smoothing happens.
In Fir开发者_开发技巧efox I can disable smoothing with "image-rendering:-moz-crisp-edges".
In IE there's "-ms-interpolation-mode:nearest-neighbor"... which is the default scaling mode anyway, mostly.
But I can't find a way to turn off smoothing in Safari for scaled images. Has anyone found a way to do this?
It doesn't look like there's anything equivalent in Safari/WebKit.
See bottom of this: https://developer.mozilla.org/en/CSS/image-rendering
I realize that this is an old question, but I had the same doubt and got here when looking for an answer had the same doubt and I will post the solution for anyone in the same position.
What seems to do the trick in Safari is drawing to a canvas whose context has this flag: ctx.webkitImageSmoothingEnabled = false;
For all variations of this flag see:https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/imageSmoothingEnabled
精彩评论