在缩放图像时禁用抗锯齿 [英] Disable antialising when scaling images

查看:782
本文介绍了在缩放图像时禁用抗锯齿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:



http://updates.html5rocks.com/2015/01/pixelated



GitaarLAB


Possible Duplicate:
How to stretch images with no antialiasing

Is it in any way possible to disable antialiasing when scaling up an image ?

Right now, i get something that looks like this :

Using the following css code :

#bib { width:104px;height:104px;background-image:url(/media/buttonart_back.png);background-size:1132px 1360px;
background-repeat:no-repeat;}

What I would like, is something like this :

In short, any CSS flag to disable anti-aliasing from when scaling up images, preserving hard edges.

Any javascript hacks or similar are welcome too.

(Yes, I am aware that php and imagemagick can do this as well, but would prefer a css based solution.)

UPDATE The following have been suggested :

image-rendering: -moz-crisp-edges;
image-rendering: -moz-crisp-edges;
image-rendering: -o-crisp-edges;
image-rendering: -webkit-optimize-contrast;
-ms-interpolation-mode: nearest-neighbor;

But that doesn't seem to work on background images.

解决方案

Try this, it's a fix for removing it in all browsers.

img { 
    image-rendering: optimizeSpeed;             /* STOP SMOOTHING, GIVE ME SPEED  */
    image-rendering: -moz-crisp-edges;          /* Firefox                        */
    image-rendering: -o-crisp-edges;            /* Opera                          */
    image-rendering: -webkit-optimize-contrast; /* Chrome (and eventually Safari) */
    image-rendering: pixelated; /* Chrome */
    image-rendering: optimize-contrast;         /* CSS3 Proposed                  */
    -ms-interpolation-mode: nearest-neighbor;   /* IE8+                           */

}

Sources:

http://nullsleep.tumblr.com/post/16417178705/how-to-disable-image-smoothing-in-modern-web-browsers

http://updates.html5rocks.com/2015/01/pixelated

GitaarLAB

这篇关于在缩放图像时禁用抗锯齿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆