Deprecate the imageSmoothing option for sources
This commit is contained in:
@@ -6,6 +6,7 @@ import EventType from '../events/EventType.js';
|
||||
import ImageSource, {defaultImageLoadFunction} from './Image.js';
|
||||
import ImageState from '../ImageState.js';
|
||||
import ImageWrapper from '../Image.js';
|
||||
import {IMAGE_SMOOTHING_DISABLED} from '../renderer/canvas/common.js';
|
||||
import {assign} from '../obj.js';
|
||||
import {createCanvasContext2D} from '../dom.js';
|
||||
import {getHeight, getWidth, intersects} from '../extent.js';
|
||||
@@ -20,7 +21,9 @@ import {get as getProjection} from '../proj.js';
|
||||
* @property {import("../extent.js").Extent} [imageExtent] Extent of the image in map coordinates.
|
||||
* This is the [left, bottom, right, top] map coordinates of your image.
|
||||
* @property {import("../Image.js").LoadFunction} [imageLoadFunction] Optional function to load an image given a URL.
|
||||
* @property {boolean} [imageSmoothing=true] Enable image smoothing.
|
||||
* @property {boolean} [imageSmoothing=true] Deprecated. Use the `interpolate` option instead.
|
||||
* @property {boolean} [interpolate=true] Use interpolated values when resampling. By default,
|
||||
* linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.
|
||||
* @property {import("../proj.js").ProjectionLike} [projection] Projection. Default is the view projection.
|
||||
* @property {import("../size.js").Size} [imageSize] Size of the image in pixels. Usually the image size is auto-detected, so this
|
||||
* only needs to be set if auto-detection fails for some reason.
|
||||
@@ -45,9 +48,15 @@ class Static extends ImageSource {
|
||||
? options.imageLoadFunction
|
||||
: defaultImageLoadFunction;
|
||||
|
||||
let interpolate =
|
||||
options.imageSmoothing !== undefined ? options.imageSmoothing : true;
|
||||
if (options.interpolate !== undefined) {
|
||||
interpolate = options.interpolate;
|
||||
}
|
||||
|
||||
super({
|
||||
attributions: options.attributions,
|
||||
imageSmoothing: options.imageSmoothing,
|
||||
interpolate: interpolate,
|
||||
projection: getProjection(options.projection),
|
||||
});
|
||||
|
||||
@@ -148,7 +157,9 @@ class Static extends ImageSource {
|
||||
}
|
||||
if (targetWidth !== imageWidth || targetHeight !== imageHeight) {
|
||||
const context = createCanvasContext2D(targetWidth, targetHeight);
|
||||
assign(context, this.getContextOptions());
|
||||
if (!this.getInterpolate()) {
|
||||
assign(context, IMAGE_SMOOTHING_DISABLED);
|
||||
}
|
||||
const canvas = context.canvas;
|
||||
context.drawImage(
|
||||
image,
|
||||
|
||||
Reference in New Issue
Block a user