【发布时间】:2016-03-08 18:34:36
【问题描述】:
我意识到这可能是这个问题的重复问题:https://stackoverflow.com/questions/35582721/rendering-images-pixelated-with-openlayers-3。
但是,没有回复或 cmets。所以,我想我会在提供一些代码的同时问它。
我正在修改/更新显示各种天气相关元素(例如温度)的 PNG 图像的网页,以使用 OpenLayers 3 而不是 2,因为 OpenLayers 将允许我们使用其附加功能。我的客户需要放大和平滑时显示的实际像素。在 OpenLayers 2 中,我只需要添加图像渲染 CSS,即
.olTileImage {
image-rendering: -moz-crisp-edges; /* Firefox */
image-rendering: -o-crisp-edges; /* Opera */
image-rendering: -webkit-optimize-contrast;/* Webkit (non-standard naming) */
image-rendering: crisp-edges;
-ms-interpolation-mode: nearest-neighbor; /* IE (non-standard property) */
}
但是,如果我尝试在 .ol-viewport、.ol-unselectable、img 和 canvas 类/元素上执行相同的操作,则不会发生任何事情,并且在放大时图像仍然会变得平滑。
这就是我声明层的方式:
fcstoverlay = new ol.layer.Image({
type: 'overlay',
opacity: 0.5,
title: 'Forecast',
name: 'imgforecast',
source: new ol.source.ImageStatic({
url: "images/ndfd/conus/mercator/maxt_2016020200.png",
imageSize: [3328, 2048],
imageExtent: [-15028131.257, 1878516.407,-6887893.493, 6887893.493],
projection: ovProj
}),
visible: true
});
图层加载正常,但放大显示平滑/抗锯齿图像,我需要将其关闭。
【问题讨论】: