Skip to content

Commit 129f731

Browse files
committed
[css-images-3] Switch image-rendering:pixelated to be slightly smooth. Add new nearest-neighbor value for strict NN. w3c#5837
1 parent b65e4ce commit 129f731

1 file changed

Lines changed: 40 additions & 8 deletions

File tree

css-images-3/Overview.bs

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ At Risk: 'image-orientation'
2020
Implementation Report: https://wpt.fyi/results/css/css-images?label=experimental&label=master&aligned
2121
Previous Version: https://www.w3.org/TR/2019/CR-css-images-3-20191010/
2222
Previous Version: https://www.w3.org/TR/2012/CR-css3-images-20120417/
23-
Ignored Terms: <offset>, background positioning area, border image area, <meetorslice>, <ending-shape>, Map, center, content
23+
Ignored Terms: <offset>, background positioning area, border image area, <meetorslice>, <ending-shape>
2424
Ignored Vars: start image, end image
25-
Link Defaults: css2 (property) display
2625
Include Can I Use Panels: yes
2726
</pre>
2827
<pre class=link-defaults>
2928
spec:svg; type:element; text:feimage
29+
spec:css-backgrounds-3; type:value; text:center
3030
</pre>
3131

3232
Introduction {#intro}
@@ -1740,16 +1740,48 @@ Determining How To Scale an Image: the 'image-rendering' property {#the-image-re
17401740
only apply it to the most important images on the page.
17411741
</div>
17421742

1743+
<dt><dfn>pixelated</dfn>
1744+
<dd>
1745+
The image is scaled in a way that preserves the pixelated nature of the original as much as possible,
1746+
but allows minor smoothing instead of awkward distortion in some cases.
1747+
1748+
For each axis,
1749+
independently determine the integer multiple of its natural size
1750+
that puts it closest to the target size
1751+
and is greater than zero.
1752+
1753+
Scale it to this integer-multiple-size as for ''nearest-neighbor'',
1754+
then scale it the rest of the way to the target size as for ''smooth''.
1755+
1756+
Note: At integer multiples of the natural size,
1757+
this gives the same results as ''nearest-neighbor''.
1758+
At non-integer multiples, this usually gives better visual results,
1759+
even for pixel art,
1760+
but it does incur a performance penalty
1761+
due to the "two-step" rendering requirement.
1762+
17431763
<dt><dfn caniuse="css-crisp-edges">crisp-edges</dfn>
17441764
<dd>
17451765
The image must be scaled with an algorithm that preserves contrast and edges in the image,
17461766
and which does not smooth colors or introduce blur to the image in the process.
1747-
This is intended for images such as pixel art or line drawings.
17481767

1749-
<dt><dfn>pixelated</dfn>
1768+
This <em>may</em> be identical to ''nearest-neighbor'',
1769+
but UAs may use any algorithm that meets the requirements.
1770+
1771+
<dt><dfn>nearest-neighbor</dfn>
17501772
<dd>
1751-
The image must be scaled with the "nearest neighbor" or similar algorithm,
1752-
to preserve a "pixelated" look as the image changes in size.
1773+
The image must be scaled with the "nearest neighbor" algorithm:
1774+
treating the original image's pixel grid as a literal grid of rectangles,
1775+
scale those to the desired size,
1776+
then each pixel of the final image
1777+
takes its color solely from the nearest pixel of the scaled original image.
1778+
1779+
Note: If the new size is not an integer multiple of the original size,
1780+
the NN algorithm can introduce significant "aliasing" bugs;
1781+
lines that were the same thickness in the original image
1782+
might be a pixel thinner or thicker in the scaled image,
1783+
depending on where they appear,
1784+
etc.
17531785
</dl>
17541786

17551787
This property does not dictate any particular scaling algorithm to be used.
@@ -1786,7 +1818,7 @@ Determining How To Scale an Image: the 'image-rendering' property {#the-image-re
17861818
<img src="images/pixel-art-smooth.png">
17871819
<figcaption>
17881820
The image scaled with ''crisp-edges''.<br>
1789-
<small>(Or it might look like ''pixelated'',
1821+
<small>(Or it might look like ''nearest-neighbor'',
17901822
or as another type of pixel-scaling algorithm,
17911823
depending on the browser.)</small>
17921824
</figcaption>
@@ -1796,7 +1828,7 @@ Determining How To Scale an Image: the 'image-rendering' property {#the-image-re
17961828
This property previously accepted the values ''optimizeSpeed'' and ''optimizeQuality''.
17971829
These are now deprecated;
17981830
a user agent must accept them as valid values
1799-
but must treat them as having the same behavior as ''pixelated'' and ''smooth'' respectively,
1831+
but must treat them as having the same behavior as ''nearest-neighbor'' and ''smooth'' respectively,
18001832
and authors must not use them.
18011833

18021834

0 commit comments

Comments
 (0)